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_to_router() - get next hop neighbor to an orig address
343 * @bat_priv: the bat priv with all the soft interface information
345 * @if_outgoing: the interface where the payload packet has been received or
348 * Return: A neighbor node which is the best router towards the given originator
369 * batadv_orig_ifinfo_get() - find the ifinfo from an orig_node
370 * @orig_node: the orig node to be queried
371 * @if_outgoing: the interface for which the ifinfo should be acquired
384 hlist_for_each_entry_rcu(tmp, &orig_node->ifinfo_list, in batadv_orig_ifinfo_get()
386 if (tmp->if_outgoing != if_outgoing) in batadv_orig_ifinfo_get()
389 if (!kref_get_unless_zero(&tmp->refcount)) in batadv_orig_ifinfo_get()
401 * batadv_orig_ifinfo_new() - search and possibly create an orig_ifinfo object
402 * @orig_node: the orig node to be queried
403 * @if_outgoing: the interface for which the ifinfo should be acquired
406 * interface otherwise. The object is created and added to the list
418 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_orig_ifinfo_new()
429 kref_get(&if_outgoing->refcount); in batadv_orig_ifinfo_new()
431 reset_time = jiffies - 1; in batadv_orig_ifinfo_new()
432 reset_time -= msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); in batadv_orig_ifinfo_new()
433 orig_ifinfo->batman_seqno_reset = reset_time; in batadv_orig_ifinfo_new()
434 orig_ifinfo->if_outgoing = if_outgoing; in batadv_orig_ifinfo_new()
435 INIT_HLIST_NODE(&orig_ifinfo->list); in batadv_orig_ifinfo_new()
436 kref_init(&orig_ifinfo->refcount); in batadv_orig_ifinfo_new()
438 kref_get(&orig_ifinfo->refcount); in batadv_orig_ifinfo_new()
439 hlist_add_head_rcu(&orig_ifinfo->list, in batadv_orig_ifinfo_new()
440 &orig_node->ifinfo_list); in batadv_orig_ifinfo_new()
442 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_orig_ifinfo_new()
447 * batadv_neigh_ifinfo_get() - find the ifinfo from an neigh_node
448 * @neigh: the neigh node to be queried
449 * @if_outgoing: the interface for which the ifinfo should be acquired
463 hlist_for_each_entry_rcu(tmp_neigh_ifinfo, &neigh->ifinfo_list, in batadv_neigh_ifinfo_get()
465 if (tmp_neigh_ifinfo->if_outgoing != if_outgoing) in batadv_neigh_ifinfo_get()
468 if (!kref_get_unless_zero(&tmp_neigh_ifinfo->refcount)) in batadv_neigh_ifinfo_get()
480 * batadv_neigh_ifinfo_new() - search and possibly create an neigh_ifinfo object
481 * @neigh: the neigh node to be queried
482 * @if_outgoing: the interface for which the ifinfo should be acquired
485 * if_outgoing interface otherwise. The object is created and added to the list
496 spin_lock_bh(&neigh->ifinfo_lock); in batadv_neigh_ifinfo_new()
507 kref_get(&if_outgoing->refcount); in batadv_neigh_ifinfo_new()
509 INIT_HLIST_NODE(&neigh_ifinfo->list); in batadv_neigh_ifinfo_new()
510 kref_init(&neigh_ifinfo->refcount); in batadv_neigh_ifinfo_new()
511 neigh_ifinfo->if_outgoing = if_outgoing; in batadv_neigh_ifinfo_new()
513 kref_get(&neigh_ifinfo->refcount); in batadv_neigh_ifinfo_new()
514 hlist_add_head_rcu(&neigh_ifinfo->list, &neigh->ifinfo_list); in batadv_neigh_ifinfo_new()
517 spin_unlock_bh(&neigh->ifinfo_lock); in batadv_neigh_ifinfo_new()
523 * batadv_neigh_node_get() - retrieve a neighbour from the list
525 * @hard_iface: the interface where this neighbour is connected to
529 * which is connected through the provided hard interface.
541 hlist_for_each_entry_rcu(tmp_neigh_node, &orig_node->neigh_list, list) { in batadv_neigh_node_get()
542 if (!batadv_compare_eth(tmp_neigh_node->addr, addr)) in batadv_neigh_node_get()
545 if (tmp_neigh_node->if_incoming != hard_iface) in batadv_neigh_node_get()
548 if (!kref_get_unless_zero(&tmp_neigh_node->refcount)) in batadv_neigh_node_get()
560 * batadv_hardif_neigh_create() - create a hardif neighbour node
561 * @hard_iface: the interface this neighbour is connected to
562 * @neigh_addr: the interface address of the neighbour to retrieve
565 * Return: the hardif neighbour node if found or created or NULL otherwise.
572 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hardif_neigh_create()
575 spin_lock_bh(&hard_iface->neigh_list_lock); in batadv_hardif_neigh_create()
586 kref_get(&hard_iface->refcount); in batadv_hardif_neigh_create()
587 INIT_HLIST_NODE(&hardif_neigh->list); in batadv_hardif_neigh_create()
588 ether_addr_copy(hardif_neigh->addr, neigh_addr); in batadv_hardif_neigh_create()
589 ether_addr_copy(hardif_neigh->orig, orig_node->orig); in batadv_hardif_neigh_create()
590 hardif_neigh->if_incoming = hard_iface; in batadv_hardif_neigh_create()
591 hardif_neigh->last_seen = jiffies; in batadv_hardif_neigh_create()
593 kref_init(&hardif_neigh->refcount); in batadv_hardif_neigh_create()
595 if (bat_priv->algo_ops->neigh.hardif_init) in batadv_hardif_neigh_create()
596 bat_priv->algo_ops->neigh.hardif_init(hardif_neigh); in batadv_hardif_neigh_create()
598 hlist_add_head_rcu(&hardif_neigh->list, &hard_iface->neigh_list); in batadv_hardif_neigh_create()
601 spin_unlock_bh(&hard_iface->neigh_list_lock); in batadv_hardif_neigh_create()
606 * batadv_hardif_neigh_get_or_create() - retrieve or create a hardif neighbour
607 * node
608 * @hard_iface: the interface this neighbour is connected to
609 * @neigh_addr: the interface address of the neighbour to retrieve
612 * Return: the hardif neighbour node if found or created or NULL otherwise.
630 * batadv_hardif_neigh_get() - retrieve a hardif neighbour from the list
631 * @hard_iface: the interface where this neighbour is connected to
634 * Looks for and possibly returns a neighbour belonging to this hard interface.
646 &hard_iface->neigh_list, list) { in batadv_hardif_neigh_get()
647 if (!batadv_compare_eth(tmp_hardif_neigh->addr, neigh_addr)) in batadv_hardif_neigh_get()
650 if (!kref_get_unless_zero(&tmp_hardif_neigh->refcount)) in batadv_hardif_neigh_get()
662 * batadv_neigh_node_create() - create a neigh node object
664 * @hard_iface: the interface where the neighbour is connected to
665 * @neigh_addr: the mac address of the neighbour interface
669 * Return: the neighbour node if found or created or NULL otherwise.
679 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_neigh_node_create()
694 INIT_HLIST_NODE(&neigh_node->list); in batadv_neigh_node_create()
695 INIT_HLIST_HEAD(&neigh_node->ifinfo_list); in batadv_neigh_node_create()
696 spin_lock_init(&neigh_node->ifinfo_lock); in batadv_neigh_node_create()
698 kref_get(&hard_iface->refcount); in batadv_neigh_node_create()
699 ether_addr_copy(neigh_node->addr, neigh_addr); in batadv_neigh_node_create()
700 neigh_node->if_incoming = hard_iface; in batadv_neigh_node_create()
701 neigh_node->orig_node = orig_node; in batadv_neigh_node_create()
702 neigh_node->last_seen = jiffies; in batadv_neigh_node_create()
705 kref_get(&hardif_neigh->refcount); in batadv_neigh_node_create()
706 neigh_node->hardif_neigh = hardif_neigh; in batadv_neigh_node_create()
709 kref_init(&neigh_node->refcount); in batadv_neigh_node_create()
711 kref_get(&neigh_node->refcount); in batadv_neigh_node_create()
712 hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); in batadv_neigh_node_create()
714 batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv, in batadv_neigh_node_create()
715 "Creating new neighbor %pM for orig_node %pM on interface %s\n", in batadv_neigh_node_create()
716 neigh_addr, orig_node->orig, hard_iface->net_dev->name); in batadv_neigh_node_create()
719 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_neigh_node_create()
726 * batadv_neigh_node_get_or_create() - retrieve or create a neigh node object
728 * @hard_iface: the interface where the neighbour is connected to
729 * @neigh_addr: the mac address of the neighbour interface
731 * Return: the neighbour node if found or created or NULL otherwise.
749 * batadv_hardif_neigh_dump() - Dump to netlink the neighbor infos for a
750 * specific outgoing interface
758 struct net *net = sock_net(cb->skb->sk); in batadv_hardif_neigh_dump()
767 ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); in batadv_hardif_neigh_dump()
769 return -EINVAL; in batadv_hardif_neigh_dump()
773 ret = -ENODEV; in batadv_hardif_neigh_dump()
780 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) { in batadv_hardif_neigh_dump()
781 ret = -ENOENT; in batadv_hardif_neigh_dump()
785 hard_ifindex = batadv_netlink_get_ifindex(cb->nlh, in batadv_hardif_neigh_dump()
793 ret = -ENODEV; in batadv_hardif_neigh_dump()
797 if (hardif->soft_iface != soft_iface) { in batadv_hardif_neigh_dump()
798 ret = -ENOENT; in batadv_hardif_neigh_dump()
803 if (!bat_priv->algo_ops->neigh.dump) { in batadv_hardif_neigh_dump()
804 ret = -EOPNOTSUPP; in batadv_hardif_neigh_dump()
808 bat_priv->algo_ops->neigh.dump(msg, cb, bat_priv, hardif); in batadv_hardif_neigh_dump()
810 ret = msg->len; in batadv_hardif_neigh_dump()
822 * batadv_orig_ifinfo_release() - release orig_ifinfo from lists and queue for
833 if (orig_ifinfo->if_outgoing != BATADV_IF_DEFAULT) in batadv_orig_ifinfo_release()
834 batadv_hardif_put(orig_ifinfo->if_outgoing); in batadv_orig_ifinfo_release()
837 router = rcu_dereference_protected(orig_ifinfo->router, true); in batadv_orig_ifinfo_release()
844 * batadv_orig_node_free_rcu() - free the orig_node
857 kfree(orig_node->tt_buff); in batadv_orig_node_free_rcu()
862 * batadv_orig_node_release() - release orig_node from lists and queue for
877 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_orig_node_release()
881 &orig_node->neigh_list, list) { in batadv_orig_node_release()
882 hlist_del_rcu(&neigh_node->list); in batadv_orig_node_release()
887 &orig_node->ifinfo_list, list) { in batadv_orig_node_release()
888 hlist_del_rcu(&orig_ifinfo->list); in batadv_orig_node_release()
892 last_candidate = orig_node->last_bonding_candidate; in batadv_orig_node_release()
893 orig_node->last_bonding_candidate = NULL; in batadv_orig_node_release()
894 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_orig_node_release()
898 spin_lock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_release()
899 hlist_for_each_entry_safe(vlan, node_tmp, &orig_node->vlan_list, list) { in batadv_orig_node_release()
900 hlist_del_rcu(&vlan->list); in batadv_orig_node_release()
903 spin_unlock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_release()
906 batadv_nc_purge_orig(orig_node->bat_priv, orig_node, NULL); in batadv_orig_node_release()
908 call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu); in batadv_orig_node_release()
912 * batadv_originator_free() - Free all originator structures
913 * @bat_priv: the bat priv with all the soft interface information
917 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_originator_free()
927 cancel_delayed_work_sync(&bat_priv->orig_work); in batadv_originator_free()
929 bat_priv->orig_hash = NULL; in batadv_originator_free()
931 for (i = 0; i < hash->size; i++) { in batadv_originator_free()
932 head = &hash->table[i]; in batadv_originator_free()
933 list_lock = &hash->list_locks[i]; in batadv_originator_free()
938 hlist_del_rcu(&orig_node->hash_entry); in batadv_originator_free()
948 * batadv_orig_node_new() - creates a new orig_node
949 * @bat_priv: the bat priv with all the soft interface information
972 INIT_HLIST_HEAD(&orig_node->neigh_list); in batadv_orig_node_new()
973 INIT_HLIST_HEAD(&orig_node->vlan_list); in batadv_orig_node_new()
974 INIT_HLIST_HEAD(&orig_node->ifinfo_list); in batadv_orig_node_new()
975 spin_lock_init(&orig_node->bcast_seqno_lock); in batadv_orig_node_new()
976 spin_lock_init(&orig_node->neigh_list_lock); in batadv_orig_node_new()
977 spin_lock_init(&orig_node->tt_buff_lock); in batadv_orig_node_new()
978 spin_lock_init(&orig_node->tt_lock); in batadv_orig_node_new()
979 spin_lock_init(&orig_node->vlan_list_lock); in batadv_orig_node_new()
984 kref_init(&orig_node->refcount); in batadv_orig_node_new()
986 orig_node->bat_priv = bat_priv; in batadv_orig_node_new()
987 ether_addr_copy(orig_node->orig, addr); in batadv_orig_node_new()
989 atomic_set(&orig_node->last_ttvn, 0); in batadv_orig_node_new()
990 orig_node->tt_buff = NULL; in batadv_orig_node_new()
991 orig_node->tt_buff_len = 0; in batadv_orig_node_new()
992 orig_node->last_seen = jiffies; in batadv_orig_node_new()
993 reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); in batadv_orig_node_new()
994 orig_node->bcast_seqno_reset = reset_time; in batadv_orig_node_new()
997 orig_node->mcast_flags = BATADV_MCAST_WANT_NO_RTR4; in batadv_orig_node_new()
998 orig_node->mcast_flags |= BATADV_MCAST_WANT_NO_RTR6; in batadv_orig_node_new()
999 orig_node->mcast_flags |= BATADV_MCAST_HAVE_MC_PTYPE_CAPA; in batadv_orig_node_new()
1000 INIT_HLIST_NODE(&orig_node->mcast_want_all_unsnoopables_node); in batadv_orig_node_new()
1001 INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv4_node); in batadv_orig_node_new()
1002 INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv6_node); in batadv_orig_node_new()
1003 spin_lock_init(&orig_node->mcast_handler_lock); in batadv_orig_node_new()
1017 INIT_HLIST_HEAD(&orig_node->fragments[i].fragment_list); in batadv_orig_node_new()
1018 spin_lock_init(&orig_node->fragments[i].lock); in batadv_orig_node_new()
1019 orig_node->fragments[i].size = 0; in batadv_orig_node_new()
1029 * batadv_purge_neigh_ifinfo() - purge obsolete ifinfo entries from neighbor
1030 * @bat_priv: the bat priv with all the soft interface information
1031 * @neigh: orig node which is to be checked
1041 spin_lock_bh(&neigh->ifinfo_lock); in batadv_purge_neigh_ifinfo()
1045 &neigh->ifinfo_list, list) { in batadv_purge_neigh_ifinfo()
1046 if_outgoing = neigh_ifinfo->if_outgoing; in batadv_purge_neigh_ifinfo()
1048 /* always keep the default interface */ in batadv_purge_neigh_ifinfo()
1052 /* don't purge if the interface is not (going) down */ in batadv_purge_neigh_ifinfo()
1053 if (if_outgoing->if_status != BATADV_IF_INACTIVE && in batadv_purge_neigh_ifinfo()
1054 if_outgoing->if_status != BATADV_IF_NOT_IN_USE && in batadv_purge_neigh_ifinfo()
1055 if_outgoing->if_status != BATADV_IF_TO_BE_REMOVED) in batadv_purge_neigh_ifinfo()
1060 neigh->addr, if_outgoing->net_dev->name); in batadv_purge_neigh_ifinfo()
1062 hlist_del_rcu(&neigh_ifinfo->list); in batadv_purge_neigh_ifinfo()
1066 spin_unlock_bh(&neigh->ifinfo_lock); in batadv_purge_neigh_ifinfo()
1070 * batadv_purge_orig_ifinfo() - purge obsolete ifinfo entries from originator
1071 * @bat_priv: the bat priv with all the soft interface information
1072 * @orig_node: orig node which is to be checked
1085 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_ifinfo()
1089 &orig_node->ifinfo_list, list) { in batadv_purge_orig_ifinfo()
1090 if_outgoing = orig_ifinfo->if_outgoing; in batadv_purge_orig_ifinfo()
1092 /* always keep the default interface */ in batadv_purge_orig_ifinfo()
1096 /* don't purge if the interface is not (going) down */ in batadv_purge_orig_ifinfo()
1097 if (if_outgoing->if_status != BATADV_IF_INACTIVE && in batadv_purge_orig_ifinfo()
1098 if_outgoing->if_status != BATADV_IF_NOT_IN_USE && in batadv_purge_orig_ifinfo()
1099 if_outgoing->if_status != BATADV_IF_TO_BE_REMOVED) in batadv_purge_orig_ifinfo()
1104 orig_node->orig, if_outgoing->net_dev->name); in batadv_purge_orig_ifinfo()
1108 hlist_del_rcu(&orig_ifinfo->list); in batadv_purge_orig_ifinfo()
1110 if (orig_node->last_bonding_candidate == orig_ifinfo) { in batadv_purge_orig_ifinfo()
1111 orig_node->last_bonding_candidate = NULL; in batadv_purge_orig_ifinfo()
1116 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_ifinfo()
1122 * batadv_purge_orig_neighbors() - purges neighbors from originator
1123 * @bat_priv: the bat priv with all the soft interface information
1124 * @orig_node: orig node which is to be checked
1138 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_neighbors()
1142 &orig_node->neigh_list, list) { in batadv_purge_orig_neighbors()
1143 last_seen = neigh_node->last_seen; in batadv_purge_orig_neighbors()
1144 if_incoming = neigh_node->if_incoming; in batadv_purge_orig_neighbors()
1147 if_incoming->if_status == BATADV_IF_INACTIVE || in batadv_purge_orig_neighbors()
1148 if_incoming->if_status == BATADV_IF_NOT_IN_USE || in batadv_purge_orig_neighbors()
1149 if_incoming->if_status == BATADV_IF_TO_BE_REMOVED) { in batadv_purge_orig_neighbors()
1150 if (if_incoming->if_status == BATADV_IF_INACTIVE || in batadv_purge_orig_neighbors()
1151 if_incoming->if_status == BATADV_IF_NOT_IN_USE || in batadv_purge_orig_neighbors()
1152 if_incoming->if_status == BATADV_IF_TO_BE_REMOVED) in batadv_purge_orig_neighbors()
1155 orig_node->orig, neigh_node->addr, in batadv_purge_orig_neighbors()
1156 if_incoming->net_dev->name); in batadv_purge_orig_neighbors()
1160 orig_node->orig, neigh_node->addr, in batadv_purge_orig_neighbors()
1165 hlist_del_rcu(&neigh_node->list); in batadv_purge_orig_neighbors()
1169 * deleted, but some interface has been removed. in batadv_purge_orig_neighbors()
1175 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_neighbors()
1180 * batadv_find_best_neighbor() - finds the best neighbor after purging
1181 * @bat_priv: the bat priv with all the soft interface information
1182 * @orig_node: orig node which is to be checked
1183 * @if_outgoing: the interface for which the metric should be compared
1193 struct batadv_algo_ops *bao = bat_priv->algo_ops; in batadv_find_best_neighbor()
1196 hlist_for_each_entry_rcu(neigh, &orig_node->neigh_list, list) { in batadv_find_best_neighbor()
1197 if (best && (bao->neigh.cmp(neigh, if_outgoing, best, in batadv_find_best_neighbor()
1201 if (!kref_get_unless_zero(&neigh->refcount)) in batadv_find_best_neighbor()
1214 * batadv_purge_orig_node() - purges obsolete information from an orig_node
1215 * @bat_priv: the bat priv with all the soft interface information
1216 * @orig_node: orig node which is to be checked
1230 if (batadv_has_timed_out(orig_node->last_seen, in batadv_purge_orig_node()
1234 orig_node->orig, in batadv_purge_orig_node()
1235 jiffies_to_msecs(orig_node->last_seen)); in batadv_purge_orig_node()
1254 if (hard_iface->if_status != BATADV_IF_ACTIVE) in batadv_purge_orig_node()
1257 if (hard_iface->soft_iface != bat_priv->soft_iface) in batadv_purge_orig_node()
1260 if (!kref_get_unless_zero(&hard_iface->refcount)) in batadv_purge_orig_node()
1278 * batadv_purge_orig_ref() - Purge all outdated originators
1279 * @bat_priv: the bat priv with all the soft interface information
1283 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_purge_orig_ref()
1294 for (i = 0; i < hash->size; i++) { in batadv_purge_orig_ref()
1295 head = &hash->table[i]; in batadv_purge_orig_ref()
1298 list_lock = &hash->list_locks[i]; in batadv_purge_orig_ref()
1305 hlist_del_rcu(&orig_node->hash_entry); in batadv_purge_orig_ref()
1306 batadv_tt_global_del_orig(orig_node->bat_priv, in batadv_purge_orig_ref()
1307 orig_node, -1, in batadv_purge_orig_ref()
1331 &bat_priv->orig_work, in batadv_purge_orig()
1336 * batadv_orig_dump() - Dump to netlink the originator infos for a specific
1337 * outgoing interface
1345 struct net *net = sock_net(cb->skb->sk); in batadv_orig_dump()
1354 ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); in batadv_orig_dump()
1356 return -EINVAL; in batadv_orig_dump()
1360 ret = -ENODEV; in batadv_orig_dump()
1367 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) { in batadv_orig_dump()
1368 ret = -ENOENT; in batadv_orig_dump()
1372 hard_ifindex = batadv_netlink_get_ifindex(cb->nlh, in batadv_orig_dump()
1380 ret = -ENODEV; in batadv_orig_dump()
1384 if (hardif->soft_iface != soft_iface) { in batadv_orig_dump()
1385 ret = -ENOENT; in batadv_orig_dump()
1390 if (!bat_priv->algo_ops->orig.dump) { in batadv_orig_dump()
1391 ret = -EOPNOTSUPP; in batadv_orig_dump()
1395 bat_priv->algo_ops->orig.dump(msg, cb, bat_priv, hardif); in batadv_orig_dump()
1397 ret = msg->len; in batadv_orig_dump()