• Home
  • Raw
  • Download

Lines Matching +full:interface +full:- +full:node

1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2009-2020 B.A.T.M.A.N. contributors:
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_orig_node_vlan_new() - search and possibly create an orig_node_vlan
153 spin_lock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_vlan_new()
164 kref_init(&vlan->refcount); in batadv_orig_node_vlan_new()
165 vlan->vid = vid; in batadv_orig_node_vlan_new()
167 kref_get(&vlan->refcount); in batadv_orig_node_vlan_new()
168 hlist_add_head_rcu(&vlan->list, &orig_node->vlan_list); in batadv_orig_node_vlan_new()
171 spin_unlock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_vlan_new()
177 * batadv_orig_node_vlan_release() - release originator-vlan object from lists
179 * @ref: kref pointer of the originator-vlan object
191 * batadv_originator_init() - Initialize all originator structures
192 * @bat_priv: the bat priv with all the soft interface information
198 if (bat_priv->orig_hash) in batadv_originator_init()
201 bat_priv->orig_hash = batadv_hash_new(1024); in batadv_originator_init()
203 if (!bat_priv->orig_hash) in batadv_originator_init()
206 batadv_hash_set_lock_class(bat_priv->orig_hash, in batadv_originator_init()
209 INIT_DELAYED_WORK(&bat_priv->orig_work, batadv_purge_orig); in batadv_originator_init()
211 &bat_priv->orig_work, in batadv_originator_init()
217 return -ENOMEM; in batadv_originator_init()
221 * batadv_neigh_ifinfo_release() - release neigh_ifinfo from lists and queue for
231 if (neigh_ifinfo->if_outgoing != BATADV_IF_DEFAULT) in batadv_neigh_ifinfo_release()
232 batadv_hardif_put(neigh_ifinfo->if_outgoing); in batadv_neigh_ifinfo_release()
238 * batadv_hardif_neigh_release() - release hardif neigh node from lists and
249 spin_lock_bh(&hardif_neigh->if_incoming->neigh_list_lock); in batadv_hardif_neigh_release()
250 hlist_del_init_rcu(&hardif_neigh->list); in batadv_hardif_neigh_release()
251 spin_unlock_bh(&hardif_neigh->if_incoming->neigh_list_lock); in batadv_hardif_neigh_release()
253 batadv_hardif_put(hardif_neigh->if_incoming); in batadv_hardif_neigh_release()
258 * batadv_neigh_node_release() - release neigh_node from lists and queue for
271 &neigh_node->ifinfo_list, list) { in batadv_neigh_node_release()
275 batadv_hardif_neigh_put(neigh_node->hardif_neigh); in batadv_neigh_node_release()
277 batadv_hardif_put(neigh_node->if_incoming); in batadv_neigh_node_release()
283 * batadv_orig_router_get() - router to the originator depending on iface
284 * @orig_node: the orig node for the router
285 * @if_outgoing: the interface where the payload packet has been received or
300 hlist_for_each_entry_rcu(orig_ifinfo, &orig_node->ifinfo_list, list) { in batadv_orig_router_get()
301 if (orig_ifinfo->if_outgoing != if_outgoing) in batadv_orig_router_get()
304 router = rcu_dereference(orig_ifinfo->router); in batadv_orig_router_get()
308 if (router && !kref_get_unless_zero(&router->refcount)) in batadv_orig_router_get()
316 * batadv_orig_ifinfo_get() - find the ifinfo from an orig_node
317 * @orig_node: the orig node to be queried
318 * @if_outgoing: the interface for which the ifinfo should be acquired
331 hlist_for_each_entry_rcu(tmp, &orig_node->ifinfo_list, in batadv_orig_ifinfo_get()
333 if (tmp->if_outgoing != if_outgoing) in batadv_orig_ifinfo_get()
336 if (!kref_get_unless_zero(&tmp->refcount)) in batadv_orig_ifinfo_get()
348 * batadv_orig_ifinfo_new() - search and possibly create an orig_ifinfo object
349 * @orig_node: the orig node to be queried
350 * @if_outgoing: the interface for which the ifinfo should be acquired
353 * interface otherwise. The object is created and added to the list
365 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_orig_ifinfo_new()
376 kref_get(&if_outgoing->refcount); in batadv_orig_ifinfo_new()
378 reset_time = jiffies - 1; in batadv_orig_ifinfo_new()
379 reset_time -= msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); in batadv_orig_ifinfo_new()
380 orig_ifinfo->batman_seqno_reset = reset_time; in batadv_orig_ifinfo_new()
381 orig_ifinfo->if_outgoing = if_outgoing; in batadv_orig_ifinfo_new()
382 INIT_HLIST_NODE(&orig_ifinfo->list); in batadv_orig_ifinfo_new()
383 kref_init(&orig_ifinfo->refcount); in batadv_orig_ifinfo_new()
385 kref_get(&orig_ifinfo->refcount); in batadv_orig_ifinfo_new()
386 hlist_add_head_rcu(&orig_ifinfo->list, in batadv_orig_ifinfo_new()
387 &orig_node->ifinfo_list); in batadv_orig_ifinfo_new()
389 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_orig_ifinfo_new()
394 * batadv_neigh_ifinfo_get() - find the ifinfo from an neigh_node
395 * @neigh: the neigh node to be queried
396 * @if_outgoing: the interface for which the ifinfo should be acquired
410 hlist_for_each_entry_rcu(tmp_neigh_ifinfo, &neigh->ifinfo_list, in batadv_neigh_ifinfo_get()
412 if (tmp_neigh_ifinfo->if_outgoing != if_outgoing) in batadv_neigh_ifinfo_get()
415 if (!kref_get_unless_zero(&tmp_neigh_ifinfo->refcount)) in batadv_neigh_ifinfo_get()
427 * batadv_neigh_ifinfo_new() - search and possibly create an neigh_ifinfo object
428 * @neigh: the neigh node to be queried
429 * @if_outgoing: the interface for which the ifinfo should be acquired
432 * if_outgoing interface otherwise. The object is created and added to the list
443 spin_lock_bh(&neigh->ifinfo_lock); in batadv_neigh_ifinfo_new()
454 kref_get(&if_outgoing->refcount); in batadv_neigh_ifinfo_new()
456 INIT_HLIST_NODE(&neigh_ifinfo->list); in batadv_neigh_ifinfo_new()
457 kref_init(&neigh_ifinfo->refcount); in batadv_neigh_ifinfo_new()
458 neigh_ifinfo->if_outgoing = if_outgoing; in batadv_neigh_ifinfo_new()
460 kref_get(&neigh_ifinfo->refcount); in batadv_neigh_ifinfo_new()
461 hlist_add_head_rcu(&neigh_ifinfo->list, &neigh->ifinfo_list); in batadv_neigh_ifinfo_new()
464 spin_unlock_bh(&neigh->ifinfo_lock); in batadv_neigh_ifinfo_new()
470 * batadv_neigh_node_get() - retrieve a neighbour from the list
472 * @hard_iface: the interface where this neighbour is connected to
476 * which is connected through the provided hard interface.
488 hlist_for_each_entry_rcu(tmp_neigh_node, &orig_node->neigh_list, list) { in batadv_neigh_node_get()
489 if (!batadv_compare_eth(tmp_neigh_node->addr, addr)) in batadv_neigh_node_get()
492 if (tmp_neigh_node->if_incoming != hard_iface) in batadv_neigh_node_get()
495 if (!kref_get_unless_zero(&tmp_neigh_node->refcount)) in batadv_neigh_node_get()
507 * batadv_hardif_neigh_create() - create a hardif neighbour node
508 * @hard_iface: the interface this neighbour is connected to
509 * @neigh_addr: the interface address of the neighbour to retrieve
512 * Return: the hardif neighbour node if found or created or NULL otherwise.
519 struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_hardif_neigh_create()
522 spin_lock_bh(&hard_iface->neigh_list_lock); in batadv_hardif_neigh_create()
533 kref_get(&hard_iface->refcount); in batadv_hardif_neigh_create()
534 INIT_HLIST_NODE(&hardif_neigh->list); in batadv_hardif_neigh_create()
535 ether_addr_copy(hardif_neigh->addr, neigh_addr); in batadv_hardif_neigh_create()
536 ether_addr_copy(hardif_neigh->orig, orig_node->orig); in batadv_hardif_neigh_create()
537 hardif_neigh->if_incoming = hard_iface; in batadv_hardif_neigh_create()
538 hardif_neigh->last_seen = jiffies; in batadv_hardif_neigh_create()
540 kref_init(&hardif_neigh->refcount); in batadv_hardif_neigh_create()
542 if (bat_priv->algo_ops->neigh.hardif_init) in batadv_hardif_neigh_create()
543 bat_priv->algo_ops->neigh.hardif_init(hardif_neigh); in batadv_hardif_neigh_create()
545 hlist_add_head_rcu(&hardif_neigh->list, &hard_iface->neigh_list); in batadv_hardif_neigh_create()
548 spin_unlock_bh(&hard_iface->neigh_list_lock); in batadv_hardif_neigh_create()
553 * batadv_hardif_neigh_get_or_create() - retrieve or create a hardif neighbour
554 * node
555 * @hard_iface: the interface this neighbour is connected to
556 * @neigh_addr: the interface address of the neighbour to retrieve
559 * Return: the hardif neighbour node if found or created or NULL otherwise.
577 * batadv_hardif_neigh_get() - retrieve a hardif neighbour from the list
578 * @hard_iface: the interface where this neighbour is connected to
581 * Looks for and possibly returns a neighbour belonging to this hard interface.
593 &hard_iface->neigh_list, list) { in batadv_hardif_neigh_get()
594 if (!batadv_compare_eth(tmp_hardif_neigh->addr, neigh_addr)) in batadv_hardif_neigh_get()
597 if (!kref_get_unless_zero(&tmp_hardif_neigh->refcount)) in batadv_hardif_neigh_get()
609 * batadv_neigh_node_create() - create a neigh node object
611 * @hard_iface: the interface where the neighbour is connected to
612 * @neigh_addr: the mac address of the neighbour interface
616 * Return: the neighbour node if found or created or NULL otherwise.
626 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_neigh_node_create()
641 INIT_HLIST_NODE(&neigh_node->list); in batadv_neigh_node_create()
642 INIT_HLIST_HEAD(&neigh_node->ifinfo_list); in batadv_neigh_node_create()
643 spin_lock_init(&neigh_node->ifinfo_lock); in batadv_neigh_node_create()
645 kref_get(&hard_iface->refcount); in batadv_neigh_node_create()
646 ether_addr_copy(neigh_node->addr, neigh_addr); in batadv_neigh_node_create()
647 neigh_node->if_incoming = hard_iface; in batadv_neigh_node_create()
648 neigh_node->orig_node = orig_node; in batadv_neigh_node_create()
649 neigh_node->last_seen = jiffies; in batadv_neigh_node_create()
652 kref_get(&hardif_neigh->refcount); in batadv_neigh_node_create()
653 neigh_node->hardif_neigh = hardif_neigh; in batadv_neigh_node_create()
656 kref_init(&neigh_node->refcount); in batadv_neigh_node_create()
658 kref_get(&neigh_node->refcount); in batadv_neigh_node_create()
659 hlist_add_head_rcu(&neigh_node->list, &orig_node->neigh_list); in batadv_neigh_node_create()
661 batadv_dbg(BATADV_DBG_BATMAN, orig_node->bat_priv, in batadv_neigh_node_create()
662 "Creating new neighbor %pM for orig_node %pM on interface %s\n", in batadv_neigh_node_create()
663 neigh_addr, orig_node->orig, hard_iface->net_dev->name); in batadv_neigh_node_create()
666 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_neigh_node_create()
674 * batadv_neigh_node_get_or_create() - retrieve or create a neigh node object
676 * @hard_iface: the interface where the neighbour is connected to
677 * @neigh_addr: the mac address of the neighbour interface
679 * Return: the neighbour node if found or created or NULL otherwise.
698 * batadv_hardif_neigh_seq_print_text() - print the single hop neighbour list
706 struct net_device *net_dev = (struct net_device *)seq->private; in batadv_hardif_neigh_seq_print_text()
715 BATADV_SOURCE_VERSION, primary_if->net_dev->name, in batadv_hardif_neigh_seq_print_text()
716 primary_if->net_dev->dev_addr, net_dev->name, in batadv_hardif_neigh_seq_print_text()
717 bat_priv->algo_ops->name); in batadv_hardif_neigh_seq_print_text()
721 if (!bat_priv->algo_ops->neigh.print) { in batadv_hardif_neigh_seq_print_text()
727 bat_priv->algo_ops->neigh.print(bat_priv, seq); in batadv_hardif_neigh_seq_print_text()
733 * batadv_hardif_neigh_dump() - Dump to netlink the neighbor infos for a
734 * specific outgoing interface
742 struct net *net = sock_net(cb->skb->sk); in batadv_hardif_neigh_dump()
751 ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); in batadv_hardif_neigh_dump()
753 return -EINVAL; in batadv_hardif_neigh_dump()
757 ret = -ENODEV; in batadv_hardif_neigh_dump()
764 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) { in batadv_hardif_neigh_dump()
765 ret = -ENOENT; in batadv_hardif_neigh_dump()
769 hard_ifindex = batadv_netlink_get_ifindex(cb->nlh, in batadv_hardif_neigh_dump()
777 ret = -ENODEV; in batadv_hardif_neigh_dump()
781 if (hardif->soft_iface != soft_iface) { in batadv_hardif_neigh_dump()
782 ret = -ENOENT; in batadv_hardif_neigh_dump()
787 if (!bat_priv->algo_ops->neigh.dump) { in batadv_hardif_neigh_dump()
788 ret = -EOPNOTSUPP; in batadv_hardif_neigh_dump()
792 bat_priv->algo_ops->neigh.dump(msg, cb, bat_priv, hardif); in batadv_hardif_neigh_dump()
794 ret = msg->len; in batadv_hardif_neigh_dump()
810 * batadv_orig_ifinfo_release() - release orig_ifinfo from lists and queue for
821 if (orig_ifinfo->if_outgoing != BATADV_IF_DEFAULT) in batadv_orig_ifinfo_release()
822 batadv_hardif_put(orig_ifinfo->if_outgoing); in batadv_orig_ifinfo_release()
825 router = rcu_dereference_protected(orig_ifinfo->router, true); in batadv_orig_ifinfo_release()
833 * batadv_orig_node_free_rcu() - free the orig_node
846 kfree(orig_node->tt_buff); in batadv_orig_node_free_rcu()
851 * batadv_orig_node_release() - release orig_node from lists and queue for
866 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_orig_node_release()
870 &orig_node->neigh_list, list) { in batadv_orig_node_release()
871 hlist_del_rcu(&neigh_node->list); in batadv_orig_node_release()
876 &orig_node->ifinfo_list, list) { in batadv_orig_node_release()
877 hlist_del_rcu(&orig_ifinfo->list); in batadv_orig_node_release()
881 last_candidate = orig_node->last_bonding_candidate; in batadv_orig_node_release()
882 orig_node->last_bonding_candidate = NULL; in batadv_orig_node_release()
883 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_orig_node_release()
888 spin_lock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_release()
889 hlist_for_each_entry_safe(vlan, node_tmp, &orig_node->vlan_list, list) { in batadv_orig_node_release()
890 hlist_del_rcu(&vlan->list); in batadv_orig_node_release()
893 spin_unlock_bh(&orig_node->vlan_list_lock); in batadv_orig_node_release()
896 batadv_nc_purge_orig(orig_node->bat_priv, orig_node, NULL); in batadv_orig_node_release()
898 call_rcu(&orig_node->rcu, batadv_orig_node_free_rcu); in batadv_orig_node_release()
902 * batadv_originator_free() - Free all originator structures
903 * @bat_priv: the bat priv with all the soft interface information
907 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_originator_free()
917 cancel_delayed_work_sync(&bat_priv->orig_work); in batadv_originator_free()
919 bat_priv->orig_hash = NULL; in batadv_originator_free()
921 for (i = 0; i < hash->size; i++) { in batadv_originator_free()
922 head = &hash->table[i]; in batadv_originator_free()
923 list_lock = &hash->list_locks[i]; in batadv_originator_free()
928 hlist_del_rcu(&orig_node->hash_entry); in batadv_originator_free()
938 * batadv_orig_node_new() - creates a new orig_node
939 * @bat_priv: the bat priv with all the soft interface information
962 INIT_HLIST_HEAD(&orig_node->neigh_list); in batadv_orig_node_new()
963 INIT_HLIST_HEAD(&orig_node->vlan_list); in batadv_orig_node_new()
964 INIT_HLIST_HEAD(&orig_node->ifinfo_list); in batadv_orig_node_new()
965 spin_lock_init(&orig_node->bcast_seqno_lock); in batadv_orig_node_new()
966 spin_lock_init(&orig_node->neigh_list_lock); in batadv_orig_node_new()
967 spin_lock_init(&orig_node->tt_buff_lock); in batadv_orig_node_new()
968 spin_lock_init(&orig_node->tt_lock); in batadv_orig_node_new()
969 spin_lock_init(&orig_node->vlan_list_lock); in batadv_orig_node_new()
974 kref_init(&orig_node->refcount); in batadv_orig_node_new()
976 orig_node->bat_priv = bat_priv; in batadv_orig_node_new()
977 ether_addr_copy(orig_node->orig, addr); in batadv_orig_node_new()
979 atomic_set(&orig_node->last_ttvn, 0); in batadv_orig_node_new()
980 orig_node->tt_buff = NULL; in batadv_orig_node_new()
981 orig_node->tt_buff_len = 0; in batadv_orig_node_new()
982 orig_node->last_seen = jiffies; in batadv_orig_node_new()
983 reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); in batadv_orig_node_new()
984 orig_node->bcast_seqno_reset = reset_time; in batadv_orig_node_new()
987 orig_node->mcast_flags = BATADV_MCAST_WANT_NO_RTR4; in batadv_orig_node_new()
988 orig_node->mcast_flags |= BATADV_MCAST_WANT_NO_RTR6; in batadv_orig_node_new()
989 INIT_HLIST_NODE(&orig_node->mcast_want_all_unsnoopables_node); in batadv_orig_node_new()
990 INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv4_node); in batadv_orig_node_new()
991 INIT_HLIST_NODE(&orig_node->mcast_want_all_ipv6_node); in batadv_orig_node_new()
992 spin_lock_init(&orig_node->mcast_handler_lock); in batadv_orig_node_new()
1006 INIT_HLIST_HEAD(&orig_node->fragments[i].fragment_list); in batadv_orig_node_new()
1007 spin_lock_init(&orig_node->fragments[i].lock); in batadv_orig_node_new()
1008 orig_node->fragments[i].size = 0; in batadv_orig_node_new()
1018 * batadv_purge_neigh_ifinfo() - purge obsolete ifinfo entries from neighbor
1019 * @bat_priv: the bat priv with all the soft interface information
1020 * @neigh: orig node which is to be checked
1030 spin_lock_bh(&neigh->ifinfo_lock); in batadv_purge_neigh_ifinfo()
1034 &neigh->ifinfo_list, list) { in batadv_purge_neigh_ifinfo()
1035 if_outgoing = neigh_ifinfo->if_outgoing; in batadv_purge_neigh_ifinfo()
1037 /* always keep the default interface */ in batadv_purge_neigh_ifinfo()
1041 /* don't purge if the interface is not (going) down */ in batadv_purge_neigh_ifinfo()
1042 if (if_outgoing->if_status != BATADV_IF_INACTIVE && in batadv_purge_neigh_ifinfo()
1043 if_outgoing->if_status != BATADV_IF_NOT_IN_USE && in batadv_purge_neigh_ifinfo()
1044 if_outgoing->if_status != BATADV_IF_TO_BE_REMOVED) in batadv_purge_neigh_ifinfo()
1049 neigh->addr, if_outgoing->net_dev->name); in batadv_purge_neigh_ifinfo()
1051 hlist_del_rcu(&neigh_ifinfo->list); in batadv_purge_neigh_ifinfo()
1055 spin_unlock_bh(&neigh->ifinfo_lock); in batadv_purge_neigh_ifinfo()
1059 * batadv_purge_orig_ifinfo() - purge obsolete ifinfo entries from originator
1060 * @bat_priv: the bat priv with all the soft interface information
1061 * @orig_node: orig node which is to be checked
1074 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_ifinfo()
1078 &orig_node->ifinfo_list, list) { in batadv_purge_orig_ifinfo()
1079 if_outgoing = orig_ifinfo->if_outgoing; in batadv_purge_orig_ifinfo()
1081 /* always keep the default interface */ in batadv_purge_orig_ifinfo()
1085 /* don't purge if the interface is not (going) down */ in batadv_purge_orig_ifinfo()
1086 if (if_outgoing->if_status != BATADV_IF_INACTIVE && in batadv_purge_orig_ifinfo()
1087 if_outgoing->if_status != BATADV_IF_NOT_IN_USE && in batadv_purge_orig_ifinfo()
1088 if_outgoing->if_status != BATADV_IF_TO_BE_REMOVED) in batadv_purge_orig_ifinfo()
1093 orig_node->orig, if_outgoing->net_dev->name); in batadv_purge_orig_ifinfo()
1097 hlist_del_rcu(&orig_ifinfo->list); in batadv_purge_orig_ifinfo()
1099 if (orig_node->last_bonding_candidate == orig_ifinfo) { in batadv_purge_orig_ifinfo()
1100 orig_node->last_bonding_candidate = NULL; in batadv_purge_orig_ifinfo()
1105 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_ifinfo()
1111 * batadv_purge_orig_neighbors() - purges neighbors from originator
1112 * @bat_priv: the bat priv with all the soft interface information
1113 * @orig_node: orig node which is to be checked
1127 spin_lock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_neighbors()
1131 &orig_node->neigh_list, list) { in batadv_purge_orig_neighbors()
1132 last_seen = neigh_node->last_seen; in batadv_purge_orig_neighbors()
1133 if_incoming = neigh_node->if_incoming; in batadv_purge_orig_neighbors()
1136 if_incoming->if_status == BATADV_IF_INACTIVE || in batadv_purge_orig_neighbors()
1137 if_incoming->if_status == BATADV_IF_NOT_IN_USE || in batadv_purge_orig_neighbors()
1138 if_incoming->if_status == BATADV_IF_TO_BE_REMOVED) { in batadv_purge_orig_neighbors()
1139 if (if_incoming->if_status == BATADV_IF_INACTIVE || in batadv_purge_orig_neighbors()
1140 if_incoming->if_status == BATADV_IF_NOT_IN_USE || in batadv_purge_orig_neighbors()
1141 if_incoming->if_status == BATADV_IF_TO_BE_REMOVED) in batadv_purge_orig_neighbors()
1144 orig_node->orig, neigh_node->addr, in batadv_purge_orig_neighbors()
1145 if_incoming->net_dev->name); in batadv_purge_orig_neighbors()
1149 orig_node->orig, neigh_node->addr, in batadv_purge_orig_neighbors()
1154 hlist_del_rcu(&neigh_node->list); in batadv_purge_orig_neighbors()
1158 * deleted, but some interface has been removed. in batadv_purge_orig_neighbors()
1164 spin_unlock_bh(&orig_node->neigh_list_lock); in batadv_purge_orig_neighbors()
1169 * batadv_find_best_neighbor() - finds the best neighbor after purging
1170 * @bat_priv: the bat priv with all the soft interface information
1171 * @orig_node: orig node which is to be checked
1172 * @if_outgoing: the interface for which the metric should be compared
1182 struct batadv_algo_ops *bao = bat_priv->algo_ops; in batadv_find_best_neighbor()
1185 hlist_for_each_entry_rcu(neigh, &orig_node->neigh_list, list) { in batadv_find_best_neighbor()
1186 if (best && (bao->neigh.cmp(neigh, if_outgoing, best, in batadv_find_best_neighbor()
1190 if (!kref_get_unless_zero(&neigh->refcount)) in batadv_find_best_neighbor()
1204 * batadv_purge_orig_node() - purges obsolete information from an orig_node
1205 * @bat_priv: the bat priv with all the soft interface information
1206 * @orig_node: orig node which is to be checked
1220 if (batadv_has_timed_out(orig_node->last_seen, in batadv_purge_orig_node()
1224 orig_node->orig, in batadv_purge_orig_node()
1225 jiffies_to_msecs(orig_node->last_seen)); in batadv_purge_orig_node()
1245 if (hard_iface->if_status != BATADV_IF_ACTIVE) in batadv_purge_orig_node()
1248 if (hard_iface->soft_iface != bat_priv->soft_iface) in batadv_purge_orig_node()
1251 if (!kref_get_unless_zero(&hard_iface->refcount)) in batadv_purge_orig_node()
1270 * batadv_purge_orig_ref() - Purge all outdated originators
1271 * @bat_priv: the bat priv with all the soft interface information
1275 struct batadv_hashtable *hash = bat_priv->orig_hash; in batadv_purge_orig_ref()
1286 for (i = 0; i < hash->size; i++) { in batadv_purge_orig_ref()
1287 head = &hash->table[i]; in batadv_purge_orig_ref()
1288 list_lock = &hash->list_locks[i]; in batadv_purge_orig_ref()
1295 hlist_del_rcu(&orig_node->hash_entry); in batadv_purge_orig_ref()
1296 batadv_tt_global_del_orig(orig_node->bat_priv, in batadv_purge_orig_ref()
1297 orig_node, -1, in batadv_purge_orig_ref()
1321 &bat_priv->orig_work, in batadv_purge_orig()
1328 * batadv_orig_seq_print_text() - Print the originator table in a seq file
1336 struct net_device *net_dev = (struct net_device *)seq->private; in batadv_orig_seq_print_text()
1345 BATADV_SOURCE_VERSION, primary_if->net_dev->name, in batadv_orig_seq_print_text()
1346 primary_if->net_dev->dev_addr, net_dev->name, in batadv_orig_seq_print_text()
1347 bat_priv->algo_ops->name); in batadv_orig_seq_print_text()
1351 if (!bat_priv->algo_ops->orig.print) { in batadv_orig_seq_print_text()
1357 bat_priv->algo_ops->orig.print(bat_priv, seq, BATADV_IF_DEFAULT); in batadv_orig_seq_print_text()
1363 * batadv_orig_hardif_seq_print_text() - writes originator infos for a specific
1364 * outgoing interface
1372 struct net_device *net_dev = (struct net_device *)seq->private; in batadv_orig_hardif_seq_print_text()
1378 if (!hard_iface || !hard_iface->soft_iface) { in batadv_orig_hardif_seq_print_text()
1379 seq_puts(seq, "Interface not known to B.A.T.M.A.N.\n"); in batadv_orig_hardif_seq_print_text()
1383 bat_priv = netdev_priv(hard_iface->soft_iface); in batadv_orig_hardif_seq_print_text()
1384 if (!bat_priv->algo_ops->orig.print) { in batadv_orig_hardif_seq_print_text()
1390 if (hard_iface->if_status != BATADV_IF_ACTIVE) { in batadv_orig_hardif_seq_print_text()
1391 seq_puts(seq, "Interface not active\n"); in batadv_orig_hardif_seq_print_text()
1396 BATADV_SOURCE_VERSION, hard_iface->net_dev->name, in batadv_orig_hardif_seq_print_text()
1397 hard_iface->net_dev->dev_addr, in batadv_orig_hardif_seq_print_text()
1398 hard_iface->soft_iface->name, bat_priv->algo_ops->name); in batadv_orig_hardif_seq_print_text()
1400 bat_priv->algo_ops->orig.print(bat_priv, seq, hard_iface); in batadv_orig_hardif_seq_print_text()
1410 * batadv_orig_dump() - Dump to netlink the originator infos for a specific
1411 * outgoing interface
1419 struct net *net = sock_net(cb->skb->sk); in batadv_orig_dump()
1428 ifindex = batadv_netlink_get_ifindex(cb->nlh, BATADV_ATTR_MESH_IFINDEX); in batadv_orig_dump()
1430 return -EINVAL; in batadv_orig_dump()
1434 ret = -ENODEV; in batadv_orig_dump()
1441 if (!primary_if || primary_if->if_status != BATADV_IF_ACTIVE) { in batadv_orig_dump()
1442 ret = -ENOENT; in batadv_orig_dump()
1446 hard_ifindex = batadv_netlink_get_ifindex(cb->nlh, in batadv_orig_dump()
1454 ret = -ENODEV; in batadv_orig_dump()
1458 if (hardif->soft_iface != soft_iface) { in batadv_orig_dump()
1459 ret = -ENOENT; in batadv_orig_dump()
1464 if (!bat_priv->algo_ops->orig.dump) { in batadv_orig_dump()
1465 ret = -EOPNOTSUPP; in batadv_orig_dump()
1469 bat_priv->algo_ops->orig.dump(msg, cb, bat_priv, hardif); in batadv_orig_dump()
1471 ret = msg->len; in batadv_orig_dump()