Lines Matching refs:bat_priv

36  * @bat_priv: the bat priv with all the soft interface information
38 static void batadv_dat_start_timer(struct batadv_priv *bat_priv)
40 INIT_DELAYED_WORK(&bat_priv->dat.work, batadv_dat_purge);
41 queue_delayed_work(batadv_event_workqueue, &bat_priv->dat.work,
70 * @bat_priv: the bat priv with all the soft interface information
79 static void __batadv_dat_purge(struct batadv_priv *bat_priv,
88 if (!bat_priv->dat.hash)
91 for (i = 0; i < bat_priv->dat.hash->size; i++) {
92 head = &bat_priv->dat.hash->table[i];
93 list_lock = &bat_priv->dat.hash->list_locks[i];
120 struct batadv_priv *bat_priv;
124 bat_priv = container_of(priv_dat, struct batadv_priv, dat);
126 __batadv_dat_purge(bat_priv, batadv_dat_to_purge);
127 batadv_dat_start_timer(bat_priv);
223 * @bat_priv: the bat priv with all the soft interface information
230 batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
235 struct batadv_hashtable *hash = bat_priv->dat.hash;
265 * @bat_priv: the bat priv with all the soft interface information
270 static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
276 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip, vid);
282 batadv_dbg(BATADV_DBG_DAT, bat_priv,
299 hash_added = batadv_hash_add(bat_priv->dat.hash, batadv_compare_dat,
309 batadv_dbg(BATADV_DBG_DAT, bat_priv, "New entry added: %pI4 %pM (vid: %d)\n",
321 * @bat_priv: the bat priv with all the soft interface information
327 static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
336 batadv_dbg(BATADV_DBG_DAT, bat_priv, "%s\n", msg);
340 batadv_dbg(BATADV_DBG_DAT, bat_priv,
352 batadv_dbg(BATADV_DBG_DAT, bat_priv,
356 batadv_dbg(BATADV_DBG_DAT, bat_priv,
361 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: DAT_DHT_PUT\n");
364 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: DAT_DHT_GET\n");
367 batadv_dbg(BATADV_DBG_DAT, bat_priv,
371 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: DATA\n");
374 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: Unknown (%u)!\n",
381 batadv_dbg(BATADV_DBG_DAT, bat_priv,
386 batadv_dbg(BATADV_DBG_DAT, bat_priv,
394 static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
457 * @bat_priv: the bat priv with all the soft interface information
463 static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
470 struct batadv_hashtable *hash = bat_priv->orig_hash;
510 batadv_dbg(BATADV_DBG_DAT, bat_priv,
521 * @bat_priv: the bat priv with all the soft interface information
531 batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst)
537 if (!bat_priv->orig_hash)
548 batadv_dbg(BATADV_DBG_DAT, bat_priv,
553 batadv_choose_next_candidate(bat_priv, res, select, ip_key,
561 * @bat_priv: the bat priv with all the soft interface information
572 static bool batadv_dat_send_data(struct batadv_priv *bat_priv,
583 cand = batadv_dat_select_candidates(bat_priv, ip);
587 batadv_dbg(BATADV_DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", &ip);
599 if (!batadv_send_skb_prepare_unicast_4addr(bat_priv, tmp_skb,
613 batadv_inc_counter(bat_priv,
617 batadv_inc_counter(bat_priv,
639 * @bat_priv: the bat priv with all the soft interface information
641 static void batadv_dat_tvlv_container_update(struct batadv_priv *bat_priv)
645 dat_mode = atomic_read(&bat_priv->distributed_arp_table);
649 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1);
652 batadv_tvlv_container_register(bat_priv, BATADV_TVLV_DAT, 1,
665 struct batadv_priv *bat_priv = netdev_priv(net_dev);
667 batadv_dat_tvlv_container_update(bat_priv);
672 * @bat_priv: the bat priv with all the soft interface information
678 static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
692 * @bat_priv: the bat priv with all the soft interface information
694 static void batadv_dat_hash_free(struct batadv_priv *bat_priv)
696 if (!bat_priv->dat.hash)
699 __batadv_dat_purge(bat_priv, NULL);
701 batadv_hash_destroy(bat_priv->dat.hash);
703 bat_priv->dat.hash = NULL;
708 * @bat_priv: the bat priv with all the soft interface information
710 int batadv_dat_init(struct batadv_priv *bat_priv)
712 if (bat_priv->dat.hash)
715 bat_priv->dat.hash = batadv_hash_new(1024);
717 if (!bat_priv->dat.hash)
720 batadv_dat_start_timer(bat_priv);
722 batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1,
725 batadv_dat_tvlv_container_update(bat_priv);
731 * @bat_priv: the bat priv with all the soft interface information
733 void batadv_dat_free(struct batadv_priv *bat_priv)
735 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1);
736 batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_DAT, 1);
738 cancel_delayed_work_sync(&bat_priv->dat.work);
740 batadv_dat_hash_free(bat_priv);
751 struct batadv_priv *bat_priv = netdev_priv(net_dev);
752 struct batadv_hashtable *hash = bat_priv->dat.hash;
795 * @bat_priv: the bat priv with all the soft interface information
801 static uint16_t batadv_arp_get_type(struct batadv_priv *bat_priv,
895 * @bat_priv: the bat priv with all the soft interface information
902 bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
914 if (!atomic_read(&bat_priv->distributed_arp_table))
919 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
926 batadv_dbg_arp(bat_priv, skb, type, hdr_size,
933 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
935 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
945 if (batadv_is_my_client(bat_priv, dat_entry->mac_addr, vid)) {
951 bat_priv->soft_iface, ip_dst, hw_src,
962 bat_priv->soft_iface);
963 bat_priv->stats.rx_packets++;
964 bat_priv->stats.rx_bytes += skb->len + ETH_HLEN + hdr_size;
965 bat_priv->soft_iface->last_rx = jiffies;
968 batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n");
972 ret = batadv_dat_send_data(bat_priv, skb, ip_dst,
984 * @bat_priv: the bat priv with all the soft interface information
990 bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
1002 if (!atomic_read(&bat_priv->distributed_arp_table))
1007 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1015 batadv_dbg_arp(bat_priv, skb, type, hdr_size,
1018 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1020 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
1025 bat_priv->soft_iface, ip_dst, hw_src,
1045 err = batadv_send_skb_via_tt_4addr(bat_priv, skb_new,
1049 err = batadv_send_skb_via_tt(bat_priv, skb_new, NULL, vid);
1052 batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
1065 * @bat_priv: the bat priv with all the soft interface information
1068 void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
1077 if (!atomic_read(&bat_priv->distributed_arp_table))
1082 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1086 batadv_dbg_arp(bat_priv, skb, type, hdr_size,
1094 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1095 batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
1100 batadv_dat_send_data(bat_priv, skb, ip_src, BATADV_P_DAT_DHT_PUT);
1101 batadv_dat_send_data(bat_priv, skb, ip_dst, BATADV_P_DAT_DHT_PUT);
1106 * @bat_priv: the bat priv with all the soft interface information
1110 bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
1119 if (!atomic_read(&bat_priv->distributed_arp_table))
1124 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1128 batadv_dbg_arp(bat_priv, skb, type, hdr_size,
1139 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1140 batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
1145 ret = !batadv_is_my_client(bat_priv, hw_dst, vid);
1156 * @bat_priv: the bat priv with all the soft interface information
1161 bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
1171 if (!atomic_read(&bat_priv->distributed_arp_table))
1182 type = batadv_arp_get_type(bat_priv, forw_packet->skb, hdr_size);
1187 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
1190 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1195 batadv_dbg(BATADV_DBG_DAT, bat_priv,