Lines Matching refs:bat_priv

100  * @bat_priv: the bat priv with all the soft interface information
102 static void batadv_dat_start_timer(struct batadv_priv *bat_priv)
104 queue_delayed_work(batadv_event_workqueue, &bat_priv->dat.work,
149 * @bat_priv: the bat priv with all the soft interface information
158 static void __batadv_dat_purge(struct batadv_priv *bat_priv,
167 if (!bat_priv->dat.hash)
170 for (i = 0; i < bat_priv->dat.hash->size; i++) {
171 head = &bat_priv->dat.hash->table[i];
172 list_lock = &bat_priv->dat.hash->list_locks[i];
199 struct batadv_priv *bat_priv;
203 bat_priv = container_of(priv_dat, struct batadv_priv, dat);
205 __batadv_dat_purge(bat_priv, batadv_dat_to_purge);
206 batadv_dat_start_timer(bat_priv);
319 * @bat_priv: the bat priv with all the soft interface information
326 batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
331 struct batadv_hashtable *hash = bat_priv->dat.hash;
361 * @bat_priv: the bat priv with all the soft interface information
366 static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
372 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip, vid);
378 batadv_dbg(BATADV_DBG_DAT, bat_priv,
396 hash_added = batadv_hash_add(bat_priv->dat.hash, batadv_compare_dat,
406 batadv_dbg(BATADV_DBG_DAT, bat_priv, "New entry added: %pI4 %pM (vid: %d)\n",
418 * @bat_priv: the bat priv with all the soft interface information
423 static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
432 batadv_dbg(BATADV_DBG_DAT, bat_priv, "%s\n", msg);
436 batadv_dbg(BATADV_DBG_DAT, bat_priv,
448 batadv_dbg(BATADV_DBG_DAT, bat_priv,
452 batadv_dbg(BATADV_DBG_DAT, bat_priv,
457 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: DAT_DHT_PUT\n");
460 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: DAT_DHT_GET\n");
463 batadv_dbg(BATADV_DBG_DAT, bat_priv,
467 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: DATA\n");
470 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: Unknown (%u)!\n",
477 batadv_dbg(BATADV_DBG_DAT, bat_priv,
482 batadv_dbg(BATADV_DBG_DAT, bat_priv,
490 static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
553 * @bat_priv: the bat priv with all the soft interface information
559 static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
567 struct batadv_hashtable *hash = bat_priv->orig_hash;
606 batadv_dbg(BATADV_DBG_DAT, bat_priv,
617 * @bat_priv: the bat priv with all the soft interface information
628 batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
636 if (!bat_priv->orig_hash)
649 batadv_dbg(BATADV_DBG_DAT, bat_priv,
654 batadv_choose_next_candidate(bat_priv, res, select, ip_key,
662 * @bat_priv: the bat priv with all the soft interface information
674 static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,
685 cand = batadv_dat_select_candidates(bat_priv, ip, vid);
689 batadv_dbg(BATADV_DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", &ip);
701 if (!batadv_send_skb_prepare_unicast_4addr(bat_priv, tmp_skb,
713 batadv_inc_counter(bat_priv,
717 batadv_inc_counter(bat_priv,
739 * @bat_priv: the bat priv with all the soft interface information
741 static void batadv_dat_tvlv_container_update(struct batadv_priv *bat_priv)
745 dat_mode = atomic_read(&bat_priv->distributed_arp_table);
749 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1);
752 batadv_tvlv_container_register(bat_priv, BATADV_TVLV_DAT, 1,
765 struct batadv_priv *bat_priv = netdev_priv(net_dev);
767 batadv_dat_tvlv_container_update(bat_priv);
772 * @bat_priv: the bat priv with all the soft interface information
778 static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
791 * @bat_priv: the bat priv with all the soft interface information
793 static void batadv_dat_hash_free(struct batadv_priv *bat_priv)
795 if (!bat_priv->dat.hash)
798 __batadv_dat_purge(bat_priv, NULL);
800 batadv_hash_destroy(bat_priv->dat.hash);
802 bat_priv->dat.hash = NULL;
807 * @bat_priv: the bat priv with all the soft interface information
811 int batadv_dat_init(struct batadv_priv *bat_priv)
813 if (bat_priv->dat.hash)
816 bat_priv->dat.hash = batadv_hash_new(1024);
818 if (!bat_priv->dat.hash)
821 INIT_DELAYED_WORK(&bat_priv->dat.work, batadv_dat_purge);
822 batadv_dat_start_timer(bat_priv);
824 batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1,
827 batadv_dat_tvlv_container_update(bat_priv);
833 * @bat_priv: the bat priv with all the soft interface information
835 void batadv_dat_free(struct batadv_priv *bat_priv)
837 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1);
838 batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_DAT, 1);
840 cancel_delayed_work_sync(&bat_priv->dat.work);
842 batadv_dat_hash_free(bat_priv);
944 struct batadv_priv *bat_priv;
961 bat_priv = netdev_priv(soft_iface);
962 hash = bat_priv->dat.hash;
964 primary_if = batadv_primary_if_get_selected(bat_priv);
994 * @bat_priv: the bat priv with all the soft interface information
1000 static u16 batadv_arp_get_type(struct batadv_priv *bat_priv,
1094 * @bat_priv: the bat priv with all the soft interface information
1107 batadv_dat_arp_create_reply(struct batadv_priv *bat_priv, __be32 ip_src,
1113 skb = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_dst, bat_priv->soft_iface,
1130 * @bat_priv: the bat priv with all the soft interface information
1137 bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
1146 struct net_device *soft_iface = bat_priv->soft_iface;
1150 if (!atomic_read(&bat_priv->distributed_arp_table))
1155 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1162 batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing outgoing ARP REQUEST");
1168 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1170 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
1180 if (batadv_is_my_client(bat_priv, dat_entry->mac_addr, vid)) {
1190 if (!batadv_bla_check_claim(bat_priv,
1192 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1199 skb_new = batadv_dat_arp_create_reply(bat_priv, ip_dst, ip_src,
1207 batadv_inc_counter(bat_priv, BATADV_CNT_RX);
1208 batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
1212 batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n");
1216 ret = batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
1227 * @bat_priv: the bat priv with all the soft interface information
1233 bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
1245 if (!atomic_read(&bat_priv->distributed_arp_table))
1250 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1258 batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing incoming ARP REQUEST");
1260 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1262 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
1266 skb_new = batadv_dat_arp_create_reply(bat_priv, ip_dst, ip_src,
1276 err = batadv_send_skb_via_tt_4addr(bat_priv, skb_new,
1280 err = batadv_send_skb_via_tt(bat_priv, skb_new, NULL, vid);
1283 batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
1295 * @bat_priv: the bat priv with all the soft interface information
1298 void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
1307 if (!atomic_read(&bat_priv->distributed_arp_table))
1312 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1316 batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing outgoing ARP REPLY");
1323 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1324 batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
1329 batadv_dat_forward_data(bat_priv, skb, ip_src, vid,
1331 batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
1338 * @bat_priv: the bat priv with all the soft interface information
1345 bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
1355 if (!atomic_read(&bat_priv->distributed_arp_table))
1360 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1364 batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing incoming ARP REPLY");
1377 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_src, vid);
1379 batadv_dbg(BATADV_DBG_DAT, bat_priv, "Doubled ARP reply removed: ARP MSG = [src: %pM-%pI4 dst: %pM-%pI4]; dat_entry: %pM-%pI4\n",
1388 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1389 batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
1400 if (!batadv_bla_check_claim(bat_priv, hw_src, vid)) {
1401 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1411 dropped = !batadv_is_my_client(bat_priv, hw_dst, vid);
1416 dropped |= batadv_is_my_client(bat_priv, hw_src, vid);
1619 * @bat_priv: the bat priv with all the soft interface information
1632 static void batadv_dat_put_dhcp(struct batadv_priv *bat_priv, u8 *chaddr,
1638 skb = batadv_dat_arp_create_reply(bat_priv, yiaddr, ip_dst, chaddr,
1645 batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid);
1646 batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
1648 batadv_dat_forward_data(bat_priv, skb, yiaddr, vid,
1650 batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
1655 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1658 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1704 * @bat_priv: the bat priv with all the soft interface information
1717 void batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
1725 if (!atomic_read(&bat_priv->distributed_arp_table))
1731 batadv_dat_put_dhcp(bat_priv, chaddr, yiaddr, eth_hdr(skb)->h_source,
1737 * @bat_priv: the bat priv with all the soft interface information
1745 void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
1755 if (!atomic_read(&bat_priv->distributed_arp_table))
1771 batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid);
1772 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1774 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1777 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1785 * @bat_priv: the bat priv with all the soft interface information
1790 bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
1800 if (!atomic_read(&bat_priv->distributed_arp_table))
1811 type = batadv_arp_get_type(bat_priv, forw_packet->skb, hdr_size);
1816 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
1819 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1824 batadv_dbg(BATADV_DBG_DAT, bat_priv,