net/bridge/br_netlink_tunnel.c
Source file repositories/reference/linux-study-clean/net/bridge/br_netlink_tunnel.c
File Facts
- System
- Linux kernel
- Corpus path
net/bridge/br_netlink_tunnel.c- Extension
.c- Size
- 8188 bytes
- Lines
- 343
- 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/slab.hlinux/etherdevice.hnet/rtnetlink.hnet/net_namespace.hnet/sock.huapi/linux/if_bridge.hnet/dst_metadata.hbr_private.hbr_private_tunnel.h
Detected Declarations
function __get_vlan_tinfo_sizefunction vlan_tunid_inrangefunction __get_num_vlan_tunnel_infosfunction vlan_tunid_inrangefunction br_get_vlan_tunnel_info_sizefunction br_fill_vlan_tinfofunction br_fill_vlan_tinfo_rangefunction br_fill_vlan_tunnel_infofunction vlan_tunid_inrangefunction br_vlan_tunnel_infofunction br_parse_vlan_tunnel_infofunction __vlan_tunnel_handle_rangefunction br_process_vlan_tunnel_info
Annotated Snippet
if (!vtbegin) {
goto initvars;
} else if ((v->vid - vtend->vid) == 1 &&
vlan_tunid_inrange(v, vtend)) {
vtend = v;
continue;
} else {
if ((vtend->vid - vtbegin->vid) > 0)
num_tinfos += 2;
else
num_tinfos += 1;
}
initvars:
vtbegin = v;
vtend = v;
}
if (vtbegin && vtend) {
if ((vtend->vid - vtbegin->vid) > 0)
num_tinfos += 2;
else
num_tinfos += 1;
}
return num_tinfos;
}
int br_get_vlan_tunnel_info_size(struct net_bridge_vlan_group *vg)
{
int num_tinfos;
if (!vg)
return 0;
rcu_read_lock();
num_tinfos = __get_num_vlan_tunnel_infos(vg);
rcu_read_unlock();
return num_tinfos * __get_vlan_tinfo_size();
}
static int br_fill_vlan_tinfo(struct sk_buff *skb, u16 vid,
__be64 tunnel_id, u16 flags)
{
__be32 tid = tunnel_id_to_key32(tunnel_id);
struct nlattr *tmap;
tmap = nla_nest_start_noflag(skb, IFLA_BRIDGE_VLAN_TUNNEL_INFO);
if (!tmap)
return -EMSGSIZE;
if (nla_put_u32(skb, IFLA_BRIDGE_VLAN_TUNNEL_ID,
be32_to_cpu(tid)))
goto nla_put_failure;
if (nla_put_u16(skb, IFLA_BRIDGE_VLAN_TUNNEL_VID,
vid))
goto nla_put_failure;
if (nla_put_u16(skb, IFLA_BRIDGE_VLAN_TUNNEL_FLAGS,
flags))
goto nla_put_failure;
nla_nest_end(skb, tmap);
return 0;
nla_put_failure:
nla_nest_cancel(skb, tmap);
return -EMSGSIZE;
}
static int br_fill_vlan_tinfo_range(struct sk_buff *skb,
struct net_bridge_vlan *vtbegin,
struct net_bridge_vlan *vtend)
{
int err;
if (vtend && (vtend->vid - vtbegin->vid) > 0) {
/* add range to skb */
err = br_fill_vlan_tinfo(skb, vtbegin->vid,
vtbegin->tinfo.tunnel_id,
BRIDGE_VLAN_INFO_RANGE_BEGIN);
if (err)
return err;
err = br_fill_vlan_tinfo(skb, vtend->vid,
vtend->tinfo.tunnel_id,
BRIDGE_VLAN_INFO_RANGE_END);
if (err)
return err;
} else {
err = br_fill_vlan_tinfo(skb, vtbegin->vid,
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`, `net/dst_metadata.h`.
- Detected declarations: `function __get_vlan_tinfo_size`, `function vlan_tunid_inrange`, `function __get_num_vlan_tunnel_infos`, `function vlan_tunid_inrange`, `function br_get_vlan_tunnel_info_size`, `function br_fill_vlan_tinfo`, `function br_fill_vlan_tinfo_range`, `function br_fill_vlan_tunnel_info`, `function vlan_tunid_inrange`, `function br_vlan_tunnel_info`.
- 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.