Lines Matching refs:bat_priv
101 * @bat_priv: the bat priv with all the soft interface information
103 static void batadv_dat_start_timer(struct batadv_priv *bat_priv)
105 queue_delayed_work(batadv_event_workqueue, &bat_priv->dat.work,
150 * @bat_priv: the bat priv with all the soft interface information
159 static void __batadv_dat_purge(struct batadv_priv *bat_priv,
168 if (!bat_priv->dat.hash)
171 for (i = 0; i < bat_priv->dat.hash->size; i++) {
172 head = &bat_priv->dat.hash->table[i];
173 list_lock = &bat_priv->dat.hash->list_locks[i];
200 struct batadv_priv *bat_priv;
204 bat_priv = container_of(priv_dat, struct batadv_priv, dat);
206 __batadv_dat_purge(bat_priv, batadv_dat_to_purge);
207 batadv_dat_start_timer(bat_priv);
320 * @bat_priv: the bat priv with all the soft interface information
327 batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip,
332 struct batadv_hashtable *hash = bat_priv->dat.hash;
362 * @bat_priv: the bat priv with all the soft interface information
367 static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip,
373 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip, vid);
379 batadv_dbg(BATADV_DBG_DAT, bat_priv,
397 hash_added = batadv_hash_add(bat_priv->dat.hash, batadv_compare_dat,
407 batadv_dbg(BATADV_DBG_DAT, bat_priv, "New entry added: %pI4 %pM (vid: %d)\n",
420 * @bat_priv: the bat priv with all the soft interface information
425 static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
434 batadv_dbg(BATADV_DBG_DAT, bat_priv, "%s\n", msg);
438 batadv_dbg(BATADV_DBG_DAT, bat_priv,
450 batadv_dbg(BATADV_DBG_DAT, bat_priv,
454 batadv_dbg(BATADV_DBG_DAT, bat_priv,
459 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: DAT_DHT_PUT\n");
462 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: DAT_DHT_GET\n");
465 batadv_dbg(BATADV_DBG_DAT, bat_priv,
469 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: DATA\n");
472 batadv_dbg(BATADV_DBG_DAT, bat_priv, "* type: Unknown (%u)!\n",
479 batadv_dbg(BATADV_DBG_DAT, bat_priv,
484 batadv_dbg(BATADV_DBG_DAT, bat_priv,
492 static void batadv_dbg_arp(struct batadv_priv *bat_priv, struct sk_buff *skb,
555 * @bat_priv: the bat priv with all the soft interface information
561 static void batadv_choose_next_candidate(struct batadv_priv *bat_priv,
569 struct batadv_hashtable *hash = bat_priv->orig_hash;
609 batadv_dbg(BATADV_DBG_DAT, bat_priv,
620 * @bat_priv: the bat priv with all the soft interface information
631 batadv_dat_select_candidates(struct batadv_priv *bat_priv, __be32 ip_dst,
639 if (!bat_priv->orig_hash)
652 batadv_dbg(BATADV_DBG_DAT, bat_priv,
657 batadv_choose_next_candidate(bat_priv, res, select, ip_key,
665 * @bat_priv: the bat priv with all the soft interface information
677 static bool batadv_dat_forward_data(struct batadv_priv *bat_priv,
688 cand = batadv_dat_select_candidates(bat_priv, ip, vid);
692 batadv_dbg(BATADV_DBG_DAT, bat_priv, "DHT_SEND for %pI4\n", &ip);
704 if (!batadv_send_skb_prepare_unicast_4addr(bat_priv, tmp_skb,
716 batadv_inc_counter(bat_priv,
720 batadv_inc_counter(bat_priv,
742 * @bat_priv: the bat priv with all the soft interface information
744 static void batadv_dat_tvlv_container_update(struct batadv_priv *bat_priv)
748 dat_mode = atomic_read(&bat_priv->distributed_arp_table);
752 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1);
755 batadv_tvlv_container_register(bat_priv, BATADV_TVLV_DAT, 1,
768 struct batadv_priv *bat_priv = netdev_priv(net_dev);
770 batadv_dat_tvlv_container_update(bat_priv);
775 * @bat_priv: the bat priv with all the soft interface information
781 static void batadv_dat_tvlv_ogm_handler_v1(struct batadv_priv *bat_priv,
794 * @bat_priv: the bat priv with all the soft interface information
796 static void batadv_dat_hash_free(struct batadv_priv *bat_priv)
798 if (!bat_priv->dat.hash)
801 __batadv_dat_purge(bat_priv, NULL);
803 batadv_hash_destroy(bat_priv->dat.hash);
805 bat_priv->dat.hash = NULL;
810 * @bat_priv: the bat priv with all the soft interface information
814 int batadv_dat_init(struct batadv_priv *bat_priv)
816 if (bat_priv->dat.hash)
819 bat_priv->dat.hash = batadv_hash_new(1024);
821 if (!bat_priv->dat.hash)
824 INIT_DELAYED_WORK(&bat_priv->dat.work, batadv_dat_purge);
825 batadv_dat_start_timer(bat_priv);
827 batadv_tvlv_handler_register(bat_priv, batadv_dat_tvlv_ogm_handler_v1,
830 batadv_dat_tvlv_container_update(bat_priv);
836 * @bat_priv: the bat priv with all the soft interface information
838 void batadv_dat_free(struct batadv_priv *bat_priv)
840 batadv_tvlv_container_unregister(bat_priv, BATADV_TVLV_DAT, 1);
841 batadv_tvlv_handler_unregister(bat_priv, BATADV_TVLV_DAT, 1);
843 cancel_delayed_work_sync(&bat_priv->dat.work);
845 batadv_dat_hash_free(bat_priv);
859 struct batadv_priv *bat_priv = netdev_priv(net_dev);
860 struct batadv_hashtable *hash = bat_priv->dat.hash;
1001 struct batadv_priv *bat_priv;
1018 bat_priv = netdev_priv(soft_iface);
1019 hash = bat_priv->dat.hash;
1021 primary_if = batadv_primary_if_get_selected(bat_priv);
1053 * @bat_priv: the bat priv with all the soft interface information
1059 static u16 batadv_arp_get_type(struct batadv_priv *bat_priv,
1153 * @bat_priv: the bat priv with all the soft interface information
1166 batadv_dat_arp_create_reply(struct batadv_priv *bat_priv, __be32 ip_src,
1172 skb = arp_create(ARPOP_REPLY, ETH_P_ARP, ip_dst, bat_priv->soft_iface,
1189 * @bat_priv: the bat priv with all the soft interface information
1196 bool batadv_dat_snoop_outgoing_arp_request(struct batadv_priv *bat_priv,
1205 struct net_device *soft_iface = bat_priv->soft_iface;
1209 if (!atomic_read(&bat_priv->distributed_arp_table))
1214 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1221 batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing outgoing ARP REQUEST");
1227 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1229 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
1239 if (batadv_is_my_client(bat_priv, dat_entry->mac_addr, vid)) {
1249 if (!batadv_bla_check_claim(bat_priv,
1251 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1258 skb_new = batadv_dat_arp_create_reply(bat_priv, ip_dst, ip_src,
1266 batadv_inc_counter(bat_priv, BATADV_CNT_RX);
1267 batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
1271 batadv_dbg(BATADV_DBG_DAT, bat_priv, "ARP request replied locally\n");
1275 ret = batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
1287 * @bat_priv: the bat priv with all the soft interface information
1293 bool batadv_dat_snoop_incoming_arp_request(struct batadv_priv *bat_priv,
1305 if (!atomic_read(&bat_priv->distributed_arp_table))
1310 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1318 batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing incoming ARP REQUEST");
1320 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1322 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
1326 skb_new = batadv_dat_arp_create_reply(bat_priv, ip_dst, ip_src,
1336 err = batadv_send_skb_via_tt_4addr(bat_priv, skb_new,
1340 err = batadv_send_skb_via_tt(bat_priv, skb_new, NULL, vid);
1343 batadv_inc_counter(bat_priv, BATADV_CNT_DAT_CACHED_REPLY_TX);
1356 * @bat_priv: the bat priv with all the soft interface information
1359 void batadv_dat_snoop_outgoing_arp_reply(struct batadv_priv *bat_priv,
1368 if (!atomic_read(&bat_priv->distributed_arp_table))
1373 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1377 batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing outgoing ARP REPLY");
1384 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1385 batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
1390 batadv_dat_forward_data(bat_priv, skb, ip_src, vid,
1392 batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
1399 * @bat_priv: the bat priv with all the soft interface information
1406 bool batadv_dat_snoop_incoming_arp_reply(struct batadv_priv *bat_priv,
1416 if (!atomic_read(&bat_priv->distributed_arp_table))
1421 type = batadv_arp_get_type(bat_priv, skb, hdr_size);
1425 batadv_dbg_arp(bat_priv, skb, hdr_size, "Parsing incoming ARP REPLY");
1438 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_src, vid);
1440 batadv_dbg(BATADV_DBG_DAT, bat_priv, "Doubled ARP reply removed: ARP MSG = [src: %pM-%pI4 dst: %pM-%pI4]; dat_entry: %pM-%pI4\n",
1449 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1450 batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
1461 if (!batadv_bla_check_claim(bat_priv, hw_src, vid)) {
1462 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1472 dropped = !batadv_is_my_client(bat_priv, hw_dst, vid);
1477 dropped |= batadv_is_my_client(bat_priv, hw_src, vid);
1681 * @bat_priv: the bat priv with all the soft interface information
1694 static void batadv_dat_put_dhcp(struct batadv_priv *bat_priv, u8 *chaddr,
1700 skb = batadv_dat_arp_create_reply(bat_priv, yiaddr, ip_dst, chaddr,
1707 batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid);
1708 batadv_dat_entry_add(bat_priv, ip_dst, hw_dst, vid);
1710 batadv_dat_forward_data(bat_priv, skb, yiaddr, vid,
1712 batadv_dat_forward_data(bat_priv, skb, ip_dst, vid,
1717 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1720 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1766 * @bat_priv: the bat priv with all the soft interface information
1779 void batadv_dat_snoop_outgoing_dhcp_ack(struct batadv_priv *bat_priv,
1787 if (!atomic_read(&bat_priv->distributed_arp_table))
1793 batadv_dat_put_dhcp(bat_priv, chaddr, yiaddr, eth_hdr(skb)->h_source,
1799 * @bat_priv: the bat priv with all the soft interface information
1807 void batadv_dat_snoop_incoming_dhcp_ack(struct batadv_priv *bat_priv,
1817 if (!atomic_read(&bat_priv->distributed_arp_table))
1833 batadv_dat_entry_add(bat_priv, yiaddr, chaddr, vid);
1834 batadv_dat_entry_add(bat_priv, ip_src, hw_src, vid);
1836 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1839 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1847 * @bat_priv: the bat priv with all the soft interface information
1852 bool batadv_dat_drop_broadcast_packet(struct batadv_priv *bat_priv,
1862 if (!atomic_read(&bat_priv->distributed_arp_table))
1873 type = batadv_arp_get_type(bat_priv, forw_packet->skb, hdr_size);
1878 dat_entry = batadv_dat_entry_hash_find(bat_priv, ip_dst, vid);
1881 batadv_dbg(BATADV_DBG_DAT, bat_priv,
1886 batadv_dbg(BATADV_DBG_DAT, bat_priv,