net/bridge/br_netlink.c
Source file repositories/reference/linux-study-clean/net/bridge/br_netlink.c
File Facts
- System
- Linux kernel
- Corpus path
net/bridge/br_netlink.c- Extension
.c- Size
- 59666 bytes
- Lines
- 2002
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/slab.hlinux/etherdevice.hnet/rtnetlink.hnet/net_namespace.hnet/sock.huapi/linux/if_bridge.hbr_private.hbr_private_stp.hbr_private_cfm.hbr_private_tunnel.hbr_private_mcast_eht.h
Detected Declarations
function __get_num_vlan_infosfunction br_get_num_vlan_infosfunction br_get_link_af_size_filteredfunction br_port_info_sizefunction br_nlmsg_sizefunction br_port_fill_attrsfunction br_fill_ifvlaninfo_rangefunction br_fill_ifvlaninfo_compressedfunction br_fill_ifvlaninfofunction br_fill_ifinfofunction br_info_notifyfunction br_ifinfo_notifyfunction br_getlinkfunction br_vlan_infofunction br_process_vlan_infofunction br_afspecfunction nla_for_each_nestedfunction br_set_port_statefunction br_set_port_flagfunction br_setportfunction br_setlinkfunction br_dellinkfunction br_validatefunction br_port_slave_changelinkfunction br_port_fill_slave_infofunction br_port_get_slave_sizefunction br_changelinkfunction br_dev_newlinkfunction br_get_sizefunction br_fill_infofunction br_get_linkxstats_sizefunction br_fill_linkxstatsfunction list_for_each_entryfunction br_netlink_initfunction br_netlink_fini
Annotated Snippet
if (vid_range_start == 0) {
goto initvars;
} else if ((v->vid - vid_range_end) == 1 &&
flags == vid_range_flags) {
vid_range_end = v->vid;
continue;
} else {
if ((vid_range_end - vid_range_start) > 0)
num_vlans += 2;
else
num_vlans += 1;
}
initvars:
vid_range_start = v->vid;
vid_range_end = v->vid;
vid_range_flags = flags;
}
if (vid_range_start != 0) {
if ((vid_range_end - vid_range_start) > 0)
num_vlans += 2;
else
num_vlans += 1;
}
return num_vlans;
}
static int br_get_num_vlan_infos(struct net_bridge_vlan_group *vg,
u32 filter_mask)
{
int num_vlans;
if (!vg)
return 0;
if (filter_mask & RTEXT_FILTER_BRVLAN)
return vg->num_vlans;
rcu_read_lock();
num_vlans = __get_num_vlan_infos(vg, filter_mask);
rcu_read_unlock();
return num_vlans;
}
static size_t br_get_link_af_size_filtered(const struct net_device *dev,
u32 filter_mask)
{
struct net_bridge_vlan_group *vg = NULL;
struct net_bridge_port *p = NULL;
struct net_bridge *br = NULL;
u32 num_cfm_peer_mep_infos;
u32 num_cfm_mep_infos;
size_t vinfo_sz = 0;
int num_vlan_infos;
rcu_read_lock();
if (netif_is_bridge_port(dev)) {
p = br_port_get_check_rcu(dev);
if (p)
vg = nbp_vlan_group_rcu(p);
} else if (netif_is_bridge_master(dev)) {
br = netdev_priv(dev);
vg = br_vlan_group_rcu(br);
}
num_vlan_infos = br_get_num_vlan_infos(vg, filter_mask);
rcu_read_unlock();
if (p && test_bit(BR_VLAN_TUNNEL_BIT, &p->flags))
vinfo_sz += br_get_vlan_tunnel_info_size(vg);
/* Each VLAN is returned in bridge_vlan_info along with flags */
vinfo_sz += num_vlan_infos * nla_total_size(sizeof(struct bridge_vlan_info));
if (p && vg && (filter_mask & RTEXT_FILTER_MST))
vinfo_sz += br_mst_info_size(vg);
if (!(filter_mask & RTEXT_FILTER_CFM_STATUS))
return vinfo_sz;
if (!br)
return vinfo_sz;
/* CFM status info must be added */
br_cfm_mep_count(br, &num_cfm_mep_infos);
br_cfm_peer_mep_count(br, &num_cfm_peer_mep_infos);
vinfo_sz += nla_total_size(0); /* IFLA_BRIDGE_CFM */
/* For each status struct the MEP instance (u32) is added */
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/slab.h`, `linux/etherdevice.h`, `net/rtnetlink.h`, `net/net_namespace.h`, `net/sock.h`, `uapi/linux/if_bridge.h`, `br_private.h`.
- Detected declarations: `function __get_num_vlan_infos`, `function br_get_num_vlan_infos`, `function br_get_link_af_size_filtered`, `function br_port_info_size`, `function br_nlmsg_size`, `function br_port_fill_attrs`, `function br_fill_ifvlaninfo_range`, `function br_fill_ifvlaninfo_compressed`, `function br_fill_ifvlaninfo`, `function br_fill_ifinfo`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.