net/batman-adv/gateway_client.c
Source file repositories/reference/linux-study-clean/net/batman-adv/gateway_client.c
File Facts
- System
- Linux kernel
- Corpus path
net/batman-adv/gateway_client.c- Extension
.c- Size
- 21102 bytes
- Lines
- 765
- 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
gateway_client.hmain.hlinux/atomic.hlinux/bug.hlinux/byteorder/generic.hlinux/container_of.hlinux/err.hlinux/errno.hlinux/etherdevice.hlinux/gfp.hlinux/if_ether.hlinux/if_vlan.hlinux/in.hlinux/ip.hlinux/ipv6.hlinux/kref.hlinux/list.hlinux/lockdep.hlinux/netdevice.hlinux/netlink.hlinux/rculist.hlinux/rcupdate.hlinux/skbuff.hlinux/slab.hlinux/spinlock.hlinux/sprintf.hlinux/stddef.hlinux/udp.huapi/linux/batadv_packet.huapi/linux/batman_adv.hhard-interface.hlog.h
Detected Declarations
function batadv_gw_node_releasefunction batadv_gw_get_selected_gw_nodefunction batadv_gw_get_selected_origfunction batadv_gw_selectfunction batadv_gw_reselectfunction batadv_gw_check_client_stopfunction batadv_gw_electionfunction batadv_gw_check_electionfunction batadv_gw_node_addfunction batadv_gw_node_getfunction batadv_gw_node_updatefunction batadv_gw_node_deletefunction batadv_gw_node_freefunction hlist_for_each_entry_safefunction batadv_gw_dumpfunction batadv_gw_dhcp_recipient_getfunction batadv_gw_out_of_range
Annotated Snippet
if (!router) {
batadv_gw_reselect(bat_priv);
goto out;
}
router_ifinfo = batadv_neigh_ifinfo_get(router,
BATADV_IF_DEFAULT);
if (!router_ifinfo) {
batadv_gw_reselect(bat_priv);
goto out;
}
}
if (curr_gw && !next_gw) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Removing selected gateway - no gateway in range\n");
batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_DEL,
NULL);
} else if (!curr_gw && next_gw) {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Adding route to gateway %pM (bandwidth: %u.%u/%u.%u MBit, tq: %i)\n",
next_gw->orig_node->orig,
next_gw->bandwidth_down / 10,
next_gw->bandwidth_down % 10,
next_gw->bandwidth_up / 10,
next_gw->bandwidth_up % 10,
router_ifinfo->bat_iv.tq_avg);
batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_ADD,
gw_addr);
} else {
batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
"Changing route to gateway %pM (bandwidth: %u.%u/%u.%u MBit, tq: %i)\n",
next_gw->orig_node->orig,
next_gw->bandwidth_down / 10,
next_gw->bandwidth_down % 10,
next_gw->bandwidth_up / 10,
next_gw->bandwidth_up % 10,
router_ifinfo->bat_iv.tq_avg);
batadv_throw_uevent(bat_priv, BATADV_UEV_GW, BATADV_UEV_CHANGE,
gw_addr);
}
batadv_gw_select(bat_priv, next_gw);
out:
batadv_gw_node_put(curr_gw);
batadv_gw_node_put(next_gw);
batadv_neigh_node_put(router);
batadv_neigh_ifinfo_put(router_ifinfo);
}
/**
* batadv_gw_check_election() - Elect orig node as best gateway when eligible
* @bat_priv: the bat priv with all the mesh interface information
* @orig_node: orig node which is to be checked
*/
void batadv_gw_check_election(struct batadv_priv *bat_priv,
struct batadv_orig_node *orig_node)
{
struct batadv_orig_node *curr_gw_orig;
/* abort immediately if the routing algorithm does not support gateway
* election
*/
if (!bat_priv->algo_ops->gw.is_eligible)
return;
curr_gw_orig = batadv_gw_get_selected_orig(bat_priv);
if (!curr_gw_orig)
goto reselect;
/* this node already is the gateway */
if (curr_gw_orig == orig_node)
goto out;
if (!bat_priv->algo_ops->gw.is_eligible(bat_priv, curr_gw_orig,
orig_node))
goto out;
reselect:
batadv_gw_reselect(bat_priv);
out:
batadv_orig_node_put(curr_gw_orig);
}
/**
* batadv_gw_node_add() - add gateway node to list of available gateways
* @bat_priv: the bat priv with all the mesh interface information
* @orig_node: originator announcing gateway capabilities
* @gateway: announced bandwidth information
Annotation
- Immediate include surface: `gateway_client.h`, `main.h`, `linux/atomic.h`, `linux/bug.h`, `linux/byteorder/generic.h`, `linux/container_of.h`, `linux/err.h`, `linux/errno.h`.
- Detected declarations: `function batadv_gw_node_release`, `function batadv_gw_get_selected_gw_node`, `function batadv_gw_get_selected_orig`, `function batadv_gw_select`, `function batadv_gw_reselect`, `function batadv_gw_check_client_stop`, `function batadv_gw_election`, `function batadv_gw_check_election`, `function batadv_gw_node_add`, `function batadv_gw_node_get`.
- 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.