net/batman-adv/mesh-interface.c
Source file repositories/reference/linux-study-clean/net/batman-adv/mesh-interface.c
File Facts
- System
- Linux kernel
- Corpus path
net/batman-adv/mesh-interface.c- Extension
.c- Size
- 32103 bytes
- Lines
- 1137
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- 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
mesh-interface.hmain.hlinux/atomic.hlinux/bug.hlinux/byteorder/generic.hlinux/cache.hlinux/compiler.hlinux/container_of.hlinux/cpumask.hlinux/errno.hlinux/etherdevice.hlinux/ethtool.hlinux/gfp.hlinux/if_ether.hlinux/if_vlan.hlinux/jiffies.hlinux/kref.hlinux/list.hlinux/lockdep.hlinux/netdevice.hlinux/netlink.hlinux/percpu.hlinux/random.hlinux/rculist.hlinux/rcupdate.hlinux/skbuff.hlinux/slab.hlinux/socket.hlinux/spinlock.hlinux/stddef.hlinux/string.hlinux/types.h
Detected Declarations
function batadv_skb_head_pushfunction batadv_sum_counterfunction for_each_possible_cpufunction batadv_interface_set_mac_addrfunction batadv_interface_change_mtufunction batadv_interface_set_rx_modefunction batadv_interface_rxfunction batadv_meshif_vlan_releasefunction batadv_meshif_vlan_getfunction batadv_meshif_create_vlanfunction batadv_meshif_destroy_vlanfunction batadv_interface_add_vidfunction batadv_interface_kill_vidfunction batadv_set_lockdep_class_onefunction batadv_set_lockdep_classfunction batadv_meshif_init_latefunction batadv_meshif_slave_addfunction batadv_meshif_slave_delfunction batadv_get_drvinfofunction batadv_get_stringsfunction batadv_get_ethtool_statsfunction batadv_get_sset_countfunction batadv_meshif_freefunction batadv_meshif_init_earlyfunction batadv_meshif_validatefunction batadv_meshif_newlinkfunction batadv_meshif_destroy_netlinkfunction batadv_meshif_is_valid
Annotated Snippet
static const struct net_device_ops batadv_netdev_ops = {
.ndo_init = batadv_meshif_init_late,
.ndo_get_stats = batadv_interface_stats,
.ndo_vlan_rx_add_vid = batadv_interface_add_vid,
.ndo_vlan_rx_kill_vid = batadv_interface_kill_vid,
.ndo_set_mac_address = batadv_interface_set_mac_addr,
.ndo_change_mtu = batadv_interface_change_mtu,
.ndo_set_rx_mode = batadv_interface_set_rx_mode,
.ndo_start_xmit = batadv_interface_tx,
.ndo_validate_addr = eth_validate_addr,
.ndo_add_slave = batadv_meshif_slave_add,
.ndo_del_slave = batadv_meshif_slave_del,
};
static void batadv_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info)
{
strscpy(info->driver, "B.A.T.M.A.N. advanced", sizeof(info->driver));
strscpy(info->version, init_utsname()->release, sizeof(info->version));
strscpy(info->fw_version, "N/A", sizeof(info->fw_version));
strscpy(info->bus_info, "batman", sizeof(info->bus_info));
}
/* Inspired by drivers/net/ethernet/dlink/sundance.c:1702
* Declare each description string in struct.name[] to get fixed sized buffer
* and compile time checking for strings longer than ETH_GSTRING_LEN.
*/
static const struct {
const char name[ETH_GSTRING_LEN];
} batadv_counters_strings[] = {
{ "tx" },
{ "tx_bytes" },
{ "tx_dropped" },
{ "rx" },
{ "rx_bytes" },
{ "forward" },
{ "forward_bytes" },
{ "mgmt_tx" },
{ "mgmt_tx_bytes" },
{ "mgmt_rx" },
{ "mgmt_rx_bytes" },
{ "frag_tx" },
{ "frag_tx_bytes" },
{ "frag_rx" },
{ "frag_rx_bytes" },
{ "frag_fwd" },
{ "frag_fwd_bytes" },
{ "tt_request_tx" },
{ "tt_request_rx" },
{ "tt_response_tx" },
{ "tt_response_rx" },
{ "tt_roam_adv_tx" },
{ "tt_roam_adv_rx" },
#ifdef CONFIG_BATMAN_ADV_MCAST
{ "mcast_tx" },
{ "mcast_tx_bytes" },
{ "mcast_tx_local" },
{ "mcast_tx_local_bytes" },
{ "mcast_rx" },
{ "mcast_rx_bytes" },
{ "mcast_rx_local" },
{ "mcast_rx_local_bytes" },
{ "mcast_fwd" },
{ "mcast_fwd_bytes" },
#endif
#ifdef CONFIG_BATMAN_ADV_DAT
{ "dat_get_tx" },
{ "dat_get_rx" },
{ "dat_put_tx" },
{ "dat_put_rx" },
{ "dat_cached_reply_tx" },
#endif
};
static void batadv_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{
if (stringset == ETH_SS_STATS)
memcpy(data, batadv_counters_strings,
sizeof(batadv_counters_strings));
}
static void batadv_get_ethtool_stats(struct net_device *dev,
struct ethtool_stats *stats, u64 *data)
{
struct batadv_priv *bat_priv = netdev_priv(dev);
int i;
for (i = 0; i < BATADV_CNT_NUM; i++)
data[i] = batadv_sum_counter(bat_priv, i);
}
Annotation
- Immediate include surface: `mesh-interface.h`, `main.h`, `linux/atomic.h`, `linux/bug.h`, `linux/byteorder/generic.h`, `linux/cache.h`, `linux/compiler.h`, `linux/container_of.h`.
- Detected declarations: `function batadv_skb_head_push`, `function batadv_sum_counter`, `function for_each_possible_cpu`, `function batadv_interface_set_mac_addr`, `function batadv_interface_change_mtu`, `function batadv_interface_set_rx_mode`, `function batadv_interface_rx`, `function batadv_meshif_vlan_release`, `function batadv_meshif_vlan_get`, `function batadv_meshif_create_vlan`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: pattern 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.