net/bridge/br_fdb.c
Source file repositories/reference/linux-study-clean/net/bridge/br_fdb.c
File Facts
- System
- Linux kernel
- Corpus path
net/bridge/br_fdb.c- Extension
.c- Size
- 41883 bytes
- Lines
- 1641
- 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/kernel.hlinux/init.hlinux/rculist.hlinux/spinlock.hlinux/times.hlinux/netdevice.hlinux/etherdevice.hlinux/jhash.hlinux/random.hlinux/slab.hlinux/atomic.hlinux/unaligned.hlinux/if_vlan.hnet/switchdev.htrace/events/bridge.hbr_private.h
Detected Declarations
function br_fdb_initfunction br_fdb_finifunction br_fdb_hash_initfunction br_fdb_hash_finifunction longerfunction has_expiredfunction fdb_to_nudfunction fdb_fill_infofunction fdb_nlmsg_sizefunction fdb_notifyfunction fdb_add_hw_addrfunction list_for_each_entryfunction fdb_del_hw_addrfunction list_for_each_entryfunction fdb_deletefunction fdb_delete_localfunction br_fdb_find_delete_localfunction fdb_add_localfunction br_fdb_changeaddrfunction br_fdb_change_mac_addressfunction br_fdb_cleanupfunction br_fdb_delete_locals_per_vlan_portfunction br_fdb_delete_locals_per_vlanfunction br_fdb_insert_locals_per_vlan_portfunction list_for_each_entryfunction br_fdb_insert_locals_per_vlanfunction list_for_each_entryfunction br_fdb_toggle_local_vlan_0function __fdb_flush_matchesfunction br_fdb_flushfunction __ndm_state_to_fdb_flagsfunction __ndm_flags_to_fdb_flagsfunction __fdb_flush_validate_ifindexfunction br_fdb_delete_bulkfunction br_fdb_delete_by_portfunction br_fdb_fillbuffunction br_fdb_add_localfunction __fdb_mark_activefunction br_fdb_updatefunction br_fdb_dumpfunction br_fdb_getfunction fdb_handle_notifyfunction test_and_clear_bitfunction fdb_add_entryfunction __br_fdb_addfunction br_fdb_addfunction list_for_each_entryfunction fdb_delete_by_addr_and_port
Annotated Snippet
if (nla_put_u8(skb, NFEA_ACTIVITY_NOTIFY, notify_bits)) {
nla_nest_cancel(skb, nest);
goto nla_put_failure;
}
nla_nest_end(skb, nest);
}
nlmsg_end(skb, nlh);
return 0;
nla_put_failure:
nlmsg_cancel(skb, nlh);
return -EMSGSIZE;
}
static inline size_t fdb_nlmsg_size(void)
{
return NLMSG_ALIGN(sizeof(struct ndmsg))
+ nla_total_size(ETH_ALEN) /* NDA_LLADDR */
+ nla_total_size(sizeof(u32)) /* NDA_MASTER */
+ nla_total_size(sizeof(u32)) /* NDA_FLAGS_EXT */
+ nla_total_size(sizeof(u16)) /* NDA_VLAN */
+ nla_total_size(sizeof(struct nda_cacheinfo))
+ nla_total_size(0) /* NDA_FDB_EXT_ATTRS */
+ nla_total_size(sizeof(u8)); /* NFEA_ACTIVITY_NOTIFY */
}
static void fdb_notify(struct net_bridge *br,
const struct net_bridge_fdb_entry *fdb, int type,
bool swdev_notify)
{
struct net *net = dev_net(br->dev);
struct sk_buff *skb;
int err = -ENOBUFS;
if (swdev_notify)
br_switchdev_fdb_notify(br, fdb, type);
skb = nlmsg_new(fdb_nlmsg_size(), GFP_ATOMIC);
if (skb == NULL)
goto errout;
err = fdb_fill_info(skb, br, fdb, 0, 0, type, 0);
if (err < 0) {
/* -EMSGSIZE implies BUG in fdb_nlmsg_size() */
WARN_ON(err == -EMSGSIZE);
kfree_skb(skb);
goto errout;
}
rtnl_notify(skb, net, 0, RTNLGRP_NEIGH, NULL, GFP_ATOMIC);
return;
errout:
rtnl_set_sk_err(net, RTNLGRP_NEIGH, err);
}
static struct net_bridge_fdb_entry *fdb_find_rcu(struct rhashtable *tbl,
const unsigned char *addr,
__u16 vid)
{
struct net_bridge_fdb_key key;
WARN_ON_ONCE(!rcu_read_lock_held());
key.vlan_id = vid;
memcpy(key.addr.addr, addr, sizeof(key.addr.addr));
return rhashtable_lookup(tbl, &key, br_fdb_rht_params);
}
/* requires bridge hash_lock */
static struct net_bridge_fdb_entry *br_fdb_find(struct net_bridge *br,
const unsigned char *addr,
__u16 vid)
{
struct net_bridge_fdb_entry *fdb;
lockdep_assert_held_once(&br->hash_lock);
rcu_read_lock();
fdb = fdb_find_rcu(&br->fdb_hash_tbl, addr, vid);
rcu_read_unlock();
return fdb;
}
struct net_device *br_fdb_find_port(const struct net_device *br_dev,
const unsigned char *addr,
__u16 vid)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/init.h`, `linux/rculist.h`, `linux/spinlock.h`, `linux/times.h`, `linux/netdevice.h`, `linux/etherdevice.h`, `linux/jhash.h`.
- Detected declarations: `function br_fdb_init`, `function br_fdb_fini`, `function br_fdb_hash_init`, `function br_fdb_hash_fini`, `function longer`, `function has_expired`, `function fdb_to_nud`, `function fdb_fill_info`, `function fdb_nlmsg_size`, `function fdb_notify`.
- 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.