Lines Matching refs:bat_priv
56 batadv_bla_send_announce(struct batadv_priv *bat_priv,
212 * @bat_priv: the bat priv with all the soft interface information
218 batadv_claim_hash_find(struct batadv_priv *bat_priv,
221 struct batadv_hashtable *hash = bat_priv->bla.claim_hash;
251 * @bat_priv: the bat priv with all the soft interface information
258 batadv_backbone_hash_find(struct batadv_priv *bat_priv, const u8 *addr,
261 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
307 hash = backbone_gw->bat_priv->bla.claim_hash;
335 * @bat_priv: the bat priv with all the soft interface information
340 static void batadv_bla_send_claim(struct batadv_priv *bat_priv, const u8 *mac,
351 primary_if = batadv_primary_if_get_selected(bat_priv);
355 memcpy(&local_claim_dest, &bat_priv->bla.claim_dest,
390 batadv_dbg(BATADV_DBG_BLA, bat_priv,
399 batadv_dbg(BATADV_DBG_BLA, bat_priv,
408 batadv_dbg(BATADV_DBG_BLA, bat_priv,
419 batadv_dbg(BATADV_DBG_BLA, bat_priv,
426 batadv_dbg(BATADV_DBG_BLA, bat_priv,
443 batadv_inc_counter(bat_priv, BATADV_CNT_RX);
444 batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
462 struct batadv_priv *bat_priv;
467 bat_priv = backbone_gw->bat_priv;
469 batadv_info(bat_priv->soft_iface,
476 batadv_throw_uevent(bat_priv, BATADV_UEV_BLA, BATADV_UEV_LOOPDETECT,
484 * @bat_priv: the bat priv with all the soft interface information
492 batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, const u8 *orig,
499 entry = batadv_backbone_hash_find(bat_priv, orig, vid);
504 batadv_dbg(BATADV_DBG_BLA, bat_priv,
515 entry->bat_priv = bat_priv;
524 hash_added = batadv_hash_add(bat_priv->bla.backbone_hash,
536 orig_node = batadv_orig_hash_find(bat_priv, orig);
538 batadv_tt_global_del_orig(bat_priv, orig_node, vid,
544 batadv_bla_send_announce(bat_priv, entry);
549 atomic_inc(&bat_priv->bla.num_requests);
557 * @bat_priv: the bat priv with all the soft interface information
565 batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv,
571 backbone_gw = batadv_bla_get_backbone_gw(bat_priv,
583 * @bat_priv: the bat priv with all the soft interface information
590 static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
600 batadv_dbg(BATADV_DBG_BLA, bat_priv,
604 backbone_gw = batadv_backbone_hash_find(bat_priv,
610 hash = bat_priv->bla.claim_hash;
620 batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
627 batadv_bla_send_announce(bat_priv, backbone_gw);
644 batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
648 batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig,
653 atomic_inc(&backbone_gw->bat_priv->bla.num_requests);
660 * @bat_priv: the bat priv with all the soft interface information
663 static void batadv_bla_send_announce(struct batadv_priv *bat_priv,
675 batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid,
681 * @bat_priv: the bat priv with all the soft interface information
686 static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
698 claim = batadv_claim_hash_find(bat_priv, &search_claim);
714 batadv_dbg(BATADV_DBG_BLA, bat_priv,
719 hash_added = batadv_hash_add(bat_priv->bla.claim_hash,
735 batadv_dbg(BATADV_DBG_BLA, bat_priv,
791 * @bat_priv: the bat priv with all the soft interface information
795 static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
804 claim = batadv_claim_hash_find(bat_priv, &search_claim);
808 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): %pM, vid %d\n", __func__,
811 claim_removed_node = batadv_hash_remove(bat_priv->bla.claim_hash,
829 * @bat_priv: the bat priv with all the soft interface information
836 static bool batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
845 backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid,
855 batadv_dbg(BATADV_DBG_BLA, bat_priv,
864 batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
876 atomic_dec(&backbone_gw->bat_priv->bla.num_requests);
887 * @bat_priv: the bat priv with all the soft interface information
895 static bool batadv_handle_request(struct batadv_priv *bat_priv,
910 batadv_dbg(BATADV_DBG_BLA, bat_priv,
914 batadv_bla_answer_request(bat_priv, primary_if, vid);
920 * @bat_priv: the bat priv with all the soft interface information
928 static bool batadv_handle_unclaim(struct batadv_priv *bat_priv,
938 batadv_bla_send_claim(bat_priv, claim_addr, vid,
941 backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);
947 batadv_dbg(BATADV_DBG_BLA, bat_priv,
951 batadv_bla_del_claim(bat_priv, claim_addr, vid);
958 * @bat_priv: the bat priv with all the soft interface information
966 static bool batadv_handle_claim(struct batadv_priv *bat_priv,
975 backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid,
982 batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
984 batadv_bla_send_claim(bat_priv, claim_addr, vid,
995 * @bat_priv: the bat priv with all the soft interface information
1010 static int batadv_check_claim_group(struct batadv_priv *bat_priv,
1020 bla_dst_own = &bat_priv->bla.claim_dest;
1047 orig_node = batadv_orig_hash_find(bat_priv, backbone_addr);
1057 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1070 * @bat_priv: the bat priv with all the soft interface information
1077 static bool batadv_bla_process_claim(struct batadv_priv *bat_priv,
1145 bla_dst_own = &bat_priv->bla.claim_dest;
1164 ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst,
1167 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1176 batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
1181 if (batadv_handle_claim(bat_priv, primary_if, hw_src,
1186 if (batadv_handle_unclaim(bat_priv, primary_if,
1192 if (batadv_handle_announce(bat_priv, hw_src, ethhdr->h_source,
1197 if (batadv_handle_request(bat_priv, primary_if, hw_src, ethhdr,
1203 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1213 * @bat_priv: the bat priv with all the soft interface information
1219 static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now)
1228 hash = bat_priv->bla.backbone_hash;
1245 batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
1252 atomic_dec(&bat_priv->bla.num_requests);
1265 * @bat_priv: the bat priv with all the soft interface information
1272 static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
1282 hash = bat_priv->bla.claim_hash;
1303 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1307 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1311 batadv_handle_unclaim(bat_priv, primary_if,
1324 * @bat_priv: the bat priv with all the soft interface information
1328 void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
1340 bat_priv->bla.claim_dest.group = group;
1343 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1347 batadv_bla_purge_claims(bat_priv, NULL, 1);
1348 batadv_bla_purge_backbone_gw(bat_priv, 1);
1352 hash = bat_priv->bla.backbone_hash;
1371 batadv_bla_send_announce(bat_priv, backbone_gw);
1379 * @bat_priv: the bat priv with all the soft interface information
1388 batadv_bla_send_loopdetect(struct batadv_priv *bat_priv,
1391 batadv_dbg(BATADV_DBG_BLA, bat_priv, "Send loopdetect frame for vid %d\n",
1393 batadv_bla_send_claim(bat_priv, bat_priv->bla.loopdetect_addr,
1403 struct batadv_priv *bat_priv = netdev_priv(net_dev);
1406 primary_if = batadv_primary_if_get_selected(bat_priv);
1413 batadv_bla_update_orig_address(bat_priv, primary_if, primary_if);
1428 struct batadv_priv *bat_priv;
1439 bat_priv = container_of(priv_bla, struct batadv_priv, bla);
1440 primary_if = batadv_primary_if_get_selected(bat_priv);
1444 batadv_bla_purge_claims(bat_priv, primary_if, 0);
1445 batadv_bla_purge_backbone_gw(bat_priv, 0);
1447 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1450 if (atomic_dec_and_test(&bat_priv->bla.loopdetect_next)) {
1455 eth_random_addr(bat_priv->bla.loopdetect_addr);
1456 bat_priv->bla.loopdetect_addr[0] = 0xba;
1457 bat_priv->bla.loopdetect_addr[1] = 0xbe;
1458 bat_priv->bla.loopdetect_lasttime = jiffies;
1459 atomic_set(&bat_priv->bla.loopdetect_next,
1466 hash = bat_priv->bla.backbone_hash;
1481 batadv_bla_send_announce(bat_priv, backbone_gw);
1483 batadv_bla_send_loopdetect(bat_priv,
1501 atomic_dec(&backbone_gw->bat_priv->bla.num_requests);
1509 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
1523 * @bat_priv: the bat priv with all the soft interface information
1527 int batadv_bla_init(struct batadv_priv *bat_priv)
1535 spin_lock_init(&bat_priv->bla.bcast_duplist_lock);
1537 batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n");
1540 memcpy(&bat_priv->bla.claim_dest.magic, claim_dest, 3);
1541 bat_priv->bla.claim_dest.type = 0;
1542 primary_if = batadv_primary_if_get_selected(bat_priv);
1545 bat_priv->bla.claim_dest.group = htons(crc);
1548 bat_priv->bla.claim_dest.group = 0; /* will be set later */
1554 bat_priv->bla.bcast_duplist[i].entrytime = entrytime;
1555 bat_priv->bla.bcast_duplist_curr = 0;
1557 atomic_set(&bat_priv->bla.loopdetect_next,
1560 if (bat_priv->bla.claim_hash)
1563 bat_priv->bla.claim_hash = batadv_hash_new(128);
1564 if (!bat_priv->bla.claim_hash)
1567 bat_priv->bla.backbone_hash = batadv_hash_new(32);
1568 if (!bat_priv->bla.backbone_hash) {
1569 batadv_hash_destroy(bat_priv->bla.claim_hash);
1573 batadv_hash_set_lock_class(bat_priv->bla.claim_hash,
1575 batadv_hash_set_lock_class(bat_priv->bla.backbone_hash,
1578 batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n");
1580 INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
1582 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
1589 * @bat_priv: the bat priv with all the soft interface information
1606 static bool batadv_bla_check_duplist(struct batadv_priv *bat_priv,
1618 spin_lock_bh(&bat_priv->bla.bcast_duplist_lock);
1621 curr = (bat_priv->bla.bcast_duplist_curr + i);
1623 entry = &bat_priv->bla.bcast_duplist[curr];
1660 curr = (bat_priv->bla.bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1);
1662 entry = &bat_priv->bla.bcast_duplist[curr];
1673 bat_priv->bla.bcast_duplist_curr = curr;
1676 spin_unlock_bh(&bat_priv->bla.bcast_duplist_lock);
1683 * @bat_priv: the bat priv with all the soft interface information
1693 static bool batadv_bla_check_ucast_duplist(struct batadv_priv *bat_priv,
1696 return batadv_bla_check_duplist(bat_priv, skb, (u8 *)skb->data, NULL);
1701 * @bat_priv: the bat priv with all the soft interface information
1710 bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
1719 return batadv_bla_check_duplist(bat_priv, skb, payload_ptr,
1726 * @bat_priv: the bat priv with all the soft interface information
1732 bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
1735 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
1740 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1778 if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance))
1788 backbone_gw = batadv_backbone_hash_find(orig_node->bat_priv,
1799 * @bat_priv: the bat priv with all the soft interface information
1803 void batadv_bla_free(struct batadv_priv *bat_priv)
1807 cancel_delayed_work_sync(&bat_priv->bla.work);
1808 primary_if = batadv_primary_if_get_selected(bat_priv);
1810 if (bat_priv->bla.claim_hash) {
1811 batadv_bla_purge_claims(bat_priv, primary_if, 1);
1812 batadv_hash_destroy(bat_priv->bla.claim_hash);
1813 bat_priv->bla.claim_hash = NULL;
1815 if (bat_priv->bla.backbone_hash) {
1816 batadv_bla_purge_backbone_gw(bat_priv, 1);
1817 batadv_hash_destroy(bat_priv->bla.backbone_hash);
1818 bat_priv->bla.backbone_hash = NULL;
1825 * @bat_priv: the bat priv with all the soft interface information
1837 batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,
1851 bat_priv->bla.loopdetect_addr))
1857 if (batadv_has_timed_out(bat_priv->bla.loopdetect_lasttime,
1861 backbone_gw = batadv_bla_get_backbone_gw(bat_priv,
1880 * @bat_priv: the bat priv with all the soft interface information
1894 bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
1906 primary_if = batadv_primary_if_get_selected(bat_priv);
1910 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1913 if (batadv_bla_loopdetect_check(bat_priv, skb, primary_if, vid))
1916 if (unlikely(atomic_read(&bat_priv->bla.num_requests)))
1941 batadv_bla_check_ucast_duplist(bat_priv, skb))
1946 claim = batadv_claim_hash_find(bat_priv, &search_claim);
1953 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1956 batadv_is_my_client(bat_priv,
1959 batadv_handle_claim(bat_priv, primary_if,
1992 batadv_handle_claim(bat_priv, primary_if,
1998 batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
2014 * @bat_priv: the bat priv with all the soft interface information
2029 bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
2039 primary_if = batadv_primary_if_get_selected(bat_priv);
2043 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
2046 if (batadv_bla_process_claim(bat_priv, primary_if, skb))
2051 if (unlikely(atomic_read(&bat_priv->bla.num_requests)))
2059 claim = batadv_claim_hash_find(bat_priv, &search_claim);
2080 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): Roaming client %pM detected. Unclaim it.\n",
2082 batadv_handle_unclaim(bat_priv, primary_if,
2087 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): Race for claim %pM detected. Drop packet.\n",
2106 batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
2239 struct batadv_priv *bat_priv;
2256 bat_priv = netdev_priv(soft_iface);
2257 hash = bat_priv->bla.claim_hash;
2259 primary_if = batadv_primary_if_get_selected(bat_priv);
2409 struct batadv_priv *bat_priv;
2426 bat_priv = netdev_priv(soft_iface);
2427 hash = bat_priv->bla.backbone_hash;
2429 primary_if = batadv_primary_if_get_selected(bat_priv);
2459 * @bat_priv: the bat priv with all the soft interface information
2468 bool batadv_bla_check_claim(struct batadv_priv *bat_priv,
2476 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
2479 primary_if = batadv_primary_if_get_selected(bat_priv);
2487 claim = batadv_claim_hash_find(bat_priv, &search_claim);