Lines Matching +full:interface +full:- +full:node
1 // SPDX-License-Identifier: GPL-2.0
34 #include "distributed-arp-table.h"
37 #include "hard-interface.h"
42 #include "network-coding.h"
44 #include "soft-interface.h"
45 #include "translation-table.h"
51 * batadv_orig_hash_find() - Find and return originator from orig_hash
52 * @bat_priv: the bat priv with all the soft interface information
60 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_orig_hash_find()
68 index = batadv_choose_orig(data, hash->size); in batadv_orig_hash_find()
69 head = &hash->table[index]; in batadv_orig_hash_find()
76 if (!kref_get_unless_zero(&orig_node->refcount)) in batadv_orig_hash_find()
90 * batadv_compare_orig() - comparing function used in the originator hash table
91 * @node: node in the local table
92 * @data2: second object to compare the node to
96 bool batadv_compare_orig(const struct hlist_node *node, const void *data2) in batadv_compare_orig() argument
98 const void *data1 = container_of(node, struct batadv_orig_node, in batadv_compare_orig()
105 * batadv_orig_node_vlan_get() - get an orig_node_vlan object
119 hlist_for_each_entry_rcu(tmp, &orig_node->vlan_list, list) { in batadv_orig_node_vlan_get()
120 if (tmp->vid != vid) in batadv_orig_node_vlan_get()
123 if (!kref_get_unless_zero(&tmp->refcount)) in batadv_orig_node_vlan_get()
136 * batadv_vlan_id_valid() - check if vlan id is in valid batman-adv encoding
159 * batadv_orig_node_vlan_new() - search and possibly create an orig_node_vlan
179 spin_lock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_vlan_new()
190 kref_init(&vlan->refcount); in batadv_orig_node_vlan_new()
191 vlan->vid = vid; in batadv_orig_node_vlan_new()
193 kref_get(&vlan->refcount); in batadv_orig_node_vlan_new()
194 hlist_add_head_rcu(&vlan->list, &orig_node->vlan_list); in batadv_orig_node_vlan_new()
197 spin_unlock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_vlan_new()
203 * batadv_orig_node_vlan_release() - release originator-vlan object from lists
205 * @ref: kref pointer of the originator-vlan object
217 * batadv_originator_init() - Initialize all originator structures
218 * @bat_priv: the bat priv with all the soft interface information
224 if (bat_priv->orig_hash) in batadv_originator_init()
227 bat_priv->orig_hash = batadv_hash_new(1024); in batadv_originator_init()
229 if (!bat_priv->orig_hash) in batadv_originator_init()
232 batadv_hash_set_lock_class(bat_priv->orig_hash, in batadv_originator_init()
235 INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig); in batadv_originator_init()
237 &bat_priv->orig_work, in batadv_originator_init()
243 return -ENOMEM; in batadv_originator_init()
247 * batadv_neigh_ifinfo_release() - release neigh_ifinfo from lists and queue for
257 if (neigh_ifinfo->if_outgoing != BATADV_IF_DEFAULT) in batadv_neigh_ifinfo_release()
258 batadv_hardif_put(neigh_ifinfo->if_outgoing); in batadv_neigh_ifinfo_release()
264 * batadv_hardif_neigh_release() - release hardif neigh node from lists and
275 spin_lock_bh(&hardif_neigh->if_incoming->neigh_list_lock); in batadv_hardif_neigh_release()
276 hlist_del_init_rcu(&hardif_neigh->list); in batadv_hardif_neigh_release()
277 spin_unlock_bh(&hardif_neigh->if_incoming->neigh_list_lock); in batadv_hardif_neigh_release()
279 batadv_hardif_put(hardif_neigh->if_incoming); in batadv_hardif_neigh_release()
284 * batadv_neigh_node_release() - release neigh_node from lists and queue for
297 &neigh_node->ifinfo_list, list) { in batadv_neigh_node_release()
301 batadv_hardif_neigh_put(neigh_node->hardif_neigh); in batadv_neigh_node_release()
303 batadv_hardif_put(neigh_node->if_incoming); in batadv_neigh_node_release()
309 * batadv_orig_router_get() - router to the originator depending on iface
310 * @orig_node: the orig node for the router
311 * @if_outgoing: the interface where the payload packet has been received or
326 hlist_for_each_entry_rcu(orig_ifinfo, &orig_node->ifinfo_list, list) { in batadv_orig_router_get()
327 if (orig_ifinfo->if_outgoing != if_outgoing) in batadv_orig_router_get()
330 router = rcu_dereference(orig_ifinfo->router); in batadv_orig_router_get()
334 if (router && !kref_get_unless_zero(&router->refcount)) in batadv_orig_router_get()
342 * batadv_orig_ifinfo_get() - find the ifinfo from an orig_node
343 * @orig_node: the orig node to be queried
344 * @if_outgoing: the interface for which the ifinfo should be acquired
357 hlist_for_each_entry_rcu(tmp, &orig_node->ifinfo_list, in batadv_orig_ifinfo_get()
359 if (tmp->if_outgoing != if_outgoing) in batadv_orig_ifinfo_get()
362 if (!kref_get_unless_zero(&tmp->refcount)) in batadv_orig_ifinfo_get()
374 * batadv_orig_ifinfo_new() - search and possibly create an orig_ifinfo object
375 * @orig_node: the orig node to be queried
376 * @if_outgoing: the interface for which the ifinfo should be acquired
379 * interface otherwise. The object is created and added to the list
391 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_orig_ifinfo_new()
402 kref_get(&if_outgoing->refcount); in batadv_orig_ifinfo_new()
404 reset_time = jiffies - 1; in batadv_orig_ifinfo_new()
405 reset_time -= msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); in batadv_orig_ifinfo_new()
406 orig_ifinfo->batman_seqno_reset = reset_time; in batadv_orig_ifinfo_new()
407 orig_ifinfo->if_outgoing = if_outgoing; in batadv_orig_ifinfo_new()
408 INIT_HLIST_NODE(&orig_ifinfo->list); in batadv_orig_ifinfo_new()
409 kref_init(&orig_ifinfo->refcount); in batadv_orig_ifinfo_new()
411 kref_get(&orig_ifinfo->refcount); in batadv_orig_ifinfo_new()
412 hlist_add_head_rcu(&orig_ifinfo->list, in batadv_orig_ifinfo_new()
413 &orig_node->ifinfo_list); in batadv_orig_ifinfo_new()
415 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_orig_ifinfo_new()
420 * batadv_neigh_ifinfo_get() - find the ifinfo from an neigh_node
421 * @neigh: the neigh node to be queried
422 * @if_outgoing: the interface for which the ifinfo should be acquired
436 hlist_for_each_entry_rcu(tmp_neigh_ifinfo, &neigh->ifinfo_list, in batadv_neigh_ifinfo_get()
438 if (tmp_neigh_ifinfo->if_outgoing != if_outgoing) in batadv_neigh_ifinfo_get()
441 if (!kref_get_unless_zero(&tmp_neigh_ifinfo->refcount)) in batadv_neigh_ifinfo_get()
453 * batadv_neigh_ifinfo_new() - search and possibly create an neigh_ifinfo object
454 * @neigh: the neigh node to be queried
455 * @if_outgoing: the interface for which the ifinfo should be acquired
458 * if_outgoing interface otherwise. The object is created and added to the list
469 spin_lock_bh(&neigh->ifinfo_lock); in batadv_neigh_ifinfo_new()
480 kref_get(&if_outgoing->refcount); in batadv_neigh_ifinfo_new()
482 INIT_HLIST_NODE(&neigh_ifinfo->list); in batadv_neigh_ifinfo_new()
483 kref_init(&neigh_ifinfo->refcount); in batadv_neigh_ifinfo_new()
484 neigh_ifinfo->if_outgoing = if_outgoing; in batadv_neigh_ifinfo_new()
486 kref_get(&neigh_ifinfo->refcount); in batadv_neigh_ifinfo_new()
487 hlist_add_head_rcu(&neigh_ifinfo->list, &neigh->ifinfo_list); in batadv_neigh_ifinfo_new()
490 spin_unlock_bh(&neigh->ifinfo_lock); in batadv_neigh_ifinfo_new()
496 * batadv_neigh_node_get() - retrieve a neighbour from the list
498 * @hard_iface: the interface where this neighbour is connected to
502 * which is connected through the provided hard interface.
514 hlist_for_each_entry_rcu(tmp_neigh_node, &orig_node->neigh_list, list) { in batadv_neigh_node_get()
515 if (!batadv_compare_eth(tmp_neigh_node->addr, addr)) in batadv_neigh_node_get()
518 if (tmp_neigh_node->if_incoming != hard_iface) in batadv_neigh_node_get()
521 if (!kref_get_unless_zero(&tmp_neigh_node->refcount)) in batadv_neigh_node_get()
533 * batadv_hardif_neigh_create() - create a hardif neighbour node
534 * @hard_iface: the interface this neighbour is connected to
535 * @neigh_addr: the interface address of the neighbour to retrieve
538 * Return: the hardif neighbour node if found or created or NULL otherwise.
545 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hardif_neigh_create()
548 spin_lock_bh(&hard_iface->neigh_list_lock); in batadv_hardif_neigh_create()
559 kref_get(&hard_iface->refcount); in batadv_hardif_neigh_create()
560 INIT_HLIST_NODE(&hardif_neigh->list); in batadv_hardif_neigh_create()
561 ether_addr_copy(hardif_neigh->addr, neigh_addr); in batadv_hardif_neigh_create()
562 ether_addr_copy(hardif_neigh->orig, orig_node->orig); in batadv_hardif_neigh_create()
563 hardif_neigh->if_incoming = hard_iface; in batadv_hardif_neigh_create()
564 hardif_neigh->last_seen = jiffies; in batadv_hardif_neigh_create()
566 kref_init(&hardif_neigh->refcount); in batadv_hardif_neigh_create()
568 if (bat_priv->algo_ops->neigh.hardif_init) in batadv_hardif_neigh_create()
569 bat_priv->algo_ops->neigh.hardif_init(hardif_neigh); in batadv_hardif_neigh_create()
571 hlist_add_head_rcu(&hardif_neigh->list, &hard_iface->neigh_list); in batadv_hardif_neigh_create()
574 spin_unlock_bh(&hard_iface->neigh_list_lock); in batadv_hardif_neigh_create()
579 * batadv_hardif_neigh_get_or_create() - retrieve or create a hardif neighbour
580 * node
581 * @hard_iface: the interface this neighbour is connected to
582 * @neigh_addr: the interface address of the neighbour to retrieve
585 * Return: the hardif neighbour node if found or created or NULL otherwise.
603 * batadv_hardif_neigh_get() - retrieve a hardif neighbour from the list
604 * @hard_iface: the interface where this neighbour is connected to
607 * Looks for and possibly returns a neighbour belonging to this hard interface.
619 &hard_iface->neigh_list, list) { in batadv_hardif_neigh_get()
620 if (!batadv_compare_eth(tmp_hardif_neigh->addr, neigh_addr)) in batadv_hardif_neigh_get()
623 if (!kref_get_unless_zero(&tmp_hardif_neigh->refcount)) in batadv_hardif_neigh_get()
635 * batadv_neigh_node_create() - create a neigh node object
637 * @hard_iface: the interface where the neighbour is connected to
638 * @neigh_addr: the mac address of the neighbour interface
642 * Return: the neighbour node if found or created or NULL otherwise.
652 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_neigh_node_create()
667 INIT_HLIST_NODE(&neigh_node->list); in batadv_neigh_node_create()
668 INIT_HLIST_HEAD(&neigh_node->ifinfo_list); in batadv_neigh_node_create()
669 spin_lock_init(&neigh_node->ifinfo_lock); in batadv_neigh_node_create()
671 kref_get(&hard_iface->refcount); in batadv_neigh_node_create()
672 ether_addr_copy(neigh_node->addr, neigh_addr); in batadv_neigh_node_create()
673 neigh_node->if_incoming = hard_iface; in batadv_neigh_node_create()
674 neigh_node->orig_node = orig_node; in batadv_neigh_node_create()
675 neigh_node->last_seen = jiffies; in batadv_neigh_node_create()
678 kref_get(&hardif_neigh->refcount); in batadv_neigh_node_create()
679 neigh_node->hardif_neigh = hardif_neigh; in batadv_neigh_node_create()
682 kref_init(&neigh_node->refcount); in batadv_neigh_node_create()
684 kref_get(&neigh_node->refcount); in batadv_neigh_node_create()
685 hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); in batadv_neigh_node_create()
687 batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv, in batadv_neigh_node_create()
688 "Creating new neighbor %pM for orig_node %pM on interface %s\n", in batadv_neigh_node_create()
689 neigh_addr, orig_node->orig, hard_iface->net_dev->name); in batadv_neigh_node_create()
692 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_neigh_node_create()
699 * batadv_neigh_node_get_or_create() - retrieve or create a neigh node object
701 * @hard_iface: the interface where the neighbour is connected to
702 * @neigh_addr: the mac address of the neighbour interface
704 * Return: the neighbour node if found or created or NULL otherwise.
722 * batadv_hardif_neigh_dump() - Dump to netlink the neighbor infos for a
723 * specific outgoing interface
731 struct net *net = sock_net(cb->skb->sk); in batadv_hardif_neigh_dump()
740 ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); in batadv_hardif_neigh_dump()
742 return -EINVAL; in batadv_hardif_neigh_dump()
746 ret = -ENODEV; in batadv_hardif_neigh_dump()
753 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) { in batadv_hardif_neigh_dump()
754 ret = -ENOENT; in batadv_hardif_neigh_dump()
758 hard_ifindex = batadv_netlink_get_ifindex(cb->nlh, in batadv_hardif_neigh_dump()
766 ret = -ENODEV; in batadv_hardif_neigh_dump()
770 if (hardif->soft_iface != soft_iface) { in batadv_hardif_neigh_dump()
771 ret = -ENOENT; in batadv_hardif_neigh_dump()
776 if (!bat_priv->algo_ops->neigh.dump) { in batadv_hardif_neigh_dump()
777 ret = -EOPNOTSUPP; in batadv_hardif_neigh_dump()
781 bat_priv->algo_ops->neigh.dump(msg, cb, bat_priv, hardif); in batadv_hardif_neigh_dump()
783 ret = msg->len; in batadv_hardif_neigh_dump()
795 * batadv_orig_ifinfo_release() - release orig_ifinfo from lists and queue for
806 if (orig_ifinfo->if_outgoing != BATADV_IF_DEFAULT) in batadv_orig_ifinfo_release()
807 batadv_hardif_put(orig_ifinfo->if_outgoing); in batadv_orig_ifinfo_release()
810 router = rcu_dereference_protected(orig_ifinfo->router, true); in batadv_orig_ifinfo_release()
817 * batadv_orig_node_free_rcu() - free the orig_node
830 kfree(orig_node->tt_buff); in batadv_orig_node_free_rcu()
835 * batadv_orig_node_release() - release orig_node from lists and queue for
850 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_orig_node_release()
854 &orig_node->neigh_list, list) { in batadv_orig_node_release()
855 hlist_del_rcu(&neigh_node->list); in batadv_orig_node_release()
860 &orig_node->ifinfo_list, list) { in batadv_orig_node_release()
861 hlist_del_rcu(&orig_ifinfo->list); in batadv_orig_node_release()
865 last_candidate = orig_node->last_bonding_candidate; in batadv_orig_node_release()
866 orig_node->last_bonding_candidate = NULL; in batadv_orig_node_release()
867 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_orig_node_release()
871 spin_lock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_release()
872 hlist_for_each_entry_safe(vlan, node_tmp, &orig_node->vlan_list, list) { in batadv_orig_node_release()
873 hlist_del_rcu(&vlan->list); in batadv_orig_node_release()
876 spin_unlock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_release()
879 batadv_nc_purge_orig(orig_node->bat_priv, orig_node, NULL); in batadv_orig_node_release()
881 call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu); in batadv_orig_node_release()
885 * batadv_originator_free() - Free all originator structures
886 * @bat_priv: the bat priv with all the soft interface information
890 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_originator_free()
900 cancel_delayed_work_sync(&bat_priv->orig_work); in batadv_originator_free()
902 bat_priv->orig_hash = NULL; in batadv_originator_free()
904 for (i = 0; i < hash->size; i++) { in batadv_originator_free()
905 head = &hash->table[i]; in batadv_originator_free()
906 list_lock = &hash->list_locks[i]; in batadv_originator_free()
911 hlist_del_rcu(&orig_node->hash_entry); in batadv_originator_free()
921 * batadv_orig_node_new() - creates a new orig_node
922 * @bat_priv: the bat priv with all the soft interface information
945 INIT_HLIST_HEAD(&orig_node->neigh_list); in batadv_orig_node_new()
946 INIT_HLIST_HEAD(&orig_node->vlan_list); in batadv_orig_node_new()
947 INIT_HLIST_HEAD(&orig_node->ifinfo_list); in batadv_orig_node_new()
948 spin_lock_init(&orig_node->bcast_seqno_lock); in batadv_orig_node_new()
949 spin_lock_init(&orig_node->neigh_list_lock); in batadv_orig_node_new()
950 spin_lock_init(&orig_node->tt_buff_lock); in batadv_orig_node_new()
951 spin_lock_init(&orig_node->tt_lock); in batadv_orig_node_new()
952 spin_lock_init(&orig_node->vlan_list_lock); in batadv_orig_node_new()
957 kref_init(&orig_node->refcount); in batadv_orig_node_new()
959 orig_node->bat_priv = bat_priv; in batadv_orig_node_new()
960 ether_addr_copy(orig_node->orig, addr); in batadv_orig_node_new()
962 atomic_set(&orig_node->last_ttvn, 0); in batadv_orig_node_new()
963 orig_node->tt_buff = NULL; in batadv_orig_node_new()
964 orig_node->tt_buff_len = 0; in batadv_orig_node_new()
965 orig_node->last_seen = jiffies; in batadv_orig_node_new()
966 reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); in batadv_orig_node_new()
967 orig_node->bcast_seqno_reset = reset_time; in batadv_orig_node_new()
970 orig_node->mcast_flags = BATADV_MCAST_WANT_NO_RTR4; in batadv_orig_node_new()
971 orig_node->mcast_flags |= BATADV_MCAST_WANT_NO_RTR6; in batadv_orig_node_new()
972 INIT_HLIST_NODE(&orig_node->mcast_want_all_unsnoopables_node); in batadv_orig_node_new()
973 INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv4_node); in batadv_orig_node_new()
974 INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv6_node); in batadv_orig_node_new()
975 spin_lock_init(&orig_node->mcast_handler_lock); in batadv_orig_node_new()
989 INIT_HLIST_HEAD(&orig_node->fragments[i].fragment_list); in batadv_orig_node_new()
990 spin_lock_init(&orig_node->fragments[i].lock); in batadv_orig_node_new()
991 orig_node->fragments[i].size = 0; in batadv_orig_node_new()
1001 * batadv_purge_neigh_ifinfo() - purge obsolete ifinfo entries from neighbor
1002 * @bat_priv: the bat priv with all the soft interface information
1003 * @neigh: orig node which is to be checked
1013 spin_lock_bh(&neigh->ifinfo_lock); in batadv_purge_neigh_ifinfo()
1017 &neigh->ifinfo_list, list) { in batadv_purge_neigh_ifinfo()
1018 if_outgoing = neigh_ifinfo->if_outgoing; in batadv_purge_neigh_ifinfo()
1020 /* always keep the default interface */ in batadv_purge_neigh_ifinfo()
1024 /* don't purge if the interface is not (going) down */ in batadv_purge_neigh_ifinfo()
1025 if (if_outgoing->if_status != BATADV_IF_INACTIVE && in batadv_purge_neigh_ifinfo()
1026 if_outgoing->if_status != BATADV_IF_NOT_IN_USE && in batadv_purge_neigh_ifinfo()
1027 if_outgoing->if_status != BATADV_IF_TO_BE_REMOVED) in batadv_purge_neigh_ifinfo()
1032 neigh->addr, if_outgoing->net_dev->name); in batadv_purge_neigh_ifinfo()
1034 hlist_del_rcu(&neigh_ifinfo->list); in batadv_purge_neigh_ifinfo()
1038 spin_unlock_bh(&neigh->ifinfo_lock); in batadv_purge_neigh_ifinfo()
1042 * batadv_purge_orig_ifinfo() - purge obsolete ifinfo entries from originator
1043 * @bat_priv: the bat priv with all the soft interface information
1044 * @orig_node: orig node which is to be checked
1057 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_ifinfo()
1061 &orig_node->ifinfo_list, list) { in batadv_purge_orig_ifinfo()
1062 if_outgoing = orig_ifinfo->if_outgoing; in batadv_purge_orig_ifinfo()
1064 /* always keep the default interface */ in batadv_purge_orig_ifinfo()
1068 /* don't purge if the interface is not (going) down */ in batadv_purge_orig_ifinfo()
1069 if (if_outgoing->if_status != BATADV_IF_INACTIVE && in batadv_purge_orig_ifinfo()
1070 if_outgoing->if_status != BATADV_IF_NOT_IN_USE && in batadv_purge_orig_ifinfo()
1071 if_outgoing->if_status != BATADV_IF_TO_BE_REMOVED) in batadv_purge_orig_ifinfo()
1076 orig_node->orig, if_outgoing->net_dev->name); in batadv_purge_orig_ifinfo()
1080 hlist_del_rcu(&orig_ifinfo->list); in batadv_purge_orig_ifinfo()
1082 if (orig_node->last_bonding_candidate == orig_ifinfo) { in batadv_purge_orig_ifinfo()
1083 orig_node->last_bonding_candidate = NULL; in batadv_purge_orig_ifinfo()
1088 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_ifinfo()
1094 * batadv_purge_orig_neighbors() - purges neighbors from originator
1095 * @bat_priv: the bat priv with all the soft interface information
1096 * @orig_node: orig node which is to be checked
1110 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_neighbors()
1114 &orig_node->neigh_list, list) { in batadv_purge_orig_neighbors()
1115 last_seen = neigh_node->last_seen; in batadv_purge_orig_neighbors()
1116 if_incoming = neigh_node->if_incoming; in batadv_purge_orig_neighbors()
1119 if_incoming->if_status == BATADV_IF_INACTIVE || in batadv_purge_orig_neighbors()
1120 if_incoming->if_status == BATADV_IF_NOT_IN_USE || in batadv_purge_orig_neighbors()
1121 if_incoming->if_status == BATADV_IF_TO_BE_REMOVED) { in batadv_purge_orig_neighbors()
1122 if (if_incoming->if_status == BATADV_IF_INACTIVE || in batadv_purge_orig_neighbors()
1123 if_incoming->if_status == BATADV_IF_NOT_IN_USE || in batadv_purge_orig_neighbors()
1124 if_incoming->if_status == BATADV_IF_TO_BE_REMOVED) in batadv_purge_orig_neighbors()
1127 orig_node->orig, neigh_node->addr, in batadv_purge_orig_neighbors()
1128 if_incoming->net_dev->name); in batadv_purge_orig_neighbors()
1132 orig_node->orig, neigh_node->addr, in batadv_purge_orig_neighbors()
1137 hlist_del_rcu(&neigh_node->list); in batadv_purge_orig_neighbors()
1141 * deleted, but some interface has been removed. in batadv_purge_orig_neighbors()
1147 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_neighbors()
1152 * batadv_find_best_neighbor() - finds the best neighbor after purging
1153 * @bat_priv: the bat priv with all the soft interface information
1154 * @orig_node: orig node which is to be checked
1155 * @if_outgoing: the interface for which the metric should be compared
1165 struct batadv_algo_ops *bao = bat_priv->algo_ops; in batadv_find_best_neighbor()
1168 hlist_for_each_entry_rcu(neigh, &orig_node->neigh_list, list) { in batadv_find_best_neighbor()
1169 if (best && (bao->neigh.cmp(neigh, if_outgoing, best, in batadv_find_best_neighbor()
1173 if (!kref_get_unless_zero(&neigh->refcount)) in batadv_find_best_neighbor()
1186 * batadv_purge_orig_node() - purges obsolete information from an orig_node
1187 * @bat_priv: the bat priv with all the soft interface information
1188 * @orig_node: orig node which is to be checked
1202 if (batadv_has_timed_out(orig_node->last_seen, in batadv_purge_orig_node()
1206 orig_node->orig, in batadv_purge_orig_node()
1207 jiffies_to_msecs(orig_node->last_seen)); in batadv_purge_orig_node()
1226 if (hard_iface->if_status != BATADV_IF_ACTIVE) in batadv_purge_orig_node()
1229 if (hard_iface->soft_iface != bat_priv->soft_iface) in batadv_purge_orig_node()
1232 if (!kref_get_unless_zero(&hard_iface->refcount)) in batadv_purge_orig_node()
1250 * batadv_purge_orig_ref() - Purge all outdated originators
1251 * @bat_priv: the bat priv with all the soft interface information
1255 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_purge_orig_ref()
1266 for (i = 0; i < hash->size; i++) { in batadv_purge_orig_ref()
1267 head = &hash->table[i]; in batadv_purge_orig_ref()
1270 list_lock = &hash->list_locks[i]; in batadv_purge_orig_ref()
1277 hlist_del_rcu(&orig_node->hash_entry); in batadv_purge_orig_ref()
1278 batadv_tt_global_del_orig(orig_node->bat_priv, in batadv_purge_orig_ref()
1279 orig_node, -1, in batadv_purge_orig_ref()
1303 &bat_priv->orig_work, in batadv_purge_orig()
1308 * batadv_orig_dump() - Dump to netlink the originator infos for a specific
1309 * outgoing interface
1317 struct net *net = sock_net(cb->skb->sk); in batadv_orig_dump()
1326 ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); in batadv_orig_dump()
1328 return -EINVAL; in batadv_orig_dump()
1332 ret = -ENODEV; in batadv_orig_dump()
1339 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) { in batadv_orig_dump()
1340 ret = -ENOENT; in batadv_orig_dump()
1344 hard_ifindex = batadv_netlink_get_ifindex(cb->nlh, in batadv_orig_dump()
1352 ret = -ENODEV; in batadv_orig_dump()
1356 if (hardif->soft_iface != soft_iface) { in batadv_orig_dump()
1357 ret = -ENOENT; in batadv_orig_dump()
1362 if (!bat_priv->algo_ops->orig.dump) { in batadv_orig_dump()
1363 ret = -EOPNOTSUPP; in batadv_orig_dump()
1367 bat_priv->algo_ops->orig.dump(msg, cb, bat_priv, hardif); in batadv_orig_dump()
1369 ret = msg->len; in batadv_orig_dump()