net/batman-adv/originator.c
Source file repositories/reference/linux-study-clean/net/batman-adv/originator.c
File Facts
- System
- Linux kernel
- Corpus path
net/batman-adv/originator.c- Extension
.c- Size
- 38314 bytes
- Lines
- 1376
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: implementation source
- Status
- source implementation candidate
Why This File Exists
Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Networking stack implementation surface: socket APIs, protocol dispatch, packet flow, routing, filtering, and network namespaces.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
originator.hmain.hlinux/container_of.hlinux/err.hlinux/errno.hlinux/etherdevice.hlinux/gfp.hlinux/if_vlan.hlinux/jiffies.hlinux/kref.hlinux/list.hlinux/lockdep.hlinux/netdevice.hlinux/netlink.hlinux/rculist.hlinux/rcupdate.hlinux/skbuff.hlinux/slab.hlinux/spinlock.hlinux/stddef.hlinux/workqueue.huapi/linux/batadv_packet.hdistributed-arp-table.hfragmentation.hgateway_client.hhard-interface.hhash.hlog.hmulticast.hnetlink.hrouting.htranslation-table.h
Detected Declarations
function batadv_orig_hash_findfunction batadv_compare_origfunction batadv_orig_node_vlan_getfunction batadv_vlan_id_validfunction batadv_orig_node_vlan_newfunction batadv_orig_node_vlan_releasefunction batadv_originator_initfunction batadv_neigh_ifinfo_releasefunction batadv_hardif_neigh_releasefunction batadv_neigh_node_releasefunction hlist_for_each_entry_safefunction batadv_orig_router_getfunction batadv_orig_to_routerfunction batadv_orig_ifinfo_getfunction batadv_orig_ifinfo_newfunction batadv_neigh_ifinfo_getfunction batadv_neigh_ifinfo_newfunction batadv_neigh_node_getfunction batadv_hardif_neigh_createfunction batadv_hardif_neigh_get_or_createfunction batadv_hardif_neigh_getfunction batadv_neigh_node_createfunction batadv_neigh_node_get_or_createfunction batadv_hardif_neigh_dumpfunction batadv_orig_ifinfo_releasefunction batadv_orig_node_free_rcufunction batadv_orig_node_releasefunction hlist_for_each_entry_safefunction batadv_originator_freefunction hlist_for_each_entry_safefunction batadv_orig_node_newfunction batadv_purge_neigh_ifinfofunction batadv_purge_orig_ifinfofunction batadv_purge_orig_neighborsfunction batadv_find_best_neighborfunction batadv_purge_orig_nodefunction batadv_purge_orig_reffunction hlist_for_each_entry_safefunction batadv_purge_origfunction batadv_orig_dump
Annotated Snippet
if (orig_node->last_bonding_candidate == orig_ifinfo) {
orig_node->last_bonding_candidate = NULL;
batadv_orig_ifinfo_put(orig_ifinfo);
}
}
spin_unlock_bh(&orig_node->neigh_list_lock);
return ifinfo_purged;
}
/**
* batadv_purge_orig_neighbors() - purges neighbors from originator
* @bat_priv: the bat priv with all the mesh interface information
* @orig_node: orig node which is to be checked
*
* Return: true if any neighbor was purged, false otherwise
*/
static bool
batadv_purge_orig_neighbors(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node)
{
struct hlist_node *node_tmp;
struct batadv_neigh_node *neigh_node;
bool neigh_purged = false;
unsigned long last_seen;
struct batadv_hard_iface *if_incoming;
spin_lock_bh(&orig_node->neigh_list_lock);
/* for all neighbors towards this originator ... */
hlist_for_each_entry_safe(neigh_node, node_tmp,
&orig_node->neigh_list, list) {
last_seen = neigh_node->last_seen;
if_incoming = neigh_node->if_incoming;
if (batadv_has_timed_out(last_seen, BATADV_PURGE_TIMEOUT) ||
if_incoming->if_status == BATADV_IF_INACTIVE ||
if_incoming->if_status == BATADV_IF_NOT_IN_USE ||
if_incoming->if_status == BATADV_IF_TO_BE_REMOVED) {
if (if_incoming->if_status == BATADV_IF_INACTIVE ||
if_incoming->if_status == BATADV_IF_NOT_IN_USE ||
if_incoming->if_status == BATADV_IF_TO_BE_REMOVED)
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"neighbor purge: originator %pM, neighbor: %pM, iface: %s\n",
orig_node->orig, neigh_node->addr,
if_incoming->net_dev->name);
else
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"neighbor timeout: originator %pM, neighbor: %pM, last_seen: %u\n",
orig_node->orig, neigh_node->addr,
jiffies_to_msecs(last_seen));
neigh_purged = true;
hlist_del_rcu(&neigh_node->list);
batadv_neigh_node_put(neigh_node);
} else {
/* only necessary if not the whole neighbor is to be
* deleted, but some interface has been removed.
*/
batadv_purge_neigh_ifinfo(bat_priv, neigh_node);
}
}
spin_unlock_bh(&orig_node->neigh_list_lock);
return neigh_purged;
}
/**
* batadv_find_best_neighbor() - finds the best neighbor after purging
* @bat_priv: the bat priv with all the mesh interface information
* @orig_node: orig node which is to be checked
* @if_outgoing: the interface for which the metric should be compared
*
* Return: the current best neighbor, with refcount increased.
*/
static struct batadv_neigh_node *
batadv_find_best_neighbor(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node,
struct batadv_hard_iface *if_outgoing)
{
struct batadv_neigh_node *best = NULL, *neigh;
struct batadv_algo_ops *bao = bat_priv->algo_ops;
rcu_read_lock();
hlist_for_each_entry_rcu(neigh, &orig_node->neigh_list, list) {
if (best && (bao->neigh.cmp(neigh, if_outgoing, best,
if_outgoing) <= 0))
continue;
Annotation
- Immediate include surface: `originator.h`, `main.h`, `linux/container_of.h`, `linux/err.h`, `linux/errno.h`, `linux/etherdevice.h`, `linux/gfp.h`, `linux/if_vlan.h`.
- Detected declarations: `function batadv_orig_hash_find`, `function batadv_compare_orig`, `function batadv_orig_node_vlan_get`, `function batadv_vlan_id_valid`, `function batadv_orig_node_vlan_new`, `function batadv_orig_node_vlan_release`, `function batadv_originator_init`, `function batadv_neigh_ifinfo_release`, `function batadv_hardif_neigh_release`, `function batadv_neigh_node_release`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.