net/bridge/br_vlan_options.c
Source file repositories/reference/linux-study-clean/net/bridge/br_vlan_options.c
File Facts
- System
- Linux kernel
- Corpus path
net/bridge/br_vlan_options.c- Extension
.c- Size
- 23455 bytes
- Lines
- 781
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/kernel.hlinux/netdevice.hlinux/rtnetlink.hlinux/slab.hnet/ip_tunnels.hbr_private.hbr_private_tunnel.h
Detected Declarations
function __vlan_tun_putfunction __vlan_tun_can_enter_rangefunction br_vlan_opts_eq_rangefunction br_vlan_opts_fillfunction br_vlan_opts_nl_sizefunction br_vlan_modify_statefunction br_vlan_modify_tunnelfunction br_vlan_process_one_optsfunction br_vlan_process_optionsfunction br_vlan_global_opts_can_enter_rangefunction br_vlan_global_opts_fillfunction rtnl_vlan_global_opts_nlmsg_sizefunction br_vlan_global_opts_notifyfunction br_vlan_process_global_one_optsfunction br_vlan_rtm_process_global_options
Annotated Snippet
if (!tun_tb[BRIDGE_VLANDB_TINFO_ID]) {
NL_SET_ERR_MSG_MOD(extack, "Missing tunnel id attribute");
return -ENOENT;
}
/* when working on vlan ranges this is the starting tunnel id */
tun_id = nla_get_u32(tun_tb[BRIDGE_VLANDB_TINFO_ID]);
/* vlan info attr is guaranteed by br_vlan_rtm_process_one */
vinfo = nla_data(tb[BRIDGE_VLANDB_ENTRY_INFO]);
/* tunnel ids are mapped to each vlan in increasing order,
* the starting vlan is in BRIDGE_VLANDB_ENTRY_INFO and v is the
* current vlan, so we compute: tun_id + v - vinfo->vid
*/
tun_id += v->vid - vinfo->vid;
break;
case RTM_DELLINK:
break;
default:
NL_SET_ERR_MSG_MOD(extack, "Unsupported tunnel command");
return -EINVAL;
}
return br_vlan_tunnel_info(p, cmd, v->vid, tun_id, changed);
}
static int br_vlan_process_one_opts(const struct net_bridge *br,
const struct net_bridge_port *p,
struct net_bridge_vlan_group *vg,
struct net_bridge_vlan *v,
struct nlattr **tb,
bool *changed,
struct netlink_ext_ack *extack)
{
int err;
*changed = false;
if (tb[BRIDGE_VLANDB_ENTRY_STATE]) {
u8 state = nla_get_u8(tb[BRIDGE_VLANDB_ENTRY_STATE]);
err = br_vlan_modify_state(vg, v, state, changed, extack);
if (err)
return err;
}
if (tb[BRIDGE_VLANDB_ENTRY_TUNNEL_INFO]) {
err = br_vlan_modify_tunnel(p, v, tb, changed, extack);
if (err)
return err;
}
#ifdef CONFIG_BRIDGE_IGMP_SNOOPING
if (tb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER]) {
u8 val;
val = nla_get_u8(tb[BRIDGE_VLANDB_ENTRY_MCAST_ROUTER]);
err = br_multicast_set_vlan_router(v, val);
if (err)
return err;
*changed = true;
}
if (tb[BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS]) {
u32 val;
if (!p) {
NL_SET_ERR_MSG_MOD(extack, "Can't set mcast_max_groups for non-port vlans");
return -EINVAL;
}
if (br_multicast_port_ctx_vlan_disabled(&v->port_mcast_ctx)) {
NL_SET_ERR_MSG_MOD(extack, "Multicast snooping disabled on this VLAN");
return -EINVAL;
}
val = nla_get_u32(tb[BRIDGE_VLANDB_ENTRY_MCAST_MAX_GROUPS]);
br_multicast_ngroups_set_max(&v->port_mcast_ctx, val);
*changed = true;
}
#endif
if (tb[BRIDGE_VLANDB_ENTRY_NEIGH_SUPPRESS]) {
bool enabled = v->priv_flags & BR_VLFLAG_NEIGH_SUPPRESS_ENABLED;
bool val = nla_get_u8(tb[BRIDGE_VLANDB_ENTRY_NEIGH_SUPPRESS]);
if (!p) {
NL_SET_ERR_MSG_MOD(extack, "Can't set neigh_suppress for non-port vlans");
return -EINVAL;
}
if (val != enabled) {
v->priv_flags ^= BR_VLFLAG_NEIGH_SUPPRESS_ENABLED;
*changed = true;
}
}
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/netdevice.h`, `linux/rtnetlink.h`, `linux/slab.h`, `net/ip_tunnels.h`, `br_private.h`, `br_private_tunnel.h`.
- Detected declarations: `function __vlan_tun_put`, `function __vlan_tun_can_enter_range`, `function br_vlan_opts_eq_range`, `function br_vlan_opts_fill`, `function br_vlan_opts_nl_size`, `function br_vlan_modify_state`, `function br_vlan_modify_tunnel`, `function br_vlan_process_one_opts`, `function br_vlan_process_options`, `function br_vlan_global_opts_can_enter_range`.
- 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.