Lines Matching refs:bat_priv
57 batadv_bla_send_announce(struct batadv_priv *bat_priv,
213 * @bat_priv: the bat priv with all the soft interface information
219 batadv_claim_hash_find(struct batadv_priv *bat_priv,
222 struct batadv_hashtable *hash = bat_priv->bla.claim_hash;
252 * @bat_priv: the bat priv with all the soft interface information
259 batadv_backbone_hash_find(struct batadv_priv *bat_priv, u8 *addr,
262 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
308 hash = backbone_gw->bat_priv->bla.claim_hash;
336 * @bat_priv: the bat priv with all the soft interface information
341 static void batadv_bla_send_claim(struct batadv_priv *bat_priv, u8 *mac,
352 primary_if = batadv_primary_if_get_selected(bat_priv);
356 memcpy(&local_claim_dest, &bat_priv->bla.claim_dest,
391 batadv_dbg(BATADV_DBG_BLA, bat_priv,
400 batadv_dbg(BATADV_DBG_BLA, bat_priv,
409 batadv_dbg(BATADV_DBG_BLA, bat_priv,
420 batadv_dbg(BATADV_DBG_BLA, bat_priv,
427 batadv_dbg(BATADV_DBG_BLA, bat_priv,
444 batadv_inc_counter(bat_priv, BATADV_CNT_RX);
445 batadv_add_counter(bat_priv, BATADV_CNT_RX_BYTES,
467 struct batadv_priv *bat_priv;
472 bat_priv = backbone_gw->bat_priv;
474 batadv_info(bat_priv->soft_iface,
481 batadv_throw_uevent(bat_priv, BATADV_UEV_BLA, BATADV_UEV_LOOPDETECT,
489 * @bat_priv: the bat priv with all the soft interface information
497 batadv_bla_get_backbone_gw(struct batadv_priv *bat_priv, u8 *orig,
504 entry = batadv_backbone_hash_find(bat_priv, orig, vid);
509 batadv_dbg(BATADV_DBG_BLA, bat_priv,
520 entry->bat_priv = bat_priv;
529 hash_added = batadv_hash_add(bat_priv->bla.backbone_hash,
541 orig_node = batadv_orig_hash_find(bat_priv, orig);
543 batadv_tt_global_del_orig(bat_priv, orig_node, vid,
549 batadv_bla_send_announce(bat_priv, entry);
554 atomic_inc(&bat_priv->bla.num_requests);
562 * @bat_priv: the bat priv with all the soft interface information
570 batadv_bla_update_own_backbone_gw(struct batadv_priv *bat_priv,
576 backbone_gw = batadv_bla_get_backbone_gw(bat_priv,
588 * @bat_priv: the bat priv with all the soft interface information
595 static void batadv_bla_answer_request(struct batadv_priv *bat_priv,
605 batadv_dbg(BATADV_DBG_BLA, bat_priv,
609 backbone_gw = batadv_backbone_hash_find(bat_priv,
615 hash = bat_priv->bla.claim_hash;
625 batadv_bla_send_claim(bat_priv, claim->addr, claim->vid,
632 batadv_bla_send_announce(bat_priv, backbone_gw);
649 batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
653 batadv_bla_send_claim(backbone_gw->bat_priv, backbone_gw->orig,
658 atomic_inc(&backbone_gw->bat_priv->bla.num_requests);
665 * @bat_priv: the bat priv with all the soft interface information
668 static void batadv_bla_send_announce(struct batadv_priv *bat_priv,
680 batadv_bla_send_claim(bat_priv, mac, backbone_gw->vid,
686 * @bat_priv: the bat priv with all the soft interface information
691 static void batadv_bla_add_claim(struct batadv_priv *bat_priv,
703 claim = batadv_claim_hash_find(bat_priv, &search_claim);
719 batadv_dbg(BATADV_DBG_BLA, bat_priv,
724 hash_added = batadv_hash_add(bat_priv->bla.claim_hash,
740 batadv_dbg(BATADV_DBG_BLA, bat_priv,
796 * @bat_priv: the bat priv with all the soft interface information
800 static void batadv_bla_del_claim(struct batadv_priv *bat_priv,
809 claim = batadv_claim_hash_find(bat_priv, &search_claim);
813 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): %pM, vid %d\n", __func__,
816 claim_removed_node = batadv_hash_remove(bat_priv->bla.claim_hash,
834 * @bat_priv: the bat priv with all the soft interface information
841 static bool batadv_handle_announce(struct batadv_priv *bat_priv, u8 *an_addr,
850 backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid,
860 batadv_dbg(BATADV_DBG_BLA, bat_priv,
869 batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
881 atomic_dec(&backbone_gw->bat_priv->bla.num_requests);
892 * @bat_priv: the bat priv with all the soft interface information
900 static bool batadv_handle_request(struct batadv_priv *bat_priv,
915 batadv_dbg(BATADV_DBG_BLA, bat_priv,
919 batadv_bla_answer_request(bat_priv, primary_if, vid);
925 * @bat_priv: the bat priv with all the soft interface information
933 static bool batadv_handle_unclaim(struct batadv_priv *bat_priv,
943 batadv_bla_send_claim(bat_priv, claim_addr, vid,
946 backbone_gw = batadv_backbone_hash_find(bat_priv, backbone_addr, vid);
952 batadv_dbg(BATADV_DBG_BLA, bat_priv,
956 batadv_bla_del_claim(bat_priv, claim_addr, vid);
963 * @bat_priv: the bat priv with all the soft interface information
971 static bool batadv_handle_claim(struct batadv_priv *bat_priv,
980 backbone_gw = batadv_bla_get_backbone_gw(bat_priv, backbone_addr, vid,
987 batadv_bla_add_claim(bat_priv, claim_addr, vid, backbone_gw);
989 batadv_bla_send_claim(bat_priv, claim_addr, vid,
1000 * @bat_priv: the bat priv with all the soft interface information
1015 static int batadv_check_claim_group(struct batadv_priv *bat_priv,
1025 bla_dst_own = &bat_priv->bla.claim_dest;
1052 orig_node = batadv_orig_hash_find(bat_priv, backbone_addr);
1062 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1075 * @bat_priv: the bat priv with all the soft interface information
1082 static bool batadv_bla_process_claim(struct batadv_priv *bat_priv,
1150 bla_dst_own = &bat_priv->bla.claim_dest;
1169 ret = batadv_check_claim_group(bat_priv, primary_if, hw_src, hw_dst,
1172 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1181 batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
1186 if (batadv_handle_claim(bat_priv, primary_if, hw_src,
1191 if (batadv_handle_unclaim(bat_priv, primary_if,
1197 if (batadv_handle_announce(bat_priv, hw_src, ethhdr->h_source,
1202 if (batadv_handle_request(bat_priv, primary_if, hw_src, ethhdr,
1208 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1218 * @bat_priv: the bat priv with all the soft interface information
1224 static void batadv_bla_purge_backbone_gw(struct batadv_priv *bat_priv, int now)
1233 hash = bat_priv->bla.backbone_hash;
1250 batadv_dbg(BATADV_DBG_BLA, backbone_gw->bat_priv,
1257 atomic_dec(&bat_priv->bla.num_requests);
1270 * @bat_priv: the bat priv with all the soft interface information
1277 static void batadv_bla_purge_claims(struct batadv_priv *bat_priv,
1287 hash = bat_priv->bla.claim_hash;
1308 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1312 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1316 batadv_handle_unclaim(bat_priv, primary_if,
1329 * @bat_priv: the bat priv with all the soft interface information
1333 void batadv_bla_update_orig_address(struct batadv_priv *bat_priv,
1345 bat_priv->bla.claim_dest.group = group;
1348 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1352 batadv_bla_purge_claims(bat_priv, NULL, 1);
1353 batadv_bla_purge_backbone_gw(bat_priv, 1);
1357 hash = bat_priv->bla.backbone_hash;
1376 batadv_bla_send_announce(bat_priv, backbone_gw);
1384 * @bat_priv: the bat priv with all the soft interface information
1393 batadv_bla_send_loopdetect(struct batadv_priv *bat_priv,
1396 batadv_dbg(BATADV_DBG_BLA, bat_priv, "Send loopdetect frame for vid %d\n",
1398 batadv_bla_send_claim(bat_priv, bat_priv->bla.loopdetect_addr,
1408 struct batadv_priv *bat_priv = netdev_priv(net_dev);
1411 primary_if = batadv_primary_if_get_selected(bat_priv);
1418 batadv_bla_update_orig_address(bat_priv, primary_if, primary_if);
1433 struct batadv_priv *bat_priv;
1444 bat_priv = container_of(priv_bla, struct batadv_priv, bla);
1445 primary_if = batadv_primary_if_get_selected(bat_priv);
1449 batadv_bla_purge_claims(bat_priv, primary_if, 0);
1450 batadv_bla_purge_backbone_gw(bat_priv, 0);
1452 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1455 if (atomic_dec_and_test(&bat_priv->bla.loopdetect_next)) {
1460 eth_random_addr(bat_priv->bla.loopdetect_addr);
1461 bat_priv->bla.loopdetect_addr[0] = 0xba;
1462 bat_priv->bla.loopdetect_addr[1] = 0xbe;
1463 bat_priv->bla.loopdetect_lasttime = jiffies;
1464 atomic_set(&bat_priv->bla.loopdetect_next,
1471 hash = bat_priv->bla.backbone_hash;
1486 batadv_bla_send_announce(bat_priv, backbone_gw);
1488 batadv_bla_send_loopdetect(bat_priv,
1506 atomic_dec(&backbone_gw->bat_priv->bla.num_requests);
1515 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
1529 * @bat_priv: the bat priv with all the soft interface information
1533 int batadv_bla_init(struct batadv_priv *bat_priv)
1541 spin_lock_init(&bat_priv->bla.bcast_duplist_lock);
1543 batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hash registering\n");
1546 memcpy(&bat_priv->bla.claim_dest.magic, claim_dest, 3);
1547 bat_priv->bla.claim_dest.type = 0;
1548 primary_if = batadv_primary_if_get_selected(bat_priv);
1551 bat_priv->bla.claim_dest.group = htons(crc);
1554 bat_priv->bla.claim_dest.group = 0; /* will be set later */
1560 bat_priv->bla.bcast_duplist[i].entrytime = entrytime;
1561 bat_priv->bla.bcast_duplist_curr = 0;
1563 atomic_set(&bat_priv->bla.loopdetect_next,
1566 if (bat_priv->bla.claim_hash)
1569 bat_priv->bla.claim_hash = batadv_hash_new(128);
1570 if (!bat_priv->bla.claim_hash)
1573 bat_priv->bla.backbone_hash = batadv_hash_new(32);
1574 if (!bat_priv->bla.backbone_hash) {
1575 batadv_hash_destroy(bat_priv->bla.claim_hash);
1579 batadv_hash_set_lock_class(bat_priv->bla.claim_hash,
1581 batadv_hash_set_lock_class(bat_priv->bla.backbone_hash,
1584 batadv_dbg(BATADV_DBG_BLA, bat_priv, "bla hashes initialized\n");
1586 INIT_DELAYED_WORK(&bat_priv->bla.work, batadv_bla_periodic_work);
1588 queue_delayed_work(batadv_event_workqueue, &bat_priv->bla.work,
1595 * @bat_priv: the bat priv with all the soft interface information
1612 static bool batadv_bla_check_duplist(struct batadv_priv *bat_priv,
1624 spin_lock_bh(&bat_priv->bla.bcast_duplist_lock);
1627 curr = (bat_priv->bla.bcast_duplist_curr + i);
1629 entry = &bat_priv->bla.bcast_duplist[curr];
1666 curr = (bat_priv->bla.bcast_duplist_curr + BATADV_DUPLIST_SIZE - 1);
1668 entry = &bat_priv->bla.bcast_duplist[curr];
1679 bat_priv->bla.bcast_duplist_curr = curr;
1682 spin_unlock_bh(&bat_priv->bla.bcast_duplist_lock);
1689 * @bat_priv: the bat priv with all the soft interface information
1699 static bool batadv_bla_check_ucast_duplist(struct batadv_priv *bat_priv,
1702 return batadv_bla_check_duplist(bat_priv, skb, (u8 *)skb->data, NULL);
1707 * @bat_priv: the bat priv with all the soft interface information
1716 bool batadv_bla_check_bcast_duplist(struct batadv_priv *bat_priv,
1725 return batadv_bla_check_duplist(bat_priv, skb, payload_ptr,
1732 * @bat_priv: the bat priv with all the soft interface information
1738 bool batadv_bla_is_backbone_gw_orig(struct batadv_priv *bat_priv, u8 *orig,
1741 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
1746 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1784 if (!atomic_read(&orig_node->bat_priv->bridge_loop_avoidance))
1794 backbone_gw = batadv_backbone_hash_find(orig_node->bat_priv,
1805 * @bat_priv: the bat priv with all the soft interface information
1809 void batadv_bla_free(struct batadv_priv *bat_priv)
1813 cancel_delayed_work_sync(&bat_priv->bla.work);
1814 primary_if = batadv_primary_if_get_selected(bat_priv);
1816 if (bat_priv->bla.claim_hash) {
1817 batadv_bla_purge_claims(bat_priv, primary_if, 1);
1818 batadv_hash_destroy(bat_priv->bla.claim_hash);
1819 bat_priv->bla.claim_hash = NULL;
1821 if (bat_priv->bla.backbone_hash) {
1822 batadv_bla_purge_backbone_gw(bat_priv, 1);
1823 batadv_hash_destroy(bat_priv->bla.backbone_hash);
1824 bat_priv->bla.backbone_hash = NULL;
1832 * @bat_priv: the bat priv with all the soft interface information
1844 batadv_bla_loopdetect_check(struct batadv_priv *bat_priv, struct sk_buff *skb,
1858 bat_priv->bla.loopdetect_addr))
1864 if (batadv_has_timed_out(bat_priv->bla.loopdetect_lasttime,
1868 backbone_gw = batadv_bla_get_backbone_gw(bat_priv,
1887 * @bat_priv: the bat priv with all the soft interface information
1901 bool batadv_bla_rx(struct batadv_priv *bat_priv, struct sk_buff *skb,
1913 primary_if = batadv_primary_if_get_selected(bat_priv);
1917 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
1920 if (batadv_bla_loopdetect_check(bat_priv, skb, primary_if, vid))
1923 if (unlikely(atomic_read(&bat_priv->bla.num_requests)))
1948 batadv_bla_check_ucast_duplist(bat_priv, skb))
1953 claim = batadv_claim_hash_find(bat_priv, &search_claim);
1960 batadv_dbg(BATADV_DBG_BLA, bat_priv,
1963 batadv_is_my_client(bat_priv,
1966 batadv_handle_claim(bat_priv, primary_if,
1999 batadv_handle_claim(bat_priv, primary_if,
2005 batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
2023 * @bat_priv: the bat priv with all the soft interface information
2038 bool batadv_bla_tx(struct batadv_priv *bat_priv, struct sk_buff *skb,
2048 primary_if = batadv_primary_if_get_selected(bat_priv);
2052 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
2055 if (batadv_bla_process_claim(bat_priv, primary_if, skb))
2060 if (unlikely(atomic_read(&bat_priv->bla.num_requests)))
2068 claim = batadv_claim_hash_find(bat_priv, &search_claim);
2089 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): Roaming client %pM detected. Unclaim it.\n",
2091 batadv_handle_unclaim(bat_priv, primary_if,
2096 batadv_dbg(BATADV_DBG_BLA, bat_priv, "%s(): Race for claim %pM detected. Drop packet.\n",
2115 batadv_bla_update_own_backbone_gw(bat_priv, primary_if, vid);
2139 struct batadv_priv *bat_priv = netdev_priv(net_dev);
2140 struct batadv_hashtable *hash = bat_priv->bla.claim_hash;
2158 ntohs(bat_priv->bla.claim_dest.group));
2313 struct batadv_priv *bat_priv;
2330 bat_priv = netdev_priv(soft_iface);
2331 hash = bat_priv->bla.claim_hash;
2333 primary_if = batadv_primary_if_get_selected(bat_priv);
2373 struct batadv_priv *bat_priv = netdev_priv(net_dev);
2374 struct batadv_hashtable *hash = bat_priv->bla.backbone_hash;
2392 ntohs(bat_priv->bla.claim_dest.group));
2551 struct batadv_priv *bat_priv;
2568 bat_priv = netdev_priv(soft_iface);
2569 hash = bat_priv->bla.backbone_hash;
2571 primary_if = batadv_primary_if_get_selected(bat_priv);
2603 * @bat_priv: the bat priv with all the soft interface information
2612 bool batadv_bla_check_claim(struct batadv_priv *bat_priv,
2620 if (!atomic_read(&bat_priv->bridge_loop_avoidance))
2623 primary_if = batadv_primary_if_get_selected(bat_priv);
2631 claim = batadv_claim_hash_find(bat_priv, &search_claim);