net/bridge/br_input.c
Source file repositories/reference/linux-study-clean/net/bridge/br_input.c
File Facts
- System
- Linux kernel
- Corpus path
net/bridge/br_input.c- Extension
.c- Size
- 13054 bytes
- Lines
- 486
- Domain
- Networking Core
- Bucket
- Sockets, Protocols, Packet Path, And Network Policy
- Inferred role
- Networking Core: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/slab.hlinux/kernel.hlinux/netdevice.hlinux/etherdevice.hlinux/netfilter_bridge.hnet/netfilter/nf_queue.hlinux/neighbour.hnet/arp.hnet/dsa.hlinux/export.hlinux/rculist.hbr_private.hbr_private_tunnel.h
Detected Declarations
function br_netif_receive_skbfunction br_pass_frame_upfunction br_handle_frame_finishfunction test_bitfunction br_opt_getfunction __br_handle_local_finishfunction br_handle_local_finishfunction nf_hook_bridge_prefunction br_process_frame_typefunction br_handle_framefunction okfnfunction themfunction br_add_framefunction br_del_framefunction hlist_for_each_entryexport br_handle_frame_finish
Annotated Snippet
if (p->state == BR_STATE_DISABLED) {
reason = SKB_DROP_REASON_BRIDGE_INGRESS_STP_STATE;
goto drop;
}
state = p->state;
}
brmctx = &p->br->multicast_ctx;
pmctx = &p->multicast_ctx;
if (!br_allowed_ingress(p->br, nbp_vlan_group_rcu(p), skb, &vid,
&state, &vlan))
goto out;
if (test_bit(BR_PORT_LOCKED_BIT, &p->flags)) {
struct net_bridge_fdb_entry *fdb_src =
br_fdb_find_rcu(br, eth_hdr(skb)->h_source, vid);
if (!fdb_src) {
/* FDB miss. Create locked FDB entry if MAB is enabled
* and drop the packet.
*/
if (test_bit(BR_PORT_MAB_BIT, &p->flags))
br_fdb_update(br, p, eth_hdr(skb)->h_source,
vid, BIT(BR_FDB_LOCKED));
goto drop;
} else if (READ_ONCE(fdb_src->dst) != p ||
test_bit(BR_FDB_LOCAL, &fdb_src->flags)) {
/* FDB mismatch. Drop the packet without roaming. */
goto drop;
} else if (test_bit(BR_FDB_LOCKED, &fdb_src->flags)) {
/* FDB match, but entry is locked. Refresh it and drop
* the packet.
*/
br_fdb_update(br, p, eth_hdr(skb)->h_source, vid,
BIT(BR_FDB_LOCKED));
goto drop;
}
}
nbp_switchdev_frame_mark(p, skb);
/* insert into forwarding database after filtering to avoid spoofing */
if (test_bit(BR_LEARNING_BIT, &p->flags))
br_fdb_update(br, p, eth_hdr(skb)->h_source, vid, 0);
promisc = !!(br->dev->flags & IFF_PROMISC);
local_rcv = promisc;
if (is_multicast_ether_addr(eth_hdr(skb)->h_dest)) {
/* by definition the broadcast is also a multicast address */
if (is_broadcast_ether_addr(eth_hdr(skb)->h_dest)) {
pkt_type = BR_PKT_BROADCAST;
local_rcv = true;
} else {
pkt_type = BR_PKT_MULTICAST;
if (br_multicast_rcv(&brmctx, &pmctx, vlan, skb, vid))
goto drop;
}
}
if (state == BR_STATE_LEARNING) {
reason = SKB_DROP_REASON_BRIDGE_INGRESS_STP_STATE;
goto drop;
}
BR_INPUT_SKB_CB(skb)->brdev = br->dev;
BR_INPUT_SKB_CB(skb)->src_port_isolated = test_bit(BR_ISOLATED_BIT, &p->flags);
if (IS_ENABLED(CONFIG_INET) &&
(skb->protocol == htons(ETH_P_ARP) ||
skb->protocol == htons(ETH_P_RARP))) {
br_do_proxy_suppress_arp(skb, br, vid, p);
} else if (ipv6_mod_enabled() &&
skb->protocol == htons(ETH_P_IPV6) &&
br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED) &&
pskb_may_pull(skb, sizeof(struct ipv6hdr) +
sizeof(struct nd_msg)) &&
ipv6_hdr(skb)->nexthdr == IPPROTO_ICMPV6) {
struct nd_msg *msg, _msg;
msg = br_is_nd_neigh_msg(skb, &_msg);
if (msg)
br_do_suppress_nd(skb, br, vid, p, msg);
}
switch (pkt_type) {
case BR_PKT_MULTICAST:
mdst = br_mdb_entry_skb_get(brmctx, skb, vid);
if ((mdst || BR_INPUT_SKB_CB_MROUTERS_ONLY(skb)) &&
Annotation
- Immediate include surface: `linux/slab.h`, `linux/kernel.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/netfilter_bridge.h`, `net/netfilter/nf_queue.h`, `linux/neighbour.h`, `net/arp.h`.
- Detected declarations: `function br_netif_receive_skb`, `function br_pass_frame_up`, `function br_handle_frame_finish`, `function test_bit`, `function br_opt_get`, `function __br_handle_local_finish`, `function br_handle_local_finish`, `function nf_hook_bridge_pre`, `function br_process_frame_type`, `function br_handle_frame`.
- Atlas domain: Networking Core / Sockets, Protocols, Packet Path, And Network Policy.
- Implementation status: integration 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.