AI Trajectory


Trajectory: (Expand/Collapse All)
Seq Timestamp Type Name Duration
0/0 2026/10/01 04:45 flow patch-triage
3m Args:
null

Results:
{
  "EnableConfigs": [
    "BRIDGE",
    "BRIDGE_VLAN_FILTERING",
    "VLAN_8021Q",
    "NET_SWITCHDEV"
  ],
  "FocusSymbols": [
    "br_fdb_cleanup_by_dst",
    "br_fdb_update",
    "br_fdb_external_learn_add",
    "br_fdb_add",
    "br_forward",
    "nbp_vlan_delete",
    "nbp_vlan_group_unpublish",
    "br_vlan_delete"
  ],
  "KMSANReasoning": "The patch refactors bridge Forwarding Database (FDB) entries to support VLAN-aware destinations. It introduces a wrapper type `struct net_bridge_dst` containing a tagged pointer (`unsigned long value`) that references either a `struct net_bridge_port` or a `struct net_bridge_vlan`.\n\nKMSAN vs KASAN Applicability:\n- Uninitialized Memory Risks (KMSAN): None. `struct net_bridge_dst` consists of a single scalar field (`unsigned long value`) with no padding, and every instance created via `br_port_to_dst()`, `br_vlan_to_dst()`, or `br_dst_read()` is fully initialized before being read, copied, or stored. Local variables across callers (such as `struct br_fwd_dst`, `vid`, `vlan`, and `state`) are explicitly initialized (e.g., `br_should_learn()` sets `*vlan = NULL` at function entry; `br_allowed_ingress()` sets `*vlan` on success; `br_dst_decode()` unconditionally sets both output pointers). No kernel structures with uninitialized padding or uninitialized fields are exposed to userspace.\n- Lifetime and Concurrency Risks (KASAN/LOCKDEP): The main risks introduced by caching pointers to `struct net_bridge_vlan` inside FDB entries revolve around object lifetimes, RCU synchronization, and potential use-after-free (UAF) or race conditions during VLAN deletion (`nbp_vlan_delete`) or port unbinding (`del_nbp`). These issues fall strictly under the detection capabilities of KASAN (use-after-free) and LOCKDEP (locking/synchronization).\n\nBecause the changes do not introduce or expose uninitialized memory reads or information leaks, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false,
  "Reasoning": "The patch modifies the Linux Ethernet bridge subsystem to allow FDB (Forwarding Database) entries to point directly to VLAN destinations in addition to ports. This refactors FDB entry destination handling, introduces atomic destination replacement via cmpxchg, alters concurrency and lifetime sequencing during port and VLAN deletion with RCU unpublishing/synchronize_net(), and adds lockdep assertions. These changes affect reachable core networking code configured via netlink and exercised during bridge frame reception, forwarding, and configuration.",
  "WorthFuzzing": true
}

1/1 2026/10/01 04:45 action read-patch-diff
0m Args:
null

Results:
{
  "PatchDiff": "commit f871cd2676b17c6338ab86a38d0a4690b5626b96\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate:   Thu Oct 1 04:45:06 2026 +0000\n\n    syz-cluster: applied patch under review\n\ndiff --git a/include/trace/events/bridge.h b/include/trace/events/bridge.h\nindex 3fe4725c83ffe..f676516b33fa5 100644\n--- a/include/trace/events/bridge.h\n+++ b/include/trace/events/bridge.h\n@@ -68,13 +68,14 @@ TRACE_EVENT(br_fdb_external_learn_add,\n \n TRACE_EVENT(fdb_delete,\n \n-\tTP_PROTO(struct net_bridge *br, struct net_bridge_fdb_entry *f),\n+\tTP_PROTO(struct net_bridge *br, struct net_bridge_fdb_entry *f,\n+\t\t const struct net_bridge_port *dst),\n \n-\tTP_ARGS(br, f),\n+\tTP_ARGS(br, f, dst),\n \n \tTP_STRUCT__entry(\n \t\t__string(br_dev, br-\u003edev-\u003ename)\n-\t\t__string(dev, f-\u003edst ? f-\u003edst-\u003edev-\u003ename : \"null\")\n+\t\t__string(dev, dst ? dst-\u003edev-\u003ename : \"null\")\n \t\t__array(unsigned char, addr, ETH_ALEN)\n \t\t__field(u16, vid)\n \t),\ndiff --git a/net/bridge/br.c b/net/bridge/br.c\nindex 09a120b3b76cb..b1abe1c5bbdd2 100644\n--- a/net/bridge/br.c\n+++ b/net/bridge/br.c\n@@ -202,7 +202,7 @@ static int br_switchdev_event(struct notifier_block *unused,\n \tcase SWITCHDEV_FDB_FLUSH_TO_BRIDGE:\n \t\tfdb_info = ptr;\n \t\t/* Don't delete static entries */\n-\t\tbr_fdb_delete_by_port(br, p, fdb_info-\u003evid, 0);\n+\t\tbr_fdb_cleanup_by_dst(br, br_port_to_dst(p), fdb_info-\u003evid, 0);\n \t\tbreak;\n \t}\n \ndiff --git a/net/bridge/br_arp_nd_proxy.c b/net/bridge/br_arp_nd_proxy.c\nindex da15f4d7c1aef..ba4a63840b219 100644\n--- a/net/bridge/br_arp_nd_proxy.c\n+++ b/net/bridge/br_arp_nd_proxy.c\n@@ -223,7 +223,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,\n \t\tneigh_ha_snapshot(ha, n, n-\u003edev);\n \t\tf = br_fdb_find_rcu(br, ha, vid);\n \t\tif (f) {\n-\t\t\tconst struct net_bridge_port *dst = READ_ONCE(f-\u003edst);\n+\t\t\tconst struct net_bridge_port *dst = br_fdb_dst_port(f);\n \t\t\tbool replied = false;\n \n \t\t\tif ((p \u0026\u0026 test_bit(BR_PROXYARP_BIT, \u0026p-\u003eflags)) ||\n@@ -500,7 +500,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,\n \t\tneigh_ha_snapshot(ha, n, n-\u003edev);\n \t\tf = br_fdb_find_rcu(br, ha, vid);\n \t\tif (f) {\n-\t\t\tconst struct net_bridge_port *dst = READ_ONCE(f-\u003edst);\n+\t\t\tconst struct net_bridge_port *dst = br_fdb_dst_port(f);\n \t\t\tbool replied = false;\n \n \t\t\tif (br_is_neigh_suppress_enabled_vid(dst, vid)) {\ndiff --git a/net/bridge/br_device.c b/net/bridge/br_device.c\nindex ce9ea9ac3d0ad..0a1ce9e59a4d4 100644\n--- a/net/bridge/br_device.c\n+++ b/net/bridge/br_device.c\n@@ -65,9 +65,10 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)\n \tskb_reset_mac_header(skb);\n \tskb_pull(skb, ETH_HLEN);\n \n-\tif (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, \u0026vid,\n-\t\t\t\t\u0026state, \u0026vlan))\n+\tif (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, \u0026state,\n+\t\t\t\t\u0026vlan))\n \t\tgoto out;\n+\tvid = vlan ? vlan-\u003evid : 0;\n \n \tif (IS_ENABLED(CONFIG_INET) \u0026\u0026\n \t    (eth_hdr(skb)-\u003eh_proto == htons(ETH_P_ARP) ||\n@@ -107,7 +108,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)\n \t\telse\n \t\t\tbr_flood(br, vlan, skb, BR_PKT_MULTICAST, false, true);\n \t} else if ((dst = br_fdb_find_rcu(br, dest, vid)) != NULL) {\n-\t\tbr_forward(READ_ONCE(dst-\u003edst), skb, false, true);\n+\t\tbr_forward(br_fdb_dst_read(dst), skb, false, true);\n \t} else {\n \t\tbr_flood(br, vlan, skb, BR_PKT_UNICAST, false, true);\n \t}\n@@ -400,7 +401,7 @@ static int br_fill_forward_path(struct net_device_path_ctx *ctx,\n \tif (!f)\n \t\treturn -1;\n \n-\tdst = READ_ONCE(f-\u003edst);\n+\tdst = br_fdb_dst_port(f);\n \tif (!dst)\n \t\treturn -1;\n \ndiff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c\nindex e4570bbed8544..730b178cf6c44 100644\n--- a/net/bridge/br_fdb.c\n+++ b/net/bridge/br_fdb.c\n@@ -90,7 +90,7 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br,\n \t\t\t const struct net_bridge_fdb_entry *fdb,\n \t\t\t u32 portid, u32 seq, int type, unsigned int flags)\n {\n-\tconst struct net_bridge_port *dst = READ_ONCE(fdb-\u003edst);\n+\tconst struct net_bridge_port *dst = br_fdb_dst_port(fdb);\n \tunsigned long now = jiffies;\n \tstruct nda_cacheinfo ci;\n \tstruct nlmsghdr *nlh;\n@@ -250,7 +250,7 @@ struct net_device *br_fdb_find_port(const struct net_device *br_dev,\n \trcu_read_lock();\n \tf = br_fdb_find_rcu(br, addr, vid);\n \tif (f) {\n-\t\tdst = READ_ONCE(f-\u003edst);\n+\t\tdst = br_fdb_dst_port(f);\n \t\tif (dst)\n \t\t\tdev = dst-\u003edev;\n \t}\n@@ -315,7 +315,7 @@ static void fdb_del_hw_addr(struct net_bridge *br, const unsigned char *addr)\n static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f,\n \t\t       bool swdev_notify)\n {\n-\ttrace_fdb_delete(br, f);\n+\ttrace_fdb_delete(br, f, br_fdb_dst_port(f));\n \n \tif (test_bit(BR_FDB_STATIC, \u0026f-\u003eflags))\n \t\tfdb_del_hw_addr(br, f-\u003ekey.addr.addr);\n@@ -350,7 +350,7 @@ static void fdb_delete_local(struct net_bridge *br,\n \t\tvg = nbp_vlan_group(op);\n \t\tif (op != p \u0026\u0026 ether_addr_equal(op-\u003edev-\u003edev_addr, addr) \u0026\u0026\n \t\t    (!vid || br_vlan_find(vg, vid))) {\n-\t\t\tWRITE_ONCE(f-\u003edst, op);\n+\t\t\tbr_fdb_dst_write(f, br_port_to_dst(op));\n \t\t\tclear_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags);\n \t\t\treturn;\n \t\t}\n@@ -361,7 +361,7 @@ static void fdb_delete_local(struct net_bridge *br,\n \t/* Maybe bridge device has same hw addr? */\n \tif (p \u0026\u0026 ether_addr_equal(br-\u003edev-\u003edev_addr, addr) \u0026\u0026\n \t    (!vid || (v \u0026\u0026 br_vlan_should_use(v)))) {\n-\t\tWRITE_ONCE(f-\u003edst, NULL);\n+\t\tbr_fdb_dst_write(f, br_port_to_dst(NULL));\n \t\tclear_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags);\n \t\treturn;\n \t}\n@@ -378,13 +378,14 @@ void br_fdb_find_delete_local(struct net_bridge *br,\n \tspin_lock_bh(\u0026br-\u003ehash_lock);\n \tf = br_fdb_find(br, addr, vid);\n \tif (f \u0026\u0026 test_bit(BR_FDB_LOCAL, \u0026f-\u003eflags) \u0026\u0026\n-\t    !test_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags) \u0026\u0026 f-\u003edst == p)\n+\t    !test_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags) \u0026\u0026\n+\t    br_fdb_dst_port(f) == p)\n \t\tfdb_delete_local(br, p, f);\n \tspin_unlock_bh(\u0026br-\u003ehash_lock);\n }\n \n static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,\n-\t\t\t\t\t       struct net_bridge_port *source,\n+\t\t\t\t\t       struct net_bridge_dst dst,\n \t\t\t\t\t       const unsigned char *addr,\n \t\t\t\t\t       __u16 vid,\n \t\t\t\t\t       unsigned long flags)\n@@ -408,7 +409,7 @@ static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,\n \t\treturn NULL;\n \n \tmemcpy(fdb-\u003ekey.addr.addr, addr, ETH_ALEN);\n-\tWRITE_ONCE(fdb-\u003edst, source);\n+\tbr_fdb_dst_write(fdb, dst);\n \tfdb-\u003ekey.vlan_id = vid;\n \tfdb-\u003eflags = flags;\n \tfdb-\u003eupdated = fdb-\u003eused = jiffies;\n@@ -447,7 +448,7 @@ static int fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,\n \t\tfdb_delete(br, fdb, true);\n \t}\n \n-\tfdb = fdb_create(br, source, addr, vid,\n+\tfdb = fdb_create(br, br_port_to_dst(source), addr, vid,\n \t\t\t BIT(BR_FDB_LOCAL) | BIT(BR_FDB_STATIC));\n \tif (!fdb)\n \t\treturn -ENOMEM;\n@@ -470,7 +471,7 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)\n \tspin_lock_bh(\u0026br-\u003ehash_lock);\n \tvg = nbp_vlan_group(p);\n \thlist_for_each_entry(f, \u0026br-\u003efdb_list, fdb_node) {\n-\t\tif (READ_ONCE(f-\u003edst) == p \u0026\u0026\n+\t\tif (br_fdb_dst_port(f) == p \u0026\u0026\n \t\t    test_bit(BR_FDB_LOCAL, \u0026f-\u003eflags) \u0026\u0026\n \t\t    !test_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags)) {\n \t\t\t/* delete old one */\n@@ -517,7 +518,8 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr)\n \t/* If old entry was unassociated with any port, then delete it. */\n \tf = br_fdb_find(br, br-\u003edev-\u003edev_addr, 0);\n \tif (f \u0026\u0026 test_bit(BR_FDB_LOCAL, \u0026f-\u003eflags) \u0026\u0026\n-\t    !f-\u003edst \u0026\u0026 !test_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags))\n+\t    !br_fdb_dst_port(f) \u0026\u0026\n+\t    !test_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags))\n \t\tfdb_delete_local(br, NULL, f);\n \n \tfdb_add_local(br, NULL, newaddr, 0);\n@@ -533,7 +535,8 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr)\n \t\t\tcontinue;\n \t\tf = br_fdb_find(br, br-\u003edev-\u003edev_addr, v-\u003evid);\n \t\tif (f \u0026\u0026 test_bit(BR_FDB_LOCAL, \u0026f-\u003eflags) \u0026\u0026\n-\t\t    !f-\u003edst \u0026\u0026 !test_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags))\n+\t\t    !br_fdb_dst_port(f) \u0026\u0026\n+\t\t    !test_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags))\n \t\t\tfdb_delete_local(br, NULL, f);\n \t\tfdb_add_local(br, NULL, newaddr, v-\u003evid);\n \t}\n@@ -693,7 +696,7 @@ static bool __fdb_flush_matches(const struct net_bridge *br,\n \t\t\t\tconst struct net_bridge_fdb_entry *f,\n \t\t\t\tconst struct net_bridge_fdb_flush_desc *desc)\n {\n-\tconst struct net_bridge_port *dst = READ_ONCE(f-\u003edst);\n+\tconst struct net_bridge_port *dst = br_fdb_dst_port(f);\n \tint port_ifidx = dst ? dst-\u003edev-\u003eifindex : br-\u003edev-\u003eifindex;\n \n \tif (desc-\u003evlan_id \u0026\u0026 desc-\u003evlan_id != f-\u003ekey.vlan_id)\n@@ -865,29 +868,50 @@ int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,\n \treturn 0;\n }\n \n-/* Flush all entries referring to a specific port.\n+/* Clean up all entries referring to a specific destination.\n  * if do_all is set also flush static entries\n  * if vid is set delete all entries that match the vlan_id\n  */\n-void br_fdb_delete_by_port(struct net_bridge *br,\n-\t\t\t   const struct net_bridge_port *p,\n-\t\t\t   u16 vid,\n+void br_fdb_cleanup_by_dst(struct net_bridge *br,\n+\t\t\t   struct net_bridge_dst cleanup_dst, u16 vid,\n \t\t\t   int do_all)\n {\n+\tconst struct net_bridge_vlan *vlan = br_dst_vlan(cleanup_dst);\n+\tconst struct net_bridge_port *p = br_dst_port(cleanup_dst);\n \tstruct net_bridge_fdb_entry *f;\n \tstruct hlist_node *tmp;\n \n \tspin_lock_bh(\u0026br-\u003ehash_lock);\n \thlist_for_each_entry_safe(f, tmp, \u0026br-\u003efdb_list, fdb_node) {\n-\t\tif (READ_ONCE(f-\u003edst) != p)\n+\t\tstruct net_bridge_dst dst = br_fdb_dst_read(f);\n+\n+\t\tif (br_dst_port(dst) != p)\n+\t\t\tcontinue;\n+\n+\t\tif (vlan \u0026\u0026 f-\u003ekey.vlan_id == vlan-\u003evid \u0026\u0026\n+\t\t    test_bit(BR_FDB_LOCAL, \u0026f-\u003eflags) \u0026\u0026\n+\t\t    !test_bit(BR_FDB_ADDED_BY_USER, \u0026f-\u003eflags) \u0026\u0026\n+\t\t    ether_addr_equal(f-\u003ekey.addr.addr, p-\u003edev-\u003edev_addr)) {\n+\t\t\tfdb_delete_local(br, p, f);\n \t\t\tcontinue;\n+\t\t}\n+\n+\t\tif (!do_all) {\n+\t\t\tif (vid \u0026\u0026 f-\u003ekey.vlan_id != vid)\n+\t\t\t\tcontinue;\n \n-\t\tif (!do_all)\n \t\t\tif (test_bit(BR_FDB_STATIC, \u0026f-\u003eflags) ||\n \t\t\t    (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, \u0026f-\u003eflags) \u0026\u0026\n-\t\t\t     !test_bit(BR_FDB_OFFLOADED, \u0026f-\u003eflags)) ||\n-\t\t\t    (vid \u0026\u0026 f-\u003ekey.vlan_id != vid))\n+\t\t\t     !test_bit(BR_FDB_OFFLOADED, \u0026f-\u003eflags))) {\n+\t\t\t\t/* The entry outlives the VLAN, so it must fall\n+\t\t\t\t * back to the raw port destination\n+\t\t\t\t */\n+\t\t\t\tif (vlan \u0026\u0026 br_dst_vlan(dst) == vlan)\n+\t\t\t\t\tbr_fdb_dst_replace(f, dst,\n+\t\t\t\t\t\t\t   br_port_to_dst(p));\n \t\t\t\tcontinue;\n+\t\t\t}\n+\t\t}\n \n \t\tif (test_bit(BR_FDB_LOCAL, \u0026f-\u003eflags))\n \t\t\tfdb_delete_local(br, p, f);\n@@ -921,7 +945,7 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf,\n \t\t\tcontinue;\n \n \t\t/* ignore pseudo entry for local MAC address */\n-\t\tdst = READ_ONCE(f-\u003edst);\n+\t\tdst = br_fdb_dst_port(f);\n \t\tif (!dst)\n \t\t\tcontinue;\n \n@@ -970,10 +994,78 @@ static bool __fdb_mark_active(struct net_bridge_fdb_entry *fdb)\n \t\t  test_and_clear_bit(BR_FDB_NOTIFY_INACTIVE, \u0026fdb-\u003eflags));\n }\n \n+static void __fdb_update(struct net_bridge *br,\n+\t\t\t struct net_bridge_fdb_entry *fdb,\n+\t\t\t struct net_bridge_port *source,\n+\t\t\t struct net_bridge_dst dst,\n+\t\t\t const unsigned char *addr, u16 vid,\n+\t\t\t unsigned long flags)\n+{\n+\tstruct net_bridge_port *old_port;\n+\tstruct net_bridge_dst old_dst;\n+\tbool fdb_modified = false;\n+\tunsigned long now;\n+\n+\t/* attempt to update an entry for a local interface */\n+\tif (unlikely(test_bit(BR_FDB_LOCAL, \u0026fdb-\u003eflags))) {\n+\t\tif (net_ratelimit())\n+\t\t\tbr_warn(br, \"received packet on %s with own address as source address (addr:%pM, vlan:%u)\\n\",\n+\t\t\t\tsource-\u003edev-\u003ename, addr, vid);\n+\t\treturn;\n+\t}\n+\n+\tnow = jiffies;\n+\tif (now != READ_ONCE(fdb-\u003eupdated)) {\n+\t\tWRITE_ONCE(fdb-\u003eupdated, now);\n+\t\tfdb_modified = __fdb_mark_active(fdb);\n+\t}\n+\n+\told_dst = br_fdb_dst_read(fdb);\n+\told_port = br_dst_port(old_dst);\n+\t/* fastpath: update of existing entry */\n+\tif (unlikely(!br_dst_equal(dst, old_dst) \u0026\u0026\n+\t\t     (source == old_port ||\n+\t\t      !test_bit(BR_FDB_STICKY, \u0026fdb-\u003eflags)))) {\n+\t\tif (source != old_port) {\n+\t\t\tbr_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);\n+\t\t\tbr_fdb_dst_write(fdb, dst);\n+\t\t\tfdb_modified = true;\n+\t\t\t/* take over HW learned entry */\n+\t\t\tif (unlikely(test_bit(BR_FDB_ADDED_BY_EXT_LEARN,\n+\t\t\t\t\t      \u0026fdb-\u003eflags)))\n+\t\t\t\tclear_bit(BR_FDB_ADDED_BY_EXT_LEARN,\n+\t\t\t\t\t  \u0026fdb-\u003eflags);\n+\t\t\t/* clear locked flag when roaming to an unlocked port */\n+\t\t\tif (unlikely(test_bit(BR_FDB_LOCKED, \u0026fdb-\u003eflags)))\n+\t\t\t\tclear_bit(BR_FDB_LOCKED, \u0026fdb-\u003eflags);\n+\t\t} else {\n+\t\t\t/* raw port-to-VLAN promotion shouldn't overwrite a\n+\t\t\t * concurrent roam to another port\n+\t\t\t */\n+\t\t\tbr_fdb_dst_replace(fdb, old_dst, dst);\n+\t\t}\n+\t}\n+\n+\tif (unlikely(test_bit(BR_FDB_ADDED_BY_USER, \u0026flags))) {\n+\t\tset_bit(BR_FDB_ADDED_BY_USER, \u0026fdb-\u003eflags);\n+\t\tif (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, \u0026fdb-\u003eflags))\n+\t\t\tatomic_dec(\u0026br-\u003efdb_n_learned);\n+\t}\n+\n+\tif (unlikely(fdb_modified)) {\n+\t\ttrace_br_fdb_update(br, source, addr, vid, flags);\n+\t\tfdb_notify(br, fdb, RTM_NEWNEIGH, true);\n+\t}\n+}\n+\n void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,\n-\t\t   const unsigned char *addr, u16 vid, unsigned long flags)\n+\t\t   struct net_bridge_vlan *vlan, const unsigned char *addr,\n+\t\t   unsigned long flags)\n {\n+\tstruct net_bridge_dst dst = vlan ? br_vlan_to_dst(vlan) :\n+\t\t\t\t\t   br_port_to_dst(source);\n \tstruct net_bridge_fdb_entry *fdb;\n+\tu16 vid = vlan ? vlan-\u003evid : 0;\n \n \t/* some users want to always flood. */\n \tif (hold_time(br) == 0)\n@@ -981,59 +1073,14 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,\n \n \tfdb = fdb_find_rcu(\u0026br-\u003efdb_hash_tbl, addr, vid);\n \tif (likely(fdb)) {\n-\t\t/* attempt to update an entry for a local interface */\n-\t\tif (unlikely(test_bit(BR_FDB_LOCAL, \u0026fdb-\u003eflags))) {\n-\t\t\tif (net_ratelimit())\n-\t\t\t\tbr_warn(br, \"received packet on %s with own address as source address (addr:%pM, vlan:%u)\\n\",\n-\t\t\t\t\tsource-\u003edev-\u003ename, addr, vid);\n-\t\t} else {\n-\t\t\tunsigned long now = jiffies;\n-\t\t\tbool fdb_modified = false;\n-\n-\t\t\tif (now != READ_ONCE(fdb-\u003eupdated)) {\n-\t\t\t\tWRITE_ONCE(fdb-\u003eupdated, now);\n-\t\t\t\tfdb_modified = __fdb_mark_active(fdb);\n-\t\t\t}\n-\n-\t\t\t/* fastpath: update of existing entry */\n-\t\t\tif (unlikely(source != READ_ONCE(fdb-\u003edst) \u0026\u0026\n-\t\t\t\t     !test_bit(BR_FDB_STICKY, \u0026fdb-\u003eflags))) {\n-\t\t\t\tbr_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);\n-\t\t\t\tWRITE_ONCE(fdb-\u003edst, source);\n-\t\t\t\tfdb_modified = true;\n-\t\t\t\t/* Take over HW learned entry */\n-\t\t\t\tif (unlikely(test_bit(BR_FDB_ADDED_BY_EXT_LEARN,\n-\t\t\t\t\t\t      \u0026fdb-\u003eflags)))\n-\t\t\t\t\tclear_bit(BR_FDB_ADDED_BY_EXT_LEARN,\n-\t\t\t\t\t\t  \u0026fdb-\u003eflags);\n-\t\t\t\t/* Clear locked flag when roaming to an\n-\t\t\t\t * unlocked port.\n-\t\t\t\t */\n-\t\t\t\tif (unlikely(test_bit(BR_FDB_LOCKED, \u0026fdb-\u003eflags)))\n-\t\t\t\t\tclear_bit(BR_FDB_LOCKED, \u0026fdb-\u003eflags);\n-\t\t\t}\n-\n-\t\t\tif (unlikely(test_bit(BR_FDB_ADDED_BY_USER, \u0026flags))) {\n-\t\t\t\tset_bit(BR_FDB_ADDED_BY_USER, \u0026fdb-\u003eflags);\n-\t\t\t\tif (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED,\n-\t\t\t\t\t\t       \u0026fdb-\u003eflags))\n-\t\t\t\t\tatomic_dec(\u0026br-\u003efdb_n_learned);\n-\t\t\t}\n-\t\t\tif (unlikely(fdb_modified)) {\n-\t\t\t\ttrace_br_fdb_update(br, source, addr, vid, flags);\n-\t\t\t\tfdb_notify(br, fdb, RTM_NEWNEIGH, true);\n-\t\t\t}\n-\t\t}\n+\t\t__fdb_update(br, fdb, source, dst, addr, vid, flags);\n \t} else {\n \t\tspin_lock(\u0026br-\u003ehash_lock);\n-\t\tfdb = fdb_create(br, source, addr, vid, flags);\n+\t\tfdb = fdb_create(br, dst, addr, vid, flags);\n \t\tif (fdb) {\n \t\t\ttrace_br_fdb_update(br, source, addr, vid, flags);\n \t\t\tfdb_notify(br, fdb, RTM_NEWNEIGH, true);\n \t\t}\n-\t\t/* else  we lose race and someone else inserts\n-\t\t * it first, don't bother updating\n-\t\t */\n \t\tspin_unlock(\u0026br-\u003ehash_lock);\n \t}\n }\n@@ -1061,17 +1108,17 @@ int br_fdb_dump(struct sk_buff *skb,\n \n \trcu_read_lock();\n \thlist_for_each_entry_rcu(f, \u0026br-\u003efdb_list, fdb_node) {\n-\t\tconst struct net_bridge_port *dst = READ_ONCE(f-\u003edst);\n+\t\tconst struct net_bridge_port *dst = br_fdb_dst_port(f);\n \n \t\tif (*idx \u003c ctx-\u003efdb_idx)\n \t\t\tgoto skip;\n \t\tif (filter_dev \u0026\u0026 (!dst || dst-\u003edev != filter_dev)) {\n \t\t\tif (filter_dev != dev)\n \t\t\t\tgoto skip;\n-\t\t\t/* !f-\u003edst is a special case for bridge\n+\t\t\t/* A NULL destination is a special case for bridge\n \t\t\t * It means the MAC belongs to the bridge\n \t\t\t * Therefore need a little more filtering\n-\t\t\t * we only want to dump the !f-\u003edst case\n+\t\t\t * we only want to dump the NULL destination case\n \t\t\t */\n \t\t\tif (dst)\n \t\t\t\tgoto skip;\n@@ -1145,10 +1192,11 @@ static bool fdb_handle_notify(struct net_bridge_fdb_entry *fdb, u8 notify)\n }\n \n /* Update (create or replace) forwarding database entry */\n-static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source,\n+static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,\n \t\t\t const u8 *addr, struct ndmsg *ndm, u16 flags, u16 vid,\n \t\t\t struct nlattr *nfea_tb[])\n {\n+\tstruct net_bridge_port *source = br_dst_port(dst);\n \tbool is_sticky = !!(ndm-\u003endm_flags \u0026 NTF_STICKY);\n \tbool refresh = !nfea_tb[NFEA_DONT_REFRESH];\n \tstruct net_bridge_fdb_entry *fdb;\n@@ -1183,19 +1231,26 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source,\n \t\tif (!(flags \u0026 NLM_F_CREATE))\n \t\t\treturn -ENOENT;\n \n-\t\tfdb = fdb_create(br, source, addr, vid,\n+\t\tfdb = fdb_create(br, dst, addr, vid,\n \t\t\t\t BIT(BR_FDB_ADDED_BY_USER));\n \t\tif (!fdb)\n \t\t\treturn -ENOMEM;\n \n \t\tmodified = true;\n \t} else {\n+\t\tstruct net_bridge_dst old_dst;\n+\n \t\tif (flags \u0026 NLM_F_EXCL)\n \t\t\treturn -EEXIST;\n \n-\t\tif (READ_ONCE(fdb-\u003edst) != source) {\n-\t\t\tWRITE_ONCE(fdb-\u003edst, source);\n-\t\t\tmodified = true;\n+\t\told_dst = br_fdb_dst_read(fdb);\n+\t\tif (!br_dst_equal(old_dst, dst)) {\n+\t\t\tif (br_dst_port(old_dst) != source) {\n+\t\t\t\tmodified = true;\n+\t\t\t\tbr_fdb_dst_write(fdb, dst);\n+\t\t\t} else {\n+\t\t\t\tbr_fdb_dst_replace(fdb, old_dst, dst);\n+\t\t\t}\n \t\t}\n \n \t\tset_bit(BR_FDB_ADDED_BY_USER, \u0026fdb-\u003eflags);\n@@ -1244,9 +1299,12 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source,\n \n static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,\n \t\t\tstruct net_bridge_port *p, const unsigned char *addr,\n-\t\t\tu16 nlh_flags, u16 vid, struct nlattr *nfea_tb[],\n+\t\t\tu16 nlh_flags, struct net_bridge_vlan *vlan,\n+\t\t\tstruct nlattr *nfea_tb[],\n \t\t\tbool *notified, struct netlink_ext_ack *extack)\n {\n+\tu16 vid = vlan ? vlan-\u003evid : 0;\n+\tstruct net_bridge_dst dst;\n \tint err = 0;\n \n \tif (ndm-\u003endm_flags \u0026 NTF_USE) {\n@@ -1260,7 +1318,7 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,\n \n \t\tlocal_bh_disable();\n \t\trcu_read_lock();\n-\t\tbr_fdb_update(br, p, addr, vid, BIT(BR_FDB_ADDED_BY_USER));\n+\t\tbr_fdb_update(br, p, vlan, addr, BIT(BR_FDB_ADDED_BY_USER));\n \t\trcu_read_unlock();\n \t\tlocal_bh_enable();\n \t} else if (ndm-\u003endm_flags \u0026 NTF_EXT_LEARNED) {\n@@ -1271,8 +1329,10 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,\n \t\t}\n \t\terr = br_fdb_external_learn_add(br, p, addr, vid, false, true);\n \t} else {\n+\t\tdst = p \u0026\u0026 vlan ? br_vlan_to_dst(vlan) : br_port_to_dst(p);\n \t\tspin_lock_bh(\u0026br-\u003ehash_lock);\n-\t\terr = fdb_add_entry(br, p, addr, ndm, nlh_flags, vid, nfea_tb);\n+\t\terr = fdb_add_entry(br, dst, addr, ndm, nlh_flags, vid,\n+\t\t\t\t    nfea_tb);\n \t\tspin_unlock_bh(\u0026br-\u003ehash_lock);\n \t}\n \n@@ -1352,10 +1412,10 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],\n \t\t}\n \n \t\t/* VID was specified, so use it. */\n-\t\terr = __br_fdb_add(ndm, br, p, addr, nlh_flags, vid, nfea_tb,\n+\t\terr = __br_fdb_add(ndm, br, p, addr, nlh_flags, v, nfea_tb,\n \t\t\t\t   notified, extack);\n \t} else {\n-\t\terr = __br_fdb_add(ndm, br, p, addr, nlh_flags, 0, nfea_tb,\n+\t\terr = __br_fdb_add(ndm, br, p, addr, nlh_flags, NULL, nfea_tb,\n \t\t\t\t   notified, extack);\n \t\tif (err || !vg || !vg-\u003enum_vlans)\n \t\t\tgoto out;\n@@ -1367,7 +1427,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],\n \t\tlist_for_each_entry(v, \u0026vg-\u003evlan_list, vlist) {\n \t\t\tif (!br_vlan_should_use(v))\n \t\t\t\tcontinue;\n-\t\t\terr = __br_fdb_add(ndm, br, p, addr, nlh_flags, v-\u003evid,\n+\t\t\terr = __br_fdb_add(ndm, br, p, addr, nlh_flags, v,\n \t\t\t\t\t   nfea_tb, notified, extack);\n \t\t\tif (err)\n \t\t\t\tgoto out;\n@@ -1385,7 +1445,7 @@ static int fdb_delete_by_addr_and_port(struct net_bridge *br,\n \tstruct net_bridge_fdb_entry *fdb;\n \n \tfdb = br_fdb_find(br, addr, vlan);\n-\tif (!fdb || READ_ONCE(fdb-\u003edst) != p)\n+\tif (!fdb || br_fdb_dst_port(fdb) != p)\n \t\treturn -ENOENT;\n \n \tfdb_delete(br, fdb, true);\n@@ -1504,10 +1564,31 @@ void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p)\n \trcu_read_unlock();\n }\n \n+static struct net_bridge_dst br_fdb_resolve_dst(const struct net_bridge_port *p,\n+\t\t\t\t\t\tu16 vid)\n+{\n+\tstruct net_bridge_dst dst = br_port_to_dst(p);\n+\tstruct net_bridge_vlan *v;\n+\n+\tlockdep_assert(rcu_read_lock_held() || lockdep_rtnl_is_held());\n+\n+\tif (!p || !vid)\n+\t\treturn dst;\n+\n+\trcu_read_lock();\n+\tv = br_vlan_find(nbp_vlan_group_rcu(p), vid);\n+\tif (v)\n+\t\tdst = br_vlan_to_dst(v);\n+\trcu_read_unlock();\n+\n+\treturn dst;\n+}\n+\n int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,\n \t\t\t      const unsigned char *addr, u16 vid, bool locked,\n \t\t\t      bool swdev_notify)\n {\n+\tstruct net_bridge_dst dst = br_fdb_resolve_dst(p, vid);\n \tstruct net_bridge_fdb_entry *fdb;\n \tbool modified = false;\n \tint err = 0;\n@@ -1532,25 +1613,32 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,\n \t\tif (locked)\n \t\t\tflags |= BIT(BR_FDB_LOCKED);\n \n-\t\tfdb = fdb_create(br, p, addr, vid, flags);\n+\t\tfdb = fdb_create(br, dst, addr, vid, flags);\n \t\tif (!fdb) {\n \t\t\terr = -ENOMEM;\n \t\t\tgoto err_unlock;\n \t\t}\n \t\tfdb_notify(br, fdb, RTM_NEWNEIGH, swdev_notify);\n \t} else {\n+\t\tstruct net_bridge_dst old_dst;\n+\n+\t\told_dst = br_fdb_dst_read(fdb);\n \t\tif (locked \u0026\u0026\n \t\t    (!test_bit(BR_FDB_LOCKED, \u0026fdb-\u003eflags) ||\n-\t\t     READ_ONCE(fdb-\u003edst) != p)) {\n+\t\t     br_dst_port(old_dst) != p)) {\n \t\t\terr = -EINVAL;\n \t\t\tgoto err_unlock;\n \t\t}\n \n \t\tWRITE_ONCE(fdb-\u003eupdated, jiffies);\n \n-\t\tif (READ_ONCE(fdb-\u003edst) != p) {\n-\t\t\tWRITE_ONCE(fdb-\u003edst, p);\n-\t\t\tmodified = true;\n+\t\tif (!br_dst_equal(old_dst, dst)) {\n+\t\t\tif (br_dst_port(old_dst) != p) {\n+\t\t\t\tmodified = true;\n+\t\t\t\tbr_fdb_dst_write(fdb, dst);\n+\t\t\t} else {\n+\t\t\t\tbr_fdb_dst_replace(fdb, old_dst, dst);\n+\t\t\t}\n \t\t}\n \n \t\tif (test_and_set_bit(BR_FDB_ADDED_BY_EXT_LEARN, \u0026fdb-\u003eflags)) {\n@@ -1632,7 +1720,7 @@ void br_fdb_clear_offload(const struct net_device *dev, u16 vid)\n \n \tspin_lock_bh(\u0026p-\u003ebr-\u003ehash_lock);\n \thlist_for_each_entry(f, \u0026p-\u003ebr-\u003efdb_list, fdb_node) {\n-\t\tif (READ_ONCE(f-\u003edst) == p \u0026\u0026 f-\u003ekey.vlan_id == vid)\n+\t\tif (br_fdb_dst_port(f) == p \u0026\u0026 f-\u003ekey.vlan_id == vid)\n \t\t\tclear_bit(BR_FDB_OFFLOADED, \u0026f-\u003eflags);\n \t}\n \tspin_unlock_bh(\u0026p-\u003ebr-\u003ehash_lock);\ndiff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c\nindex b5eece1ff9e8c..82645db32efbe 100644\n--- a/net/bridge/br_forward.c\n+++ b/net/bridge/br_forward.c\n@@ -17,7 +17,7 @@\n #include \"br_private.h\"\n \n struct br_fwd_dst {\n-\tconst struct net_bridge_port *port;\n+\tstruct net_bridge_port *port;\n \tstruct net_bridge_vlan *vlan;\n };\n \n@@ -149,35 +149,37 @@ static int deliver_clone(const struct br_fwd_dst *fwd,\n \n /**\n  * br_forward - forward a packet to a specific port\n- * @to: destination port\n+ * @dst: bridge destination\n  * @skb: packet being forwarded\n  * @local_rcv: packet will be received locally after forwarding\n  * @local_orig: packet is locally originated\n  *\n  * Should be called with rcu_read_lock.\n  */\n-void br_forward(const struct net_bridge_port *to,\n+void br_forward(struct net_bridge_dst dst,\n \t\tstruct sk_buff *skb, bool local_rcv, bool local_orig)\n {\n \tstruct br_fwd_dst fwd;\n \n-\tif (unlikely(!to))\n+\tbr_dst_decode(dst, \u0026fwd.port, \u0026fwd.vlan);\n+\n+\tif (unlikely(!fwd.port))\n \t\tgoto out;\n \n \t/* redirect to backup link if the destination port is down */\n-\tif (rcu_access_pointer(to-\u003ebackup_port) \u0026\u0026\n-\t    (!netif_carrier_ok(to-\u003edev) || !netif_running(to-\u003edev))) {\n+\tif (rcu_access_pointer(fwd.port-\u003ebackup_port) \u0026\u0026\n+\t    (!netif_carrier_ok(fwd.port-\u003edev) ||\n+\t     !netif_running(fwd.port-\u003edev))) {\n \t\tstruct net_bridge_port *backup_port;\n \n-\t\tbackup_port = rcu_dereference(to-\u003ebackup_port);\n+\t\tbackup_port = rcu_dereference(fwd.port-\u003ebackup_port);\n \t\tif (unlikely(!backup_port))\n \t\t\tgoto out;\n-\t\tBR_INPUT_SKB_CB(skb)-\u003ebackup_nhid = READ_ONCE(to-\u003ebackup_nhid);\n-\t\tto = backup_port;\n+\t\tBR_INPUT_SKB_CB(skb)-\u003ebackup_nhid = READ_ONCE(fwd.port-\u003ebackup_nhid);\n+\t\tfwd.port = backup_port;\n+\t\tfwd.vlan = NULL;\n \t}\n \n-\tfwd.port = to;\n-\tfwd.vlan = NULL;\n \tif (should_deliver(\u0026fwd, skb)) {\n \t\tif (local_rcv)\n \t\t\tdeliver_clone(\u0026fwd, skb, local_orig);\ndiff --git a/net/bridge/br_if.c b/net/bridge/br_if.c\nindex c52613431f886..2c05ebc1299d1 100644\n--- a/net/bridge/br_if.c\n+++ b/net/bridge/br_if.c\n@@ -333,8 +333,9 @@ static void update_headroom(struct net_bridge *br, int new_hr)\n  */\n static void del_nbp(struct net_bridge_port *p)\n {\n-\tstruct net_bridge *br = p-\u003ebr;\n+\tstruct net_bridge_vlan_group *vg;\n \tstruct net_device *dev = p-\u003edev;\n+\tstruct net_bridge *br = p-\u003ebr;\n \n \tsysfs_remove_link(br-\u003eifobj, p-\u003edev-\u003ename);\n \n@@ -354,8 +355,10 @@ static void del_nbp(struct net_bridge_port *p)\n \t\tupdate_headroom(br, get_max_headroom(br));\n \tnetdev_reset_rx_headroom(dev);\n \n-\tnbp_vlan_flush(p);\n-\tbr_fdb_delete_by_port(br, p, 0, 1);\n+\tvg = nbp_vlan_group(p);\n+\tnbp_vlan_group_unpublish(p);\n+\tbr_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 1);\n+\tnbp_vlan_flush(p, vg);\n \tswitchdev_deferred_process();\n \tnbp_backup_clear(p);\n \n@@ -390,7 +393,7 @@ void br_dev_delete(struct net_device *dev, struct list_head *head)\n \tbr_mst_uninit(br);\n \tbr_recalculate_neigh_suppress_enabled(br);\n \n-\tbr_fdb_delete_by_port(br, NULL, 0, 1);\n+\tbr_fdb_cleanup_by_dst(br, br_port_to_dst(NULL), 0, 1);\n \n \ttimer_shutdown_sync(\u0026br-\u003ehello_timer);\n \ttimer_shutdown_sync(\u0026br-\u003etopology_change_timer);\n@@ -696,7 +699,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,\n \tif (fdb_synced)\n \t\tbr_fdb_unsync_static(br, p);\n \tlist_del_rcu(\u0026p-\u003elist);\n-\tbr_fdb_delete_by_port(br, p, 0, 1);\n+\tbr_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 1);\n \tnbp_update_port_count(br);\n \tnetdev_upper_dev_unlink(dev, br-\u003edev);\n err5:\ndiff --git a/net/bridge/br_input.c b/net/bridge/br_input.c\nindex 4357d78524a68..fc2e381c4fe03 100644\n--- a/net/bridge/br_input.c\n+++ b/net/bridge/br_input.c\n@@ -86,8 +86,8 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb\n \tstruct net_bridge_vlan *vlan;\n \tstruct net_bridge *br;\n \tbool promisc;\n-\tu16 vid = 0;\n \tu8 state;\n+\tu16 vid;\n \n \tif (!p)\n \t\tgoto drop;\n@@ -107,9 +107,10 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb\n \n \tbrmctx = \u0026p-\u003ebr-\u003emulticast_ctx;\n \tpmctx = \u0026p-\u003emulticast_ctx;\n-\tif (!br_allowed_ingress(p-\u003ebr, nbp_vlan_group_rcu(p), skb, \u0026vid,\n-\t\t\t\t\u0026state, \u0026vlan))\n+\tif (!br_allowed_ingress(p-\u003ebr, nbp_vlan_group_rcu(p), skb, \u0026state,\n+\t\t\t\t\u0026vlan))\n \t\tgoto out;\n+\tvid = vlan ? vlan-\u003evid : 0;\n \n \tif (test_bit(BR_PORT_LOCKED_BIT, \u0026p-\u003eflags)) {\n \t\tstruct net_bridge_fdb_entry *fdb_src =\n@@ -120,10 +121,11 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb\n \t\t\t * and drop the packet.\n \t\t\t */\n \t\t\tif (test_bit(BR_PORT_MAB_BIT, \u0026p-\u003eflags))\n-\t\t\t\tbr_fdb_update(br, p, eth_hdr(skb)-\u003eh_source,\n-\t\t\t\t\t      vid, BIT(BR_FDB_LOCKED));\n+\t\t\t\tbr_fdb_update(br, p, vlan,\n+\t\t\t\t\t      eth_hdr(skb)-\u003eh_source,\n+\t\t\t\t\t      BIT(BR_FDB_LOCKED));\n \t\t\tgoto drop;\n-\t\t} else if (READ_ONCE(fdb_src-\u003edst) != p ||\n+\t\t} else if (br_fdb_dst_port(fdb_src) != p ||\n \t\t\t   test_bit(BR_FDB_LOCAL, \u0026fdb_src-\u003eflags)) {\n \t\t\t/* FDB mismatch. Drop the packet without roaming. */\n \t\t\tgoto drop;\n@@ -131,7 +133,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb\n \t\t\t/* FDB match, but entry is locked. Refresh it and drop\n \t\t\t * the packet.\n \t\t\t */\n-\t\t\tbr_fdb_update(br, p, eth_hdr(skb)-\u003eh_source, vid,\n+\t\t\tbr_fdb_update(br, p, vlan, eth_hdr(skb)-\u003eh_source,\n \t\t\t\t      BIT(BR_FDB_LOCKED));\n \t\t\tgoto drop;\n \t\t}\n@@ -141,7 +143,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb\n \n \t/* insert into forwarding database after filtering to avoid spoofing */\n \tif (test_bit(BR_LEARNING_BIT, \u0026p-\u003eflags))\n-\t\tbr_fdb_update(br, p, eth_hdr(skb)-\u003eh_source, vid, 0);\n+\t\tbr_fdb_update(br, p, vlan, eth_hdr(skb)-\u003eh_source, 0);\n \n \tpromisc = !!(br-\u003edev-\u003eflags \u0026 IFF_PROMISC);\n \tlocal_rcv = promisc;\n@@ -223,7 +225,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb\n \n \t\tif (now != READ_ONCE(dst-\u003eused))\n \t\t\tWRITE_ONCE(dst-\u003eused, now);\n-\t\tbr_forward(READ_ONCE(dst-\u003edst), skb, local_rcv, false);\n+\t\tbr_forward(br_fdb_dst_read(dst), skb, local_rcv, false);\n \t} else {\n \t\tif (!mcast_hit)\n \t\t\tbr_flood(br, vlan, skb, pkt_type, local_rcv, false);\n@@ -245,14 +247,14 @@ EXPORT_SYMBOL_GPL(br_handle_frame_finish);\n static void __br_handle_local_finish(struct sk_buff *skb)\n {\n \tstruct net_bridge_port *p = br_port_get_rcu(skb-\u003edev);\n-\tu16 vid = 0;\n+\tstruct net_bridge_vlan *vlan;\n \n \t/* check if vlan is allowed, to avoid spoofing */\n \tif (test_bit(BR_LEARNING_BIT, \u0026p-\u003eflags) \u0026\u0026\n \t    nbp_state_should_learn(p) \u0026\u0026\n \t    !br_opt_get(p-\u003ebr, BROPT_NO_LL_LEARN) \u0026\u0026\n-\t    br_should_learn(p, skb, \u0026vid))\n-\t\tbr_fdb_update(p-\u003ebr, p, eth_hdr(skb)-\u003eh_source, vid, 0);\n+\t    br_should_learn(p, skb, \u0026vlan))\n+\t\tbr_fdb_update(p-\u003ebr, p, vlan, eth_hdr(skb)-\u003eh_source, 0);\n }\n \n /* note: already called with rcu_read_lock */\ndiff --git a/net/bridge/br_mrp.c b/net/bridge/br_mrp.c\nindex dce6efa96c4c6..c8cd5b4f3af8f 100644\n--- a/net/bridge/br_mrp.c\n+++ b/net/bridge/br_mrp.c\n@@ -1219,11 +1219,11 @@ static int br_mrp_rcv(struct net_bridge_port *p,\n \n forward:\n \tif (p_dst)\n-\t\tbr_forward(p_dst, skb, true, false);\n+\t\tbr_forward(br_port_to_dst(p_dst), skb, true, false);\n \tif (s_dst)\n-\t\tbr_forward(s_dst, skb, true, false);\n+\t\tbr_forward(br_port_to_dst(s_dst), skb, true, false);\n \tif (i_dst)\n-\t\tbr_forward(i_dst, skb, true, false);\n+\t\tbr_forward(br_port_to_dst(i_dst), skb, true, false);\n \n no_forward:\n \treturn 1;\ndiff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c\nindex ae76df0de05a0..f65b8b6ca97c0 100644\n--- a/net/bridge/br_netlink.c\n+++ b/net/bridge/br_netlink.c\n@@ -1044,7 +1044,7 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[],\n \t}\n \n \tif (tb[IFLA_BRPORT_FLUSH])\n-\t\tbr_fdb_delete_by_port(p-\u003ebr, p, 0, 0);\n+\t\tbr_fdb_cleanup_by_dst(p-\u003ebr, br_port_to_dst(p), 0, 0);\n \n #ifdef CONFIG_BRIDGE_IGMP_SNOOPING\n \tif (tb[IFLA_BRPORT_MULTICAST_ROUTER]) {\ndiff --git a/net/bridge/br_private.h b/net/bridge/br_private.h\nindex 67117fb3dc880..05921192ebda1 100644\n--- a/net/bridge/br_private.h\n+++ b/net/bridge/br_private.h\n@@ -306,9 +306,15 @@ struct net_bridge_fdb_key {\n \tu16 vlan_id;\n };\n \n+#define BR_DST_VLAN_TAG\tBIT(0)\n+\n+struct net_bridge_dst {\n+\tunsigned long __private value;\n+};\n+\n struct net_bridge_fdb_entry {\n \tstruct rhash_head\t\trhnode;\n-\tstruct net_bridge_port\t\t*dst;\n+\tstruct net_bridge_dst\t\tdst;\n \n \tstruct net_bridge_fdb_key\tkey;\n \tstruct hlist_node\t\tfdb_node;\n@@ -670,6 +676,122 @@ struct br_input_skb_cb {\n #define br_debug(br, format, args...)\t\t\t\\\n \tpr_debug(\"%s: \" format,  (br)-\u003edev-\u003ename, ##args)\n \n+static inline struct net_bridge_dst\n+br_dst_read(const struct net_bridge_dst *src)\n+{\n+\tstruct net_bridge_dst dst;\n+\n+\tACCESS_PRIVATE(\u0026dst, value) =\n+\t\tREAD_ONCE(ACCESS_PRIVATE(src, value));\n+\n+\treturn dst;\n+}\n+\n+static inline void br_dst_write(struct net_bridge_dst *dst,\n+\t\t\t\tstruct net_bridge_dst src)\n+{\n+\tWRITE_ONCE(ACCESS_PRIVATE(dst, value),\n+\t\t   ACCESS_PRIVATE(\u0026src, value));\n+}\n+\n+static inline bool br_dst_equal(struct net_bridge_dst dst1,\n+\t\t\t\tstruct net_bridge_dst dst2)\n+{\n+\treturn ACCESS_PRIVATE(\u0026dst1, value) ==\n+\t       ACCESS_PRIVATE(\u0026dst2, value);\n+}\n+\n+static inline struct net_bridge_dst\n+br_port_to_dst(const struct net_bridge_port *p)\n+{\n+\tstruct net_bridge_dst dst;\n+\n+\tACCESS_PRIVATE(\u0026dst, value) = (unsigned long)p;\n+\n+\treturn dst;\n+}\n+\n+static inline struct net_bridge_dst\n+br_vlan_to_dst(const struct net_bridge_vlan *v)\n+{\n+\tstruct net_bridge_dst dst;\n+\n+\tACCESS_PRIVATE(\u0026dst, value) = (unsigned long)v | BR_DST_VLAN_TAG;\n+\n+\treturn dst;\n+}\n+\n+static inline void br_dst_decode(struct net_bridge_dst dst,\n+\t\t\t\t struct net_bridge_port **port,\n+\t\t\t\t struct net_bridge_vlan **vlan)\n+{\n+\tstruct net_bridge_vlan *v;\n+\tunsigned long value;\n+\n+\tvalue = ACCESS_PRIVATE(\u0026dst, value);\n+\tif (!(value \u0026 BR_DST_VLAN_TAG)) {\n+\t\t*port = (struct net_bridge_port *)value;\n+\t\t*vlan = NULL;\n+\t\treturn;\n+\t}\n+\n+\tv = (struct net_bridge_vlan *)(value \u0026 ~BR_DST_VLAN_TAG);\n+\t*port = v-\u003eport;\n+\t*vlan = v;\n+}\n+\n+static inline struct net_bridge_port *\n+br_dst_port(struct net_bridge_dst dst)\n+{\n+\tstruct net_bridge_port *p;\n+\tstruct net_bridge_vlan *v;\n+\n+\tbr_dst_decode(dst, \u0026p, \u0026v);\n+\n+\treturn p;\n+}\n+\n+static inline struct net_bridge_vlan *\n+br_dst_vlan(struct net_bridge_dst dst)\n+{\n+\tunsigned long value;\n+\n+\tvalue = ACCESS_PRIVATE(\u0026dst, value);\n+\tif (!(value \u0026 BR_DST_VLAN_TAG))\n+\t\treturn NULL;\n+\n+\treturn (struct net_bridge_vlan *)(value \u0026 ~BR_DST_VLAN_TAG);\n+}\n+\n+static inline struct net_bridge_dst\n+br_fdb_dst_read(const struct net_bridge_fdb_entry *fdb)\n+{\n+\treturn br_dst_read(\u0026fdb-\u003edst);\n+}\n+\n+static inline void br_fdb_dst_write(struct net_bridge_fdb_entry *fdb,\n+\t\t\t\t    struct net_bridge_dst dst)\n+{\n+\tbr_dst_write(\u0026fdb-\u003edst, dst);\n+}\n+\n+static inline bool\n+br_fdb_dst_replace(struct net_bridge_fdb_entry *fdb,\n+\t\t   struct net_bridge_dst old,\n+\t\t   struct net_bridge_dst new)\n+{\n+\tunsigned long old_value = ACCESS_PRIVATE(\u0026old, value);\n+\n+\treturn cmpxchg(\u0026ACCESS_PRIVATE(\u0026fdb-\u003edst, value), old_value,\n+\t\t       ACCESS_PRIVATE(\u0026new, value)) == old_value;\n+}\n+\n+static inline struct net_bridge_port *\n+br_fdb_dst_port(const struct net_bridge_fdb_entry *fdb)\n+{\n+\treturn br_dst_port(br_fdb_dst_read(fdb));\n+}\n+\n /* called under bridge lock */\n static inline int br_is_root_bridge(const struct net_bridge *br)\n {\n@@ -879,8 +1001,8 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr);\n void br_fdb_cleanup(struct work_struct *work);\n int br_fdb_toggle_local_vlan_0(struct net_bridge *br, bool on,\n \t\t\t       struct netlink_ext_ack *extack);\n-void br_fdb_delete_by_port(struct net_bridge *br,\n-\t\t\t   const struct net_bridge_port *p, u16 vid, int do_all);\n+void br_fdb_cleanup_by_dst(struct net_bridge *br,\n+\t\t\t   struct net_bridge_dst dst, u16 vid, int do_all);\n struct net_bridge_fdb_entry *br_fdb_find_rcu(struct net_bridge *br,\n \t\t\t\t\t     const unsigned char *addr,\n \t\t\t\t\t     __u16 vid);\n@@ -889,7 +1011,8 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf, unsigned long count,\n int br_fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,\n \t\t     const unsigned char *addr, u16 vid);\n void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,\n-\t\t   const unsigned char *addr, u16 vid, unsigned long flags);\n+\t\t   struct net_bridge_vlan *vlan, const unsigned char *addr,\n+\t\t   unsigned long flags);\n \n int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],\n \t\t  struct net_device *dev, const unsigned char *addr, u16 vid,\n@@ -922,7 +1045,7 @@ enum br_pkt_type {\n \tBR_PKT_BROADCAST\n };\n int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb);\n-void br_forward(const struct net_bridge_port *to, struct sk_buff *skb,\n+void br_forward(struct net_bridge_dst dst, struct sk_buff *skb,\n \t\tbool local_rcv, bool local_orig);\n int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb);\n void br_flood(struct net_bridge *br, struct net_bridge_vlan *v,\n@@ -1598,11 +1721,11 @@ br_multicast_ctx_options_equal(const struct net_bridge_mcast *brmctx1,\n #ifdef CONFIG_BRIDGE_VLAN_FILTERING\n bool br_allowed_ingress(const struct net_bridge *br,\n \t\t\tstruct net_bridge_vlan_group *vg, struct sk_buff *skb,\n-\t\t\tu16 *vid, u8 *state,\n-\t\t\tstruct net_bridge_vlan **vlan);\n+\t\t\tu8 *state, struct net_bridge_vlan **vlan);\n bool br_allowed_egress(struct net_bridge_vlan_group *vg,\n \t\t       const struct sk_buff *skb);\n-bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid);\n+bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb,\n+\t\t     struct net_bridge_vlan **vlan);\n struct sk_buff *br_handle_vlan(struct net_bridge *br,\n \t\t\t       const struct net_bridge_port *port,\n \t\t\t       struct net_bridge_vlan_group *vg,\n@@ -1630,7 +1753,9 @@ int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid,\n int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,\n \t\t bool *changed, struct netlink_ext_ack *extack);\n int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);\n-void nbp_vlan_flush(struct net_bridge_port *port);\n+void nbp_vlan_group_unpublish(struct net_bridge_port *port);\n+void nbp_vlan_flush(struct net_bridge_port *port,\n+\t\t    struct net_bridge_vlan_group *vg);\n int nbp_vlan_init(struct net_bridge_port *port, struct netlink_ext_ack *extack);\n int nbp_get_num_vlan_infos(struct net_bridge_port *p, u32 filter_mask);\n void br_vlan_get_stats(const struct net_bridge_vlan *v,\n@@ -1721,7 +1846,7 @@ static inline u16 br_vlan_flags(const struct net_bridge_vlan *v, u16 pvid)\n static inline bool br_allowed_ingress(const struct net_bridge *br,\n \t\t\t\t      struct net_bridge_vlan_group *vg,\n \t\t\t\t      struct sk_buff *skb,\n-\t\t\t\t      u16 *vid, u8 *state,\n+\t\t\t\t      u8 *state,\n \t\t\t\t      struct net_bridge_vlan **vlan)\n \n {\n@@ -1736,8 +1861,10 @@ static inline bool br_allowed_egress(struct net_bridge_vlan_group *vg,\n }\n \n static inline bool br_should_learn(struct net_bridge_port *p,\n-\t\t\t\t   struct sk_buff *skb, u16 *vid)\n+\t\t\t\t   struct sk_buff *skb,\n+\t\t\t\t   struct net_bridge_vlan **vlan)\n {\n+\t*vlan = NULL;\n \treturn true;\n }\n \n@@ -1787,7 +1914,13 @@ static inline int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)\n \treturn -EOPNOTSUPP;\n }\n \n-static inline void nbp_vlan_flush(struct net_bridge_port *port)\n+static inline void nbp_vlan_group_unpublish(struct net_bridge_port *port)\n+{\n+}\n+\n+static inline void\n+nbp_vlan_flush(struct net_bridge_port *port,\n+\t       struct net_bridge_vlan_group *vg)\n {\n }\n \ndiff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c\nindex a7e5422eb5d14..2e5190278c903 100644\n--- a/net/bridge/br_stp_if.c\n+++ b/net/bridge/br_stp_if.c\n@@ -114,7 +114,7 @@ void br_stp_disable_port(struct net_bridge_port *p)\n \ttimer_delete(\u0026p-\u003ehold_timer);\n \n \tif (!rcu_access_pointer(p-\u003ebackup_port))\n-\t\tbr_fdb_delete_by_port(br, p, 0, 0);\n+\t\tbr_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 0);\n \tbr_multicast_disable_port(p);\n \n \tbr_configuration_update(br);\ndiff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c\nindex 990c6b38fd397..10f3aea6a1f82 100644\n--- a/net/bridge/br_switchdev.c\n+++ b/net/bridge/br_switchdev.c\n@@ -129,7 +129,7 @@ static void br_switchdev_fdb_populate(struct net_bridge *br,\n \t\t\t\t      const struct net_bridge_fdb_entry *fdb,\n \t\t\t\t      const void *ctx)\n {\n-\tconst struct net_bridge_port *p = READ_ONCE(fdb-\u003edst);\n+\tconst struct net_bridge_port *p = br_fdb_dst_port(fdb);\n \n \titem-\u003eaddr = fdb-\u003ekey.addr.addr;\n \titem-\u003evid = fdb-\u003ekey.vlan_id;\ndiff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c\nindex b9bcafa7f034c..621d62a063d98 100644\n--- a/net/bridge/br_sysfs_if.c\n+++ b/net/bridge/br_sysfs_if.c\n@@ -191,7 +191,8 @@ static BRPORT_ATTR(hold_timer, 0444, show_hold_timer, NULL);\n \n static int store_flush(struct net_bridge_port *p, unsigned long v)\n {\n-\tbr_fdb_delete_by_port(p-\u003ebr, p, 0, 0); // Don't delete local entry\n+\t/* Don't delete local entry */\n+\tbr_fdb_cleanup_by_dst(p-\u003ebr, br_port_to_dst(p), 0, 0);\n \treturn 0;\n }\n static BRPORT_ATTR(flush, 0200, NULL, store_flush);\ndiff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c\nindex ce5aa15c45402..0675f74cf1b99 100644\n--- a/net/bridge/br_vlan.c\n+++ b/net/bridge/br_vlan.c\n@@ -429,22 +429,34 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags,\n \tgoto out;\n }\n \n-static void __vlan_del(struct net_bridge_vlan *v)\n+static void __vlan_unpublish(struct net_bridge_vlan_group *vg,\n+\t\t\t     struct net_bridge_vlan *v)\n+{\n+\t__vlan_delete_pvid(vg, v);\n+\tif (!br_vlan_is_master(v)) {\n+\t\tstruct net_bridge_vlan *masterv = v-\u003ebrvlan;\n+\n+\t\trhashtable_remove_fast(\u0026vg-\u003evlan_hash, \u0026v-\u003evnode,\n+\t\t\t\t       br_vlan_rht_params);\n+\t\t__vlan_del_list(v);\n+\t\t/* -1 because br_vlan_put_master() is called later */\n+\t\tbr_vlan_rebuild_port_array(masterv,\n+\t\t\t\t\t   br_vlan_num_ports(masterv) - 1);\n+\t}\n+}\n+\n+static void __vlan_del(struct net_bridge_vlan_group *vg,\n+\t\t       struct net_bridge_vlan *v)\n {\n \tstruct net_bridge_vlan *masterv = v;\n-\tstruct net_bridge_vlan_group *vg;\n \tstruct net_bridge_port *p = NULL;\n \tint err;\n \n-\tif (br_vlan_is_master(v)) {\n-\t\tvg = br_vlan_group(v-\u003ebr);\n-\t} else {\n+\tif (!br_vlan_is_master(v)) {\n \t\tp = v-\u003eport;\n-\t\tvg = nbp_vlan_group(v-\u003eport);\n \t\tmasterv = v-\u003ebrvlan;\n \t}\n \n-\t__vlan_delete_pvid(vg, v);\n \tif (p) {\n \t\terr = __vlan_vid_del(p-\u003edev, p-\u003ebr, v);\n \t\tif (err)\n@@ -467,12 +479,6 @@ static void __vlan_del(struct net_bridge_vlan *v)\n \n \tif (masterv != v) {\n \t\tvlan_tunnel_info_del(vg, v);\n-\t\trhashtable_remove_fast(\u0026vg-\u003evlan_hash, \u0026v-\u003evnode,\n-\t\t\t\t       br_vlan_rht_params);\n-\t\t__vlan_del_list(v);\n-\t\t/* -1 because br_vlan_put_master() is called later */\n-\t\tbr_vlan_rebuild_port_array(masterv,\n-\t\t\t\t\t   br_vlan_num_ports(masterv) - 1);\n \t\tnbp_vlan_set_vlan_dev_state(p, v-\u003evid);\n \t\tbr_multicast_toggle_one_vlan(v, false);\n \t\tbr_multicast_port_ctx_deinit(\u0026v-\u003eport_mcast_ctx);\n@@ -509,7 +515,8 @@ static void __vlan_flush(const struct net_bridge *br,\n \t\t}\n \t\tv_end = vlan-\u003evid;\n \n-\t\t__vlan_del(vlan);\n+\t\t__vlan_unpublish(vg, vlan);\n+\t\t__vlan_del(vg, vlan);\n \t}\n \n \t/* notify about the last/whole vlan range */\n@@ -583,13 +590,13 @@ struct sk_buff *br_handle_vlan(struct net_bridge *br,\n /* Called under RCU */\n static bool __allowed_ingress(const struct net_bridge *br,\n \t\t\t      struct net_bridge_vlan_group *vg,\n-\t\t\t      struct sk_buff *skb, u16 *vid,\n-\t\t\t      u8 *state,\n+\t\t\t      struct sk_buff *skb, u8 *state,\n \t\t\t      struct net_bridge_vlan **vlan)\n {\n \tstruct pcpu_sw_netstats *stats;\n \tstruct net_bridge_vlan *v;\n \tbool tagged;\n+\tu16 vid;\n \n \tBR_INPUT_SKB_CB(skb)-\u003evlan_filtered = true;\n \t/* If vlan tx offload is disabled on bridge device and frame was\n@@ -603,7 +610,7 @@ static bool __allowed_ingress(const struct net_bridge *br,\n \t\t\treturn false;\n \t}\n \n-\tif (!br_vlan_get_tag(skb, vid)) {\n+\tif (!br_vlan_get_tag(skb, \u0026vid)) {\n \t\t/* Tagged frame */\n \t\tif (skb-\u003evlan_proto != br-\u003evlan_proto) {\n \t\t\t/* Protocol-mismatch, empty out vlan_tci for new tag */\n@@ -615,7 +622,7 @@ static bool __allowed_ingress(const struct net_bridge *br,\n \n \t\t\tskb_pull(skb, ETH_HLEN);\n \t\t\tskb_reset_mac_len(skb);\n-\t\t\t*vid = 0;\n+\t\t\tvid = 0;\n \t\t\ttagged = false;\n \t\t} else {\n \t\t\ttagged = true;\n@@ -625,7 +632,7 @@ static bool __allowed_ingress(const struct net_bridge *br,\n \t\ttagged = false;\n \t}\n \n-\tif (!*vid) {\n+\tif (!vid) {\n \t\tv = vg ? rcu_dereference(vg-\u003epvid) : NULL;\n \t\t/* Frame had a tag with VID 0 or did not have a tag.\n \t\t * See if pvid is set on this port.  That tells us which\n@@ -637,7 +644,6 @@ static bool __allowed_ingress(const struct net_bridge *br,\n \t\t/* PVID is set on this port.  Any untagged or priority-tagged\n \t\t * ingress frame is considered to belong to this vlan.\n \t\t */\n-\t\t*vid = v-\u003evid;\n \t\tif (likely(!tagged))\n \t\t\t/* Untagged Frame. */\n \t\t\t__vlan_hwaccel_put_tag(skb, br-\u003evlan_proto, v-\u003evid);\n@@ -649,7 +655,7 @@ static bool __allowed_ingress(const struct net_bridge *br,\n \t\t\t */\n \t\t\tskb-\u003evlan_tci |= v-\u003evid;\n \t} else {\n-\t\tv = br_vlan_find(vg, *vid);\n+\t\tv = br_vlan_find(vg, vid);\n \t}\n \n \tif (!v || !br_vlan_should_use(v))\n@@ -680,8 +686,7 @@ static bool __allowed_ingress(const struct net_bridge *br,\n \n bool br_allowed_ingress(const struct net_bridge *br,\n \t\t\tstruct net_bridge_vlan_group *vg, struct sk_buff *skb,\n-\t\t\tu16 *vid, u8 *state,\n-\t\t\tstruct net_bridge_vlan **vlan)\n+\t\t\tu8 *state, struct net_bridge_vlan **vlan)\n {\n \t/* If VLAN filtering is disabled on the bridge, all packets are\n \t * permitted.\n@@ -692,7 +697,7 @@ bool br_allowed_ingress(const struct net_bridge *br,\n \t\treturn true;\n \t}\n \n-\treturn __allowed_ingress(br, vg, skb, vid, state, vlan);\n+\treturn __allowed_ingress(br, vg, skb, state, vlan);\n }\n \n /* Called under RCU. */\n@@ -716,11 +721,15 @@ bool br_allowed_egress(struct net_bridge_vlan_group *vg,\n }\n \n /* Called under RCU */\n-bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid)\n+bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb,\n+\t\t     struct net_bridge_vlan **vlan)\n {\n \tstruct net_bridge_vlan_group *vg;\n \tstruct net_bridge *br = p-\u003ebr;\n \tstruct net_bridge_vlan *v;\n+\tu16 vid;\n+\n+\t*vlan = NULL;\n \n \t/* If filtering was disabled at input, let it pass. */\n \tif (!br_opt_get(br, BROPT_VLAN_ENABLED))\n@@ -730,20 +739,22 @@ bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid)\n \tif (!vg || !READ_ONCE(vg-\u003enum_vlans))\n \t\treturn false;\n \n-\tif (!br_vlan_get_tag(skb, vid) \u0026\u0026 skb-\u003evlan_proto != br-\u003evlan_proto)\n-\t\t*vid = 0;\n+\tif (!br_vlan_get_tag(skb, \u0026vid) \u0026\u0026 skb-\u003evlan_proto != br-\u003evlan_proto)\n+\t\tvid = 0;\n \n-\tif (!*vid) {\n+\tif (!vid) {\n \t\tv = rcu_dereference(vg-\u003epvid);\n \t\tif (!v || !br_vlan_state_allowed(br_vlan_get_state(v), true))\n \t\t\treturn false;\n-\t\t*vid = v-\u003evid;\n+\t\t*vlan = v;\n \t\treturn true;\n \t}\n \n-\tv = br_vlan_find(vg, *vid);\n-\tif (v \u0026\u0026 br_vlan_state_allowed(br_vlan_get_state(v), true))\n+\tv = br_vlan_find(vg, vid);\n+\tif (v \u0026\u0026 br_vlan_state_allowed(br_vlan_get_state(v), true)) {\n+\t\t*vlan = v;\n \t\treturn true;\n+\t}\n \n \treturn false;\n }\n@@ -866,10 +877,11 @@ int br_vlan_delete(struct net_bridge *br, u16 vid)\n \t\treturn -ENOENT;\n \n \tbr_fdb_find_delete_local(br, NULL, br-\u003edev-\u003edev_addr, vid);\n-\tbr_fdb_delete_by_port(br, NULL, vid, 0);\n+\tbr_fdb_cleanup_by_dst(br, br_port_to_dst(NULL), vid, 0);\n \n \tvlan_tunnel_info_del(vg, v);\n-\t__vlan_del(v);\n+\t__vlan_unpublish(vg, v);\n+\t__vlan_del(vg, v);\n \n \treturn 0;\n }\n@@ -1385,30 +1397,41 @@ int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,\n  */\n int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)\n {\n+\tstruct net_bridge_vlan_group *vg;\n \tstruct net_bridge_vlan *v;\n \n \tASSERT_RTNL();\n \n-\tv = br_vlan_find(nbp_vlan_group(port), vid);\n+\tvg = nbp_vlan_group(port);\n+\tv = br_vlan_find(vg, vid);\n \tif (!v)\n \t\treturn -ENOENT;\n-\tbr_fdb_find_delete_local(port-\u003ebr, port, port-\u003edev-\u003edev_addr, vid);\n-\tbr_fdb_delete_by_port(port-\u003ebr, port, vid, 0);\n-\t__vlan_del(v);\n+\t__vlan_unpublish(vg, v);\n+\tsynchronize_net();\n+\t/* Traffic may still use v through cached fdb dsts until they are\n+\t * cleaned below. This is acceptable during vlan deletion. Above we\n+\t * drain the readers that could republish the dst before cleaning it\n+\t */\n+\tbr_fdb_cleanup_by_dst(port-\u003ebr, br_vlan_to_dst(v), vid, 0);\n+\t__vlan_del(vg, v);\n \n \treturn 0;\n }\n \n-void nbp_vlan_flush(struct net_bridge_port *port)\n+void nbp_vlan_group_unpublish(struct net_bridge_port *port)\n {\n-\tstruct net_bridge_vlan_group *vg;\n-\n \tASSERT_RTNL();\n \n-\tvg = nbp_vlan_group(port);\n-\t__vlan_flush(port-\u003ebr, port, vg);\n \tRCU_INIT_POINTER(port-\u003evlgrp, NULL);\n \tsynchronize_net();\n+}\n+\n+void nbp_vlan_flush(struct net_bridge_port *port,\n+\t\t    struct net_bridge_vlan_group *vg)\n+{\n+\tASSERT_RTNL();\n+\n+\t__vlan_flush(port-\u003ebr, port, vg);\n \t__vlan_group_free(vg);\n }\n \ndiff --git a/net/bridge/netfilter/nft_reject_bridge.c b/net/bridge/netfilter/nft_reject_bridge.c\nindex cd2b04236a99c..92b488793914a 100644\n--- a/net/bridge/netfilter/nft_reject_bridge.c\n+++ b/net/bridge/netfilter/nft_reject_bridge.c\n@@ -55,7 +55,7 @@ static void nft_reject_br_send_v4_tcp_reset(struct net *net,\n \n \tnft_reject_br_push_etherhdr(oldskb, nskb);\n \n-\tbr_forward(br_port_get_rcu(dev), nskb, false, true);\n+\tbr_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);\n }\n \n static void nft_reject_br_send_v4_unreach(struct net *net,\n@@ -71,7 +71,7 @@ static void nft_reject_br_send_v4_unreach(struct net *net,\n \n \tnft_reject_br_push_etherhdr(oldskb, nskb);\n \n-\tbr_forward(br_port_get_rcu(dev), nskb, false, true);\n+\tbr_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);\n }\n \n static void nft_reject_br_send_v6_tcp_reset(struct net *net,\n@@ -87,7 +87,7 @@ static void nft_reject_br_send_v6_tcp_reset(struct net *net,\n \n \tnft_reject_br_push_etherhdr(oldskb, nskb);\n \n-\tbr_forward(br_port_get_rcu(dev), nskb, false, true);\n+\tbr_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);\n }\n \n \n@@ -104,7 +104,7 @@ static void nft_reject_br_send_v6_unreach(struct net *net,\n \n \tnft_reject_br_push_etherhdr(oldskb, nskb);\n \n-\tbr_forward(br_port_get_rcu(dev), nskb, false, true);\n+\tbr_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);\n }\n \n static void nft_reject_bridge_eval(const struct nft_expr *expr,\n"
}

2/1 2026/10/01 04:45 agent patch-evaluator
1m Model:
core

Args:
null

Results:
{
  "EnableConfigs": [
    "BRIDGE",
    "BRIDGE_VLAN_FILTERING",
    "VLAN_8021Q",
    "NET_SWITCHDEV"
  ],
  "FocusSymbols": [
    "br_fdb_cleanup_by_dst",
    "br_fdb_update",
    "br_fdb_external_learn_add",
    "br_fdb_add",
    "br_forward",
    "nbp_vlan_delete",
    "nbp_vlan_group_unpublish",
    "br_vlan_delete"
  ],
  "Reasoning": "The patch modifies the Linux Ethernet bridge subsystem to allow FDB (Forwarding Database) entries to point directly to VLAN destinations in addition to ports. This refactors FDB entry destination handling, introduces atomic destination replacement via cmpxchg, alters concurrency and lifetime sequencing during port and VLAN deletion with RCU unpublishing/synchronize_net(), and adds lockdep assertions. These changes affect reachable core networking code configured via netlink and exercised during bridge frame reception, forwarding, and configuration.",
  "WorthFuzzing": true
}

Instruction:
You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.

IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.

================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.

- REACHABILITY IS THE PRIMARY GATE:
  Fuzzing can only discover bugs in code that can actually execute in standard virtualized
  environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
  If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
  regardless of whether it adds assertions or complex logic.

- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
  Patch authors routinely label changes as "cleanups", "refactorings", or state
  "No functional change intended". Do NOT take these claims at face value.
  Code refactorings that rearrange logic, introduce helper functions, or alter state management
  in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
  If reachable executable code is modified or refactored, it MUST be fuzzed.

- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
  When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
  BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
  Even if the author believes the invariant always holds, fuzzing is essential to verify whether
  an unusual sequence of operations can violate it.

================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:

- Non-kernel and non-executable changes:
  * Modifications to Documentation/, comments, or spelling fixes.
  * User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
    that do not affect the compiled kernel image (vmlinux) or kernel modules.
  * Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
    that do not alter control flow or data structures.
  * Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
  * Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
    ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
  * Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
    physical PCI hot-unplug or manual sysfs driver unbinding.
  * Code paths exclusive to architectures other than the target architecture.

================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
  * Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
    BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
  * Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
  * Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
  * Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).

================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:

- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
  Do NOT list generic, ubiquitous functions called by almost every program in the corpus
  (including, but not limited to: general memory allocators and deallocators, page fault
  and trap handlers, or core synchronization primitives; this is not an exhaustive list).
  Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
  which severely dilutes fuzzing effort away from the actual changes.

- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
  List functions that specifically implement the logic being added or altered, or direct API entrypoints
  for the subsystem feature under review.

- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
  Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
  distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
  If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
  functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).

================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit f871cd2676b17c6338ab86a38d0a4690b5626b96
Author: syz-cluster <triage@syzkaller.com>
Date:   Thu Oct 1 04:45:06 2026 +0000

    syz-cluster: applied patch under review

diff --git a/include/trace/events/bridge.h b/include/trace/events/bridge.h
index 3fe4725c83ffe..f676516b33fa5 100644
--- a/include/trace/events/bridge.h
+++ b/include/trace/events/bridge.h
@@ -68,13 +68,14 @@ TRACE_EVENT(br_fdb_external_learn_add,
 
 TRACE_EVENT(fdb_delete,
 
-	TP_PROTO(struct net_bridge *br, struct net_bridge_fdb_entry *f),
+	TP_PROTO(struct net_bridge *br, struct net_bridge_fdb_entry *f,
+		 const struct net_bridge_port *dst),
 
-	TP_ARGS(br, f),
+	TP_ARGS(br, f, dst),
 
 	TP_STRUCT__entry(
 		__string(br_dev, br->dev->name)
-		__string(dev, f->dst ? f->dst->dev->name : "null")
+		__string(dev, dst ? dst->dev->name : "null")
 		__array(unsigned char, addr, ETH_ALEN)
 		__field(u16, vid)
 	),
diff --git a/net/bridge/br.c b/net/bridge/br.c
index 09a120b3b76cb..b1abe1c5bbdd2 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -202,7 +202,7 @@ static int br_switchdev_event(struct notifier_block *unused,
 	case SWITCHDEV_FDB_FLUSH_TO_BRIDGE:
 		fdb_info = ptr;
 		/* Don't delete static entries */
-		br_fdb_delete_by_port(br, p, fdb_info->vid, 0);
+		br_fdb_cleanup_by_dst(br, br_port_to_dst(p), fdb_info->vid, 0);
 		break;
 	}
 
diff --git a/net/bridge/br_arp_nd_proxy.c b/net/bridge/br_arp_nd_proxy.c
index da15f4d7c1aef..ba4a63840b219 100644
--- a/net/bridge/br_arp_nd_proxy.c
+++ b/net/bridge/br_arp_nd_proxy.c
@@ -223,7 +223,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
 		neigh_ha_snapshot(ha, n, n->dev);
 		f = br_fdb_find_rcu(br, ha, vid);
 		if (f) {
-			const struct net_bridge_port *dst = READ_ONCE(f->dst);
+			const struct net_bridge_port *dst = br_fdb_dst_port(f);
 			bool replied = false;
 
 			if ((p && test_bit(BR_PROXYARP_BIT, &p->flags)) ||
@@ -500,7 +500,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
 		neigh_ha_snapshot(ha, n, n->dev);
 		f = br_fdb_find_rcu(br, ha, vid);
 		if (f) {
-			const struct net_bridge_port *dst = READ_ONCE(f->dst);
+			const struct net_bridge_port *dst = br_fdb_dst_port(f);
 			bool replied = false;
 
 			if (br_is_neigh_suppress_enabled_vid(dst, vid)) {
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index ce9ea9ac3d0ad..0a1ce9e59a4d4 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -65,9 +65,10 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 	skb_reset_mac_header(skb);
 	skb_pull(skb, ETH_HLEN);
 
-	if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &vid,
-				&state, &vlan))
+	if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &state,
+				&vlan))
 		goto out;
+	vid = vlan ? vlan->vid : 0;
 
 	if (IS_ENABLED(CONFIG_INET) &&
 	    (eth_hdr(skb)->h_proto == htons(ETH_P_ARP) ||
@@ -107,7 +108,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 		else
 			br_flood(br, vlan, skb, BR_PKT_MULTICAST, false, true);
 	} else if ((dst = br_fdb_find_rcu(br, dest, vid)) != NULL) {
-		br_forward(READ_ONCE(dst->dst), skb, false, true);
+		br_forward(br_fdb_dst_read(dst), skb, false, true);
 	} else {
 		br_flood(br, vlan, skb, BR_PKT_UNICAST, false, true);
 	}
@@ -400,7 +401,7 @@ static int br_fill_forward_path(struct net_device_path_ctx *ctx,
 	if (!f)
 		return -1;
 
-	dst = READ_ONCE(f->dst);
+	dst = br_fdb_dst_port(f);
 	if (!dst)
 		return -1;
 
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index e4570bbed8544..730b178cf6c44 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -90,7 +90,7 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br,
 			 const struct net_bridge_fdb_entry *fdb,
 			 u32 portid, u32 seq, int type, unsigned int flags)
 {
-	const struct net_bridge_port *dst = READ_ONCE(fdb->dst);
+	const struct net_bridge_port *dst = br_fdb_dst_port(fdb);
 	unsigned long now = jiffies;
 	struct nda_cacheinfo ci;
 	struct nlmsghdr *nlh;
@@ -250,7 +250,7 @@ struct net_device *br_fdb_find_port(const struct net_device *br_dev,
 	rcu_read_lock();
 	f = br_fdb_find_rcu(br, addr, vid);
 	if (f) {
-		dst = READ_ONCE(f->dst);
+		dst = br_fdb_dst_port(f);
 		if (dst)
 			dev = dst->dev;
 	}
@@ -315,7 +315,7 @@ static void fdb_del_hw_addr(struct net_bridge *br, const unsigned char *addr)
 static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f,
 		       bool swdev_notify)
 {
-	trace_fdb_delete(br, f);
+	trace_fdb_delete(br, f, br_fdb_dst_port(f));
 
 	if (test_bit(BR_FDB_STATIC, &f->flags))
 		fdb_del_hw_addr(br, f->key.addr.addr);
@@ -350,7 +350,7 @@ static void fdb_delete_local(struct net_bridge *br,
 		vg = nbp_vlan_group(op);
 		if (op != p && ether_addr_equal(op->dev->dev_addr, addr) &&
 		    (!vid || br_vlan_find(vg, vid))) {
-			WRITE_ONCE(f->dst, op);
+			br_fdb_dst_write(f, br_port_to_dst(op));
 			clear_bit(BR_FDB_ADDED_BY_USER, &f->flags);
 			return;
 		}
@@ -361,7 +361,7 @@ static void fdb_delete_local(struct net_bridge *br,
 	/* Maybe bridge device has same hw addr? */
 	if (p && ether_addr_equal(br->dev->dev_addr, addr) &&
 	    (!vid || (v && br_vlan_should_use(v)))) {
-		WRITE_ONCE(f->dst, NULL);
+		br_fdb_dst_write(f, br_port_to_dst(NULL));
 		clear_bit(BR_FDB_ADDED_BY_USER, &f->flags);
 		return;
 	}
@@ -378,13 +378,14 @@ void br_fdb_find_delete_local(struct net_bridge *br,
 	spin_lock_bh(&br->hash_lock);
 	f = br_fdb_find(br, addr, vid);
 	if (f && test_bit(BR_FDB_LOCAL, &f->flags) &&
-	    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags) && f->dst == p)
+	    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags) &&
+	    br_fdb_dst_port(f) == p)
 		fdb_delete_local(br, p, f);
 	spin_unlock_bh(&br->hash_lock);
 }
 
 static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,
-					       struct net_bridge_port *source,
+					       struct net_bridge_dst dst,
 					       const unsigned char *addr,
 					       __u16 vid,
 					       unsigned long flags)
@@ -408,7 +409,7 @@ static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,
 		return NULL;
 
 	memcpy(fdb->key.addr.addr, addr, ETH_ALEN);
-	WRITE_ONCE(fdb->dst, source);
+	br_fdb_dst_write(fdb, dst);
 	fdb->key.vlan_id = vid;
 	fdb->flags = flags;
 	fdb->updated = fdb->used = jiffies;
@@ -447,7 +448,7 @@ static int fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,
 		fdb_delete(br, fdb, true);
 	}
 
-	fdb = fdb_create(br, source, addr, vid,
+	fdb = fdb_create(br, br_port_to_dst(source), addr, vid,
 			 BIT(BR_FDB_LOCAL) | BIT(BR_FDB_STATIC));
 	if (!fdb)
 		return -ENOMEM;
@@ -470,7 +471,7 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)
 	spin_lock_bh(&br->hash_lock);
 	vg = nbp_vlan_group(p);
 	hlist_for_each_entry(f, &br->fdb_list, fdb_node) {
-		if (READ_ONCE(f->dst) == p &&
+		if (br_fdb_dst_port(f) == p &&
 		    test_bit(BR_FDB_LOCAL, &f->flags) &&
 		    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags)) {
 			/* delete old one */
@@ -517,7 +518,8 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr)
 	/* If old entry was unassociated with any port, then delete it. */
 	f = br_fdb_find(br, br->dev->dev_addr, 0);
 	if (f && test_bit(BR_FDB_LOCAL, &f->flags) &&
-	    !f->dst && !test_bit(BR_FDB_ADDED_BY_USER, &f->flags))
+	    !br_fdb_dst_port(f) &&
+	    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags))
 		fdb_delete_local(br, NULL, f);
 
 	fdb_add_local(br, NULL, newaddr, 0);
@@ -533,7 +535,8 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr)
 			continue;
 		f = br_fdb_find(br, br->dev->dev_addr, v->vid);
 		if (f && test_bit(BR_FDB_LOCAL, &f->flags) &&
-		    !f->dst && !test_bit(BR_FDB_ADDED_BY_USER, &f->flags))
+		    !br_fdb_dst_port(f) &&
+		    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags))
 			fdb_delete_local(br, NULL, f);
 		fdb_add_local(br, NULL, newaddr, v->vid);
 	}
@@ -693,7 +696,7 @@ static bool __fdb_flush_matches(const struct net_bridge *br,
 				const struct net_bridge_fdb_entry *f,
 				const struct net_bridge_fdb_flush_desc *desc)
 {
-	const struct net_bridge_port *dst = READ_ONCE(f->dst);
+	const struct net_bridge_port *dst = br_fdb_dst_port(f);
 	int port_ifidx = dst ? dst->dev->ifindex : br->dev->ifindex;
 
 	if (desc->vlan_id && desc->vlan_id != f->key.vlan_id)
@@ -865,29 +868,50 @@ int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
 	return 0;
 }
 
-/* Flush all entries referring to a specific port.
+/* Clean up all entries referring to a specific destination.
  * if do_all is set also flush static entries
  * if vid is set delete all entries that match the vlan_id
  */
-void br_fdb_delete_by_port(struct net_bridge *br,
-			   const struct net_bridge_port *p,
-			   u16 vid,
+void br_fdb_cleanup_by_dst(struct net_bridge *br,
+			   struct net_bridge_dst cleanup_dst, u16 vid,
 			   int do_all)
 {
+	const struct net_bridge_vlan *vlan = br_dst_vlan(cleanup_dst);
+	const struct net_bridge_port *p = br_dst_port(cleanup_dst);
 	struct net_bridge_fdb_entry *f;
 	struct hlist_node *tmp;
 
 	spin_lock_bh(&br->hash_lock);
 	hlist_for_each_entry_safe(f, tmp, &br->fdb_list, fdb_node) {
-		if (READ_ONCE(f->dst) != p)
+		struct net_bridge_dst dst = br_fdb_dst_read(f);
+
+		if (br_dst_port(dst) != p)
+			continue;
+
+		if (vlan && f->key.vlan_id == vlan->vid &&
+		    test_bit(BR_FDB_LOCAL, &f->flags) &&
+		    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags) &&
+		    ether_addr_equal(f->key.addr.addr, p->dev->dev_addr)) {
+			fdb_delete_local(br, p, f);
 			continue;
+		}
+
+		if (!do_all) {
+			if (vid && f->key.vlan_id != vid)
+				continue;
 
-		if (!do_all)
 			if (test_bit(BR_FDB_STATIC, &f->flags) ||
 			    (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &f->flags) &&
-			     !test_bit(BR_FDB_OFFLOADED, &f->flags)) ||
-			    (vid && f->key.vlan_id != vid))
+			     !test_bit(BR_FDB_OFFLOADED, &f->flags))) {
+				/* The entry outlives the VLAN, so it must fall
+				 * back to the raw port destination
+				 */
+				if (vlan && br_dst_vlan(dst) == vlan)
+					br_fdb_dst_replace(f, dst,
+							   br_port_to_dst(p));
 				continue;
+			}
+		}
 
 		if (test_bit(BR_FDB_LOCAL, &f->flags))
 			fdb_delete_local(br, p, f);
@@ -921,7 +945,7 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf,
 			continue;
 
 		/* ignore pseudo entry for local MAC address */
-		dst = READ_ONCE(f->dst);
+		dst = br_fdb_dst_port(f);
 		if (!dst)
 			continue;
 
@@ -970,10 +994,78 @@ static bool __fdb_mark_active(struct net_bridge_fdb_entry *fdb)
 		  test_and_clear_bit(BR_FDB_NOTIFY_INACTIVE, &fdb->flags));
 }
 
+static void __fdb_update(struct net_bridge *br,
+			 struct net_bridge_fdb_entry *fdb,
+			 struct net_bridge_port *source,
+			 struct net_bridge_dst dst,
+			 const unsigned char *addr, u16 vid,
+			 unsigned long flags)
+{
+	struct net_bridge_port *old_port;
+	struct net_bridge_dst old_dst;
+	bool fdb_modified = false;
+	unsigned long now;
+
+	/* attempt to update an entry for a local interface */
+	if (unlikely(test_bit(BR_FDB_LOCAL, &fdb->flags))) {
+		if (net_ratelimit())
+			br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
+				source->dev->name, addr, vid);
+		return;
+	}
+
+	now = jiffies;
+	if (now != READ_ONCE(fdb->updated)) {
+		WRITE_ONCE(fdb->updated, now);
+		fdb_modified = __fdb_mark_active(fdb);
+	}
+
+	old_dst = br_fdb_dst_read(fdb);
+	old_port = br_dst_port(old_dst);
+	/* fastpath: update of existing entry */
+	if (unlikely(!br_dst_equal(dst, old_dst) &&
+		     (source == old_port ||
+		      !test_bit(BR_FDB_STICKY, &fdb->flags)))) {
+		if (source != old_port) {
+			br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
+			br_fdb_dst_write(fdb, dst);
+			fdb_modified = true;
+			/* take over HW learned entry */
+			if (unlikely(test_bit(BR_FDB_ADDED_BY_EXT_LEARN,
+					      &fdb->flags)))
+				clear_bit(BR_FDB_ADDED_BY_EXT_LEARN,
+					  &fdb->flags);
+			/* clear locked flag when roaming to an unlocked port */
+			if (unlikely(test_bit(BR_FDB_LOCKED, &fdb->flags)))
+				clear_bit(BR_FDB_LOCKED, &fdb->flags);
+		} else {
+			/* raw port-to-VLAN promotion shouldn't overwrite a
+			 * concurrent roam to another port
+			 */
+			br_fdb_dst_replace(fdb, old_dst, dst);
+		}
+	}
+
+	if (unlikely(test_bit(BR_FDB_ADDED_BY_USER, &flags))) {
+		set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags);
+		if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &fdb->flags))
+			atomic_dec(&br->fdb_n_learned);
+	}
+
+	if (unlikely(fdb_modified)) {
+		trace_br_fdb_update(br, source, addr, vid, flags);
+		fdb_notify(br, fdb, RTM_NEWNEIGH, true);
+	}
+}
+
 void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
-		   const unsigned char *addr, u16 vid, unsigned long flags)
+		   struct net_bridge_vlan *vlan, const unsigned char *addr,
+		   unsigned long flags)
 {
+	struct net_bridge_dst dst = vlan ? br_vlan_to_dst(vlan) :
+					   br_port_to_dst(source);
 	struct net_bridge_fdb_entry *fdb;
+	u16 vid = vlan ? vlan->vid : 0;
 
 	/* some users want to always flood. */
 	if (hold_time(br) == 0)
@@ -981,59 +1073,14 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 
 	fdb = fdb_find_rcu(&br->fdb_hash_tbl, addr, vid);
 	if (likely(fdb)) {
-		/* attempt to update an entry for a local interface */
-		if (unlikely(test_bit(BR_FDB_LOCAL, &fdb->flags))) {
-			if (net_ratelimit())
-				br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
-					source->dev->name, addr, vid);
-		} else {
-			unsigned long now = jiffies;
-			bool fdb_modified = false;
-
-			if (now != READ_ONCE(fdb->updated)) {
-				WRITE_ONCE(fdb->updated, now);
-				fdb_modified = __fdb_mark_active(fdb);
-			}
-
-			/* fastpath: update of existing entry */
-			if (unlikely(source != READ_ONCE(fdb->dst) &&
-				     !test_bit(BR_FDB_STICKY, &fdb->flags))) {
-				br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
-				WRITE_ONCE(fdb->dst, source);
-				fdb_modified = true;
-				/* Take over HW learned entry */
-				if (unlikely(test_bit(BR_FDB_ADDED_BY_EXT_LEARN,
-						      &fdb->flags)))
-					clear_bit(BR_FDB_ADDED_BY_EXT_LEARN,
-						  &fdb->flags);
-				/* Clear locked flag when roaming to an
-				 * unlocked port.
-				 */
-				if (unlikely(test_bit(BR_FDB_LOCKED, &fdb->flags)))
-					clear_bit(BR_FDB_LOCKED, &fdb->flags);
-			}
-
-			if (unlikely(test_bit(BR_FDB_ADDED_BY_USER, &flags))) {
-				set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags);
-				if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED,
-						       &fdb->flags))
-					atomic_dec(&br->fdb_n_learned);
-			}
-			if (unlikely(fdb_modified)) {
-				trace_br_fdb_update(br, source, addr, vid, flags);
-				fdb_notify(br, fdb, RTM_NEWNEIGH, true);
-			}
-		}
+		__fdb_update(br, fdb, source, dst, addr, vid, flags);
 	} else {
 		spin_lock(&br->hash_lock);
-		fdb = fdb_create(br, source, addr, vid, flags);
+		fdb = fdb_create(br, dst, addr, vid, flags);
 		if (fdb) {
 			trace_br_fdb_update(br, source, addr, vid, flags);
 			fdb_notify(br, fdb, RTM_NEWNEIGH, true);
 		}
-		/* else  we lose race and someone else inserts
-		 * it first, don't bother updating
-		 */
 		spin_unlock(&br->hash_lock);
 	}
 }
@@ -1061,17 +1108,17 @@ int br_fdb_dump(struct sk_buff *skb,
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(f, &br->fdb_list, fdb_node) {
-		const struct net_bridge_port *dst = READ_ONCE(f->dst);
+		const struct net_bridge_port *dst = br_fdb_dst_port(f);
 
 		if (*idx < ctx->fdb_idx)
 			goto skip;
 		if (filter_dev && (!dst || dst->dev != filter_dev)) {
 			if (filter_dev != dev)
 				goto skip;
-			/* !f->dst is a special case for bridge
+			/* A NULL destination is a special case for bridge
 			 * It means the MAC belongs to the bridge
 			 * Therefore need a little more filtering
-			 * we only want to dump the !f->dst case
+			 * we only want to dump the NULL destination case
 			 */
 			if (dst)
 				goto skip;
@@ -1145,10 +1192,11 @@ static bool fdb_handle_notify(struct net_bridge_fdb_entry *fdb, u8 notify)
 }
 
 /* Update (create or replace) forwarding database entry */
-static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source,
+static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
 			 const u8 *addr, struct ndmsg *ndm, u16 flags, u16 vid,
 			 struct nlattr *nfea_tb[])
 {
+	struct net_bridge_port *source = br_dst_port(dst);
 	bool is_sticky = !!(ndm->ndm_flags & NTF_STICKY);
 	bool refresh = !nfea_tb[NFEA_DONT_REFRESH];
 	struct net_bridge_fdb_entry *fdb;
@@ -1183,19 +1231,26 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source,
 		if (!(flags & NLM_F_CREATE))
 			return -ENOENT;
 
-		fdb = fdb_create(br, source, addr, vid,
+		fdb = fdb_create(br, dst, addr, vid,
 				 BIT(BR_FDB_ADDED_BY_USER));
 		if (!fdb)
 			return -ENOMEM;
 
 		modified = true;
 	} else {
+		struct net_bridge_dst old_dst;
+
 		if (flags & NLM_F_EXCL)
 			return -EEXIST;
 
-		if (READ_ONCE(fdb->dst) != source) {
-			WRITE_ONCE(fdb->dst, source);
-			modified = true;
+		old_dst = br_fdb_dst_read(fdb);
+		if (!br_dst_equal(old_dst, dst)) {
+			if (br_dst_port(old_dst) != source) {
+				modified = true;
+				br_fdb_dst_write(fdb, dst);
+			} else {
+				br_fdb_dst_replace(fdb, old_dst, dst);
+			}
 		}
 
 		set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags);
@@ -1244,9 +1299,12 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source,
 
 static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
 			struct net_bridge_port *p, const unsigned char *addr,
-			u16 nlh_flags, u16 vid, struct nlattr *nfea_tb[],
+			u16 nlh_flags, struct net_bridge_vlan *vlan,
+			struct nlattr *nfea_tb[],
 			bool *notified, struct netlink_ext_ack *extack)
 {
+	u16 vid = vlan ? vlan->vid : 0;
+	struct net_bridge_dst dst;
 	int err = 0;
 
 	if (ndm->ndm_flags & NTF_USE) {
@@ -1260,7 +1318,7 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
 
 		local_bh_disable();
 		rcu_read_lock();
-		br_fdb_update(br, p, addr, vid, BIT(BR_FDB_ADDED_BY_USER));
+		br_fdb_update(br, p, vlan, addr, BIT(BR_FDB_ADDED_BY_USER));
 		rcu_read_unlock();
 		local_bh_enable();
 	} else if (ndm->ndm_flags & NTF_EXT_LEARNED) {
@@ -1271,8 +1329,10 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
 		}
 		err = br_fdb_external_learn_add(br, p, addr, vid, false, true);
 	} else {
+		dst = p && vlan ? br_vlan_to_dst(vlan) : br_port_to_dst(p);
 		spin_lock_bh(&br->hash_lock);
-		err = fdb_add_entry(br, p, addr, ndm, nlh_flags, vid, nfea_tb);
+		err = fdb_add_entry(br, dst, addr, ndm, nlh_flags, vid,
+				    nfea_tb);
 		spin_unlock_bh(&br->hash_lock);
 	}
 
@@ -1352,10 +1412,10 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 		}
 
 		/* VID was specified, so use it. */
-		err = __br_fdb_add(ndm, br, p, addr, nlh_flags, vid, nfea_tb,
+		err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v, nfea_tb,
 				   notified, extack);
 	} else {
-		err = __br_fdb_add(ndm, br, p, addr, nlh_flags, 0, nfea_tb,
+		err = __br_fdb_add(ndm, br, p, addr, nlh_flags, NULL, nfea_tb,
 				   notified, extack);
 		if (err || !vg || !vg->num_vlans)
 			goto out;
@@ -1367,7 +1427,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 		list_for_each_entry(v, &vg->vlan_list, vlist) {
 			if (!br_vlan_should_use(v))
 				continue;
-			err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v->vid,
+			err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v,
 					   nfea_tb, notified, extack);
 			if (err)
 				goto out;
@@ -1385,7 +1445,7 @@ static int fdb_delete_by_addr_and_port(struct net_bridge *br,
 	struct net_bridge_fdb_entry *fdb;
 
 	fdb = br_fdb_find(br, addr, vlan);
-	if (!fdb || READ_ONCE(fdb->dst) != p)
+	if (!fdb || br_fdb_dst_port(fdb) != p)
 		return -ENOENT;
 
 	fdb_delete(br, fdb, true);
@@ -1504,10 +1564,31 @@ void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p)
 	rcu_read_unlock();
 }
 
+static struct net_bridge_dst br_fdb_resolve_dst(const struct net_bridge_port *p,
+						u16 vid)
+{
+	struct net_bridge_dst dst = br_port_to_dst(p);
+	struct net_bridge_vlan *v;
+
+	lockdep_assert(rcu_read_lock_held() || lockdep_rtnl_is_held());
+
+	if (!p || !vid)
+		return dst;
+
+	rcu_read_lock();
+	v = br_vlan_find(nbp_vlan_group_rcu(p), vid);
+	if (v)
+		dst = br_vlan_to_dst(v);
+	rcu_read_unlock();
+
+	return dst;
+}
+
 int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
 			      const unsigned char *addr, u16 vid, bool locked,
 			      bool swdev_notify)
 {
+	struct net_bridge_dst dst = br_fdb_resolve_dst(p, vid);
 	struct net_bridge_fdb_entry *fdb;
 	bool modified = false;
 	int err = 0;
@@ -1532,25 +1613,32 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
 		if (locked)
 			flags |= BIT(BR_FDB_LOCKED);
 
-		fdb = fdb_create(br, p, addr, vid, flags);
+		fdb = fdb_create(br, dst, addr, vid, flags);
 		if (!fdb) {
 			err = -ENOMEM;
 			goto err_unlock;
 		}
 		fdb_notify(br, fdb, RTM_NEWNEIGH, swdev_notify);
 	} else {
+		struct net_bridge_dst old_dst;
+
+		old_dst = br_fdb_dst_read(fdb);
 		if (locked &&
 		    (!test_bit(BR_FDB_LOCKED, &fdb->flags) ||
-		     READ_ONCE(fdb->dst) != p)) {
+		     br_dst_port(old_dst) != p)) {
 			err = -EINVAL;
 			goto err_unlock;
 		}
 
 		WRITE_ONCE(fdb->updated, jiffies);
 
-		if (READ_ONCE(fdb->dst) != p) {
-			WRITE_ONCE(fdb->dst, p);
-			modified = true;
+		if (!br_dst_equal(old_dst, dst)) {
+			if (br_dst_port(old_dst) != p) {
+				modified = true;
+				br_fdb_dst_write(fdb, dst);
+			} else {
+				br_fdb_dst_replace(fdb, old_dst, dst);
+			}
 		}
 
 		if (test_and_set_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) {
@@ -1632,7 +1720,7 @@ void br_fdb_clear_offload(const struct net_device *dev, u16 vid)
 
 	spin_lock_bh(&p->br->hash_lock);
 	hlist_for_each_entry(f, &p->br->fdb_list, fdb_node) {
-		if (READ_ONCE(f->dst) == p && f->key.vlan_id == vid)
+		if (br_fdb_dst_port(f) == p && f->key.vlan_id == vid)
 			clear_bit(BR_FDB_OFFLOADED, &f->flags);
 	}
 	spin_unlock_bh(&p->br->hash_lock);
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index b5eece1ff9e8c..82645db32efbe 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -17,7 +17,7 @@
 #include "br_private.h"
 
 struct br_fwd_dst {
-	const struct net_bridge_port *port;
+	struct net_bridge_port *port;
 	struct net_bridge_vlan *vlan;
 };
 
@@ -149,35 +149,37 @@ static int deliver_clone(const struct br_fwd_dst *fwd,
 
 /**
  * br_forward - forward a packet to a specific port
- * @to: destination port
+ * @dst: bridge destination
  * @skb: packet being forwarded
  * @local_rcv: packet will be received locally after forwarding
  * @local_orig: packet is locally originated
  *
  * Should be called with rcu_read_lock.
  */
-void br_forward(const struct net_bridge_port *to,
+void br_forward(struct net_bridge_dst dst,
 		struct sk_buff *skb, bool local_rcv, bool local_orig)
 {
 	struct br_fwd_dst fwd;
 
-	if (unlikely(!to))
+	br_dst_decode(dst, &fwd.port, &fwd.vlan);
+
+	if (unlikely(!fwd.port))
 		goto out;
 
 	/* redirect to backup link if the destination port is down */
-	if (rcu_access_pointer(to->backup_port) &&
-	    (!netif_carrier_ok(to->dev) || !netif_running(to->dev))) {
+	if (rcu_access_pointer(fwd.port->backup_port) &&
+	    (!netif_carrier_ok(fwd.port->dev) ||
+	     !netif_running(fwd.port->dev))) {
 		struct net_bridge_port *backup_port;
 
-		backup_port = rcu_dereference(to->backup_port);
+		backup_port = rcu_dereference(fwd.port->backup_port);
 		if (unlikely(!backup_port))
 			goto out;
-		BR_INPUT_SKB_CB(skb)->backup_nhid = READ_ONCE(to->backup_nhid);
-		to = backup_port;
+		BR_INPUT_SKB_CB(skb)->backup_nhid = READ_ONCE(fwd.port->backup_nhid);
+		fwd.port = backup_port;
+		fwd.vlan = NULL;
 	}
 
-	fwd.port = to;
-	fwd.vlan = NULL;
 	if (should_deliver(&fwd, skb)) {
 		if (local_rcv)
 			deliver_clone(&fwd, skb, local_orig);
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index c52613431f886..2c05ebc1299d1 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -333,8 +333,9 @@ static void update_headroom(struct net_bridge *br, int new_hr)
  */
 static void del_nbp(struct net_bridge_port *p)
 {
-	struct net_bridge *br = p->br;
+	struct net_bridge_vlan_group *vg;
 	struct net_device *dev = p->dev;
+	struct net_bridge *br = p->br;
 
 	sysfs_remove_link(br->ifobj, p->dev->name);
 
@@ -354,8 +355,10 @@ static void del_nbp(struct net_bridge_port *p)
 		update_headroom(br, get_max_headroom(br));
 	netdev_reset_rx_headroom(dev);
 
-	nbp_vlan_flush(p);
-	br_fdb_delete_by_port(br, p, 0, 1);
+	vg = nbp_vlan_group(p);
+	nbp_vlan_group_unpublish(p);
+	br_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 1);
+	nbp_vlan_flush(p, vg);
 	switchdev_deferred_process();
 	nbp_backup_clear(p);
 
@@ -390,7 +393,7 @@ void br_dev_delete(struct net_device *dev, struct list_head *head)
 	br_mst_uninit(br);
 	br_recalculate_neigh_suppress_enabled(br);
 
-	br_fdb_delete_by_port(br, NULL, 0, 1);
+	br_fdb_cleanup_by_dst(br, br_port_to_dst(NULL), 0, 1);
 
 	timer_shutdown_sync(&br->hello_timer);
 	timer_shutdown_sync(&br->topology_change_timer);
@@ -696,7 +699,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,
 	if (fdb_synced)
 		br_fdb_unsync_static(br, p);
 	list_del_rcu(&p->list);
-	br_fdb_delete_by_port(br, p, 0, 1);
+	br_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 1);
 	nbp_update_port_count(br);
 	netdev_upper_dev_unlink(dev, br->dev);
 err5:
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 4357d78524a68..fc2e381c4fe03 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -86,8 +86,8 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 	struct net_bridge_vlan *vlan;
 	struct net_bridge *br;
 	bool promisc;
-	u16 vid = 0;
 	u8 state;
+	u16 vid;
 
 	if (!p)
 		goto drop;
@@ -107,9 +107,10 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 
 	brmctx = &p->br->multicast_ctx;
 	pmctx = &p->multicast_ctx;
-	if (!br_allowed_ingress(p->br, nbp_vlan_group_rcu(p), skb, &vid,
-				&state, &vlan))
+	if (!br_allowed_ingress(p->br, nbp_vlan_group_rcu(p), skb, &state,
+				&vlan))
 		goto out;
+	vid = vlan ? vlan->vid : 0;
 
 	if (test_bit(BR_PORT_LOCKED_BIT, &p->flags)) {
 		struct net_bridge_fdb_entry *fdb_src =
@@ -120,10 +121,11 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 			 * 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));
+				br_fdb_update(br, p, vlan,
+					      eth_hdr(skb)->h_source,
+					      BIT(BR_FDB_LOCKED));
 			goto drop;
-		} else if (READ_ONCE(fdb_src->dst) != p ||
+		} else if (br_fdb_dst_port(fdb_src) != p ||
 			   test_bit(BR_FDB_LOCAL, &fdb_src->flags)) {
 			/* FDB mismatch. Drop the packet without roaming. */
 			goto drop;
@@ -131,7 +133,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 			/* FDB match, but entry is locked. Refresh it and drop
 			 * the packet.
 			 */
-			br_fdb_update(br, p, eth_hdr(skb)->h_source, vid,
+			br_fdb_update(br, p, vlan, eth_hdr(skb)->h_source,
 				      BIT(BR_FDB_LOCKED));
 			goto drop;
 		}
@@ -141,7 +143,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *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);
+		br_fdb_update(br, p, vlan, eth_hdr(skb)->h_source, 0);
 
 	promisc = !!(br->dev->flags & IFF_PROMISC);
 	local_rcv = promisc;
@@ -223,7 +225,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 
 		if (now != READ_ONCE(dst->used))
 			WRITE_ONCE(dst->used, now);
-		br_forward(READ_ONCE(dst->dst), skb, local_rcv, false);
+		br_forward(br_fdb_dst_read(dst), skb, local_rcv, false);
 	} else {
 		if (!mcast_hit)
 			br_flood(br, vlan, skb, pkt_type, local_rcv, false);
@@ -245,14 +247,14 @@ EXPORT_SYMBOL_GPL(br_handle_frame_finish);
 static void __br_handle_local_finish(struct sk_buff *skb)
 {
 	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
-	u16 vid = 0;
+	struct net_bridge_vlan *vlan;
 
 	/* check if vlan is allowed, to avoid spoofing */
 	if (test_bit(BR_LEARNING_BIT, &p->flags) &&
 	    nbp_state_should_learn(p) &&
 	    !br_opt_get(p->br, BROPT_NO_LL_LEARN) &&
-	    br_should_learn(p, skb, &vid))
-		br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, 0);
+	    br_should_learn(p, skb, &vlan))
+		br_fdb_update(p->br, p, vlan, eth_hdr(skb)->h_source, 0);
 }
 
 /* note: already called with rcu_read_lock */
diff --git a/net/bridge/br_mrp.c b/net/bridge/br_mrp.c
index dce6efa96c4c6..c8cd5b4f3af8f 100644
--- a/net/bridge/br_mrp.c
+++ b/net/bridge/br_mrp.c
@@ -1219,11 +1219,11 @@ static int br_mrp_rcv(struct net_bridge_port *p,
 
 forward:
 	if (p_dst)
-		br_forward(p_dst, skb, true, false);
+		br_forward(br_port_to_dst(p_dst), skb, true, false);
 	if (s_dst)
-		br_forward(s_dst, skb, true, false);
+		br_forward(br_port_to_dst(s_dst), skb, true, false);
 	if (i_dst)
-		br_forward(i_dst, skb, true, false);
+		br_forward(br_port_to_dst(i_dst), skb, true, false);
 
 no_forward:
 	return 1;
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index ae76df0de05a0..f65b8b6ca97c0 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1044,7 +1044,7 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[],
 	}
 
 	if (tb[IFLA_BRPORT_FLUSH])
-		br_fdb_delete_by_port(p->br, p, 0, 0);
+		br_fdb_cleanup_by_dst(p->br, br_port_to_dst(p), 0, 0);
 
 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
 	if (tb[IFLA_BRPORT_MULTICAST_ROUTER]) {
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 67117fb3dc880..05921192ebda1 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -306,9 +306,15 @@ struct net_bridge_fdb_key {
 	u16 vlan_id;
 };
 
+#define BR_DST_VLAN_TAG	BIT(0)
+
+struct net_bridge_dst {
+	unsigned long __private value;
+};
+
 struct net_bridge_fdb_entry {
 	struct rhash_head		rhnode;
-	struct net_bridge_port		*dst;
+	struct net_bridge_dst		dst;
 
 	struct net_bridge_fdb_key	key;
 	struct hlist_node		fdb_node;
@@ -670,6 +676,122 @@ struct br_input_skb_cb {
 #define br_debug(br, format, args...)			\
 	pr_debug("%s: " format,  (br)->dev->name, ##args)
 
+static inline struct net_bridge_dst
+br_dst_read(const struct net_bridge_dst *src)
+{
+	struct net_bridge_dst dst;
+
+	ACCESS_PRIVATE(&dst, value) =
+		READ_ONCE(ACCESS_PRIVATE(src, value));
+
+	return dst;
+}
+
+static inline void br_dst_write(struct net_bridge_dst *dst,
+				struct net_bridge_dst src)
+{
+	WRITE_ONCE(ACCESS_PRIVATE(dst, value),
+		   ACCESS_PRIVATE(&src, value));
+}
+
+static inline bool br_dst_equal(struct net_bridge_dst dst1,
+				struct net_bridge_dst dst2)
+{
+	return ACCESS_PRIVATE(&dst1, value) ==
+	       ACCESS_PRIVATE(&dst2, value);
+}
+
+static inline struct net_bridge_dst
+br_port_to_dst(const struct net_bridge_port *p)
+{
+	struct net_bridge_dst dst;
+
+	ACCESS_PRIVATE(&dst, value) = (unsigned long)p;
+
+	return dst;
+}
+
+static inline struct net_bridge_dst
+br_vlan_to_dst(const struct net_bridge_vlan *v)
+{
+	struct net_bridge_dst dst;
+
+	ACCESS_PRIVATE(&dst, value) = (unsigned long)v | BR_DST_VLAN_TAG;
+
+	return dst;
+}
+
+static inline void br_dst_decode(struct net_bridge_dst dst,
+				 struct net_bridge_port **port,
+				 struct net_bridge_vlan **vlan)
+{
+	struct net_bridge_vlan *v;
+	unsigned long value;
+
+	value = ACCESS_PRIVATE(&dst, value);
+	if (!(value & BR_DST_VLAN_TAG)) {
+		*port = (struct net_bridge_port *)value;
+		*vlan = NULL;
+		return;
+	}
+
+	v = (struct net_bridge_vlan *)(value & ~BR_DST_VLAN_TAG);
+	*port = v->port;
+	*vlan = v;
+}
+
+static inline struct net_bridge_port *
+br_dst_port(struct net_bridge_dst dst)
+{
+	struct net_bridge_port *p;
+	struct net_bridge_vlan *v;
+
+	br_dst_decode(dst, &p, &v);
+
+	return p;
+}
+
+static inline struct net_bridge_vlan *
+br_dst_vlan(struct net_bridge_dst dst)
+{
+	unsigned long value;
+
+	value = ACCESS_PRIVATE(&dst, value);
+	if (!(value & BR_DST_VLAN_TAG))
+		return NULL;
+
+	return (struct net_bridge_vlan *)(value & ~BR_DST_VLAN_TAG);
+}
+
+static inline struct net_bridge_dst
+br_fdb_dst_read(const struct net_bridge_fdb_entry *fdb)
+{
+	return br_dst_read(&fdb->dst);
+}
+
+static inline void br_fdb_dst_write(struct net_bridge_fdb_entry *fdb,
+				    struct net_bridge_dst dst)
+{
+	br_dst_write(&fdb->dst, dst);
+}
+
+static inline bool
+br_fdb_dst_replace(struct net_bridge_fdb_entry *fdb,
+		   struct net_bridge_dst old,
+		   struct net_bridge_dst new)
+{
+	unsigned long old_value = ACCESS_PRIVATE(&old, value);
+
+	return cmpxchg(&ACCESS_PRIVATE(&fdb->dst, value), old_value,
+		       ACCESS_PRIVATE(&new, value)) == old_value;
+}
+
+static inline struct net_bridge_port *
+br_fdb_dst_port(const struct net_bridge_fdb_entry *fdb)
+{
+	return br_dst_port(br_fdb_dst_read(fdb));
+}
+
 /* called under bridge lock */
 static inline int br_is_root_bridge(const struct net_bridge *br)
 {
@@ -879,8 +1001,8 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr);
 void br_fdb_cleanup(struct work_struct *work);
 int br_fdb_toggle_local_vlan_0(struct net_bridge *br, bool on,
 			       struct netlink_ext_ack *extack);
-void br_fdb_delete_by_port(struct net_bridge *br,
-			   const struct net_bridge_port *p, u16 vid, int do_all);
+void br_fdb_cleanup_by_dst(struct net_bridge *br,
+			   struct net_bridge_dst dst, u16 vid, int do_all);
 struct net_bridge_fdb_entry *br_fdb_find_rcu(struct net_bridge *br,
 					     const unsigned char *addr,
 					     __u16 vid);
@@ -889,7 +1011,8 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf, unsigned long count,
 int br_fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,
 		     const unsigned char *addr, u16 vid);
 void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
-		   const unsigned char *addr, u16 vid, unsigned long flags);
+		   struct net_bridge_vlan *vlan, const unsigned char *addr,
+		   unsigned long flags);
 
 int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
 		  struct net_device *dev, const unsigned char *addr, u16 vid,
@@ -922,7 +1045,7 @@ enum br_pkt_type {
 	BR_PKT_BROADCAST
 };
 int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb);
-void br_forward(const struct net_bridge_port *to, struct sk_buff *skb,
+void br_forward(struct net_bridge_dst dst, struct sk_buff *skb,
 		bool local_rcv, bool local_orig);
 int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
 void br_flood(struct net_bridge *br, struct net_bridge_vlan *v,
@@ -1598,11 +1721,11 @@ br_multicast_ctx_options_equal(const struct net_bridge_mcast *brmctx1,
 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
 bool br_allowed_ingress(const struct net_bridge *br,
 			struct net_bridge_vlan_group *vg, struct sk_buff *skb,
-			u16 *vid, u8 *state,
-			struct net_bridge_vlan **vlan);
+			u8 *state, struct net_bridge_vlan **vlan);
 bool br_allowed_egress(struct net_bridge_vlan_group *vg,
 		       const struct sk_buff *skb);
-bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid);
+bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb,
+		     struct net_bridge_vlan **vlan);
 struct sk_buff *br_handle_vlan(struct net_bridge *br,
 			       const struct net_bridge_port *port,
 			       struct net_bridge_vlan_group *vg,
@@ -1630,7 +1753,9 @@ int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid,
 int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
 		 bool *changed, struct netlink_ext_ack *extack);
 int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);
-void nbp_vlan_flush(struct net_bridge_port *port);
+void nbp_vlan_group_unpublish(struct net_bridge_port *port);
+void nbp_vlan_flush(struct net_bridge_port *port,
+		    struct net_bridge_vlan_group *vg);
 int nbp_vlan_init(struct net_bridge_port *port, struct netlink_ext_ack *extack);
 int nbp_get_num_vlan_infos(struct net_bridge_port *p, u32 filter_mask);
 void br_vlan_get_stats(const struct net_bridge_vlan *v,
@@ -1721,7 +1846,7 @@ static inline u16 br_vlan_flags(const struct net_bridge_vlan *v, u16 pvid)
 static inline bool br_allowed_ingress(const struct net_bridge *br,
 				      struct net_bridge_vlan_group *vg,
 				      struct sk_buff *skb,
-				      u16 *vid, u8 *state,
+				      u8 *state,
 				      struct net_bridge_vlan **vlan)
 
 {
@@ -1736,8 +1861,10 @@ static inline bool br_allowed_egress(struct net_bridge_vlan_group *vg,
 }
 
 static inline bool br_should_learn(struct net_bridge_port *p,
-				   struct sk_buff *skb, u16 *vid)
+				   struct sk_buff *skb,
+				   struct net_bridge_vlan **vlan)
 {
+	*vlan = NULL;
 	return true;
 }
 
@@ -1787,7 +1914,13 @@ static inline int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
 	return -EOPNOTSUPP;
 }
 
-static inline void nbp_vlan_flush(struct net_bridge_port *port)
+static inline void nbp_vlan_group_unpublish(struct net_bridge_port *port)
+{
+}
+
+static inline void
+nbp_vlan_flush(struct net_bridge_port *port,
+	       struct net_bridge_vlan_group *vg)
 {
 }
 
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index a7e5422eb5d14..2e5190278c903 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -114,7 +114,7 @@ void br_stp_disable_port(struct net_bridge_port *p)
 	timer_delete(&p->hold_timer);
 
 	if (!rcu_access_pointer(p->backup_port))
-		br_fdb_delete_by_port(br, p, 0, 0);
+		br_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 0);
 	br_multicast_disable_port(p);
 
 	br_configuration_update(br);
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 990c6b38fd397..10f3aea6a1f82 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -129,7 +129,7 @@ static void br_switchdev_fdb_populate(struct net_bridge *br,
 				      const struct net_bridge_fdb_entry *fdb,
 				      const void *ctx)
 {
-	const struct net_bridge_port *p = READ_ONCE(fdb->dst);
+	const struct net_bridge_port *p = br_fdb_dst_port(fdb);
 
 	item->addr = fdb->key.addr.addr;
 	item->vid = fdb->key.vlan_id;
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index b9bcafa7f034c..621d62a063d98 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -191,7 +191,8 @@ static BRPORT_ATTR(hold_timer, 0444, show_hold_timer, NULL);
 
 static int store_flush(struct net_bridge_port *p, unsigned long v)
 {
-	br_fdb_delete_by_port(p->br, p, 0, 0); // Don't delete local entry
+	/* Don't delete local entry */
+	br_fdb_cleanup_by_dst(p->br, br_port_to_dst(p), 0, 0);
 	return 0;
 }
 static BRPORT_ATTR(flush, 0200, NULL, store_flush);
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index ce5aa15c45402..0675f74cf1b99 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -429,22 +429,34 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags,
 	goto out;
 }
 
-static void __vlan_del(struct net_bridge_vlan *v)
+static void __vlan_unpublish(struct net_bridge_vlan_group *vg,
+			     struct net_bridge_vlan *v)
+{
+	__vlan_delete_pvid(vg, v);
+	if (!br_vlan_is_master(v)) {
+		struct net_bridge_vlan *masterv = v->brvlan;
+
+		rhashtable_remove_fast(&vg->vlan_hash, &v->vnode,
+				       br_vlan_rht_params);
+		__vlan_del_list(v);
+		/* -1 because br_vlan_put_master() is called later */
+		br_vlan_rebuild_port_array(masterv,
+					   br_vlan_num_ports(masterv) - 1);
+	}
+}
+
+static void __vlan_del(struct net_bridge_vlan_group *vg,
+		       struct net_bridge_vlan *v)
 {
 	struct net_bridge_vlan *masterv = v;
-	struct net_bridge_vlan_group *vg;
 	struct net_bridge_port *p = NULL;
 	int err;
 
-	if (br_vlan_is_master(v)) {
-		vg = br_vlan_group(v->br);
-	} else {
+	if (!br_vlan_is_master(v)) {
 		p = v->port;
-		vg = nbp_vlan_group(v->port);
 		masterv = v->brvlan;
 	}
 
-	__vlan_delete_pvid(vg, v);
 	if (p) {
 		err = __vlan_vid_del(p->dev, p->br, v);
 		if (err)
@@ -467,12 +479,6 @@ static void __vlan_del(struct net_bridge_vlan *v)
 
 	if (masterv != v) {
 		vlan_tunnel_info_del(vg, v);
-		rhashtable_remove_fast(&vg->vlan_hash, &v->vnode,
-				       br_vlan_rht_params);
-		__vlan_del_list(v);
-		/* -1 because br_vlan_put_master() is called later */
-		br_vlan_rebuild_port_array(masterv,
-					   br_vlan_num_ports(masterv) - 1);
 		nbp_vlan_set_vlan_dev_state(p, v->vid);
 		br_multicast_toggle_one_vlan(v, false);
 		br_multicast_port_ctx_deinit(&v->port_mcast_ctx);
@@ -509,7 +515,8 @@ static void __vlan_flush(const struct net_bridge *br,
 		}
 		v_end = vlan->vid;
 
-		__vlan_del(vlan);
+		__vlan_unpublish(vg, vlan);
+		__vlan_del(vg, vlan);
 	}
 
 	/* notify about the last/whole vlan range */
@@ -583,13 +590,13 @@ struct sk_buff *br_handle_vlan(struct net_bridge *br,
 /* Called under RCU */
 static bool __allowed_ingress(const struct net_bridge *br,
 			      struct net_bridge_vlan_group *vg,
-			      struct sk_buff *skb, u16 *vid,
-			      u8 *state,
+			      struct sk_buff *skb, u8 *state,
 			      struct net_bridge_vlan **vlan)
 {
 	struct pcpu_sw_netstats *stats;
 	struct net_bridge_vlan *v;
 	bool tagged;
+	u16 vid;
 
 	BR_INPUT_SKB_CB(skb)->vlan_filtered = true;
 	/* If vlan tx offload is disabled on bridge device and frame was
@@ -603,7 +610,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 			return false;
 	}
 
-	if (!br_vlan_get_tag(skb, vid)) {
+	if (!br_vlan_get_tag(skb, &vid)) {
 		/* Tagged frame */
 		if (skb->vlan_proto != br->vlan_proto) {
 			/* Protocol-mismatch, empty out vlan_tci for new tag */
@@ -615,7 +622,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 
 			skb_pull(skb, ETH_HLEN);
 			skb_reset_mac_len(skb);
-			*vid = 0;
+			vid = 0;
 			tagged = false;
 		} else {
 			tagged = true;
@@ -625,7 +632,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 		tagged = false;
 	}
 
-	if (!*vid) {
+	if (!vid) {
 		v = vg ? rcu_dereference(vg->pvid) : NULL;
 		/* Frame had a tag with VID 0 or did not have a tag.
 		 * See if pvid is set on this port.  That tells us which
@@ -637,7 +644,6 @@ static bool __allowed_ingress(const struct net_bridge *br,
 		/* PVID is set on this port.  Any untagged or priority-tagged
 		 * ingress frame is considered to belong to this vlan.
 		 */
-		*vid = v->vid;
 		if (likely(!tagged))
 			/* Untagged Frame. */
 			__vlan_hwaccel_put_tag(skb, br->vlan_proto, v->vid);
@@ -649,7 +655,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 			 */
 			skb->vlan_tci |= v->vid;
 	} else {
-		v = br_vlan_find(vg, *vid);
+		v = br_vlan_find(vg, vid);
 	}
 
 	if (!v || !br_vlan_should_use(v))
@@ -680,8 +686,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 
 bool br_allowed_ingress(const struct net_bridge *br,
 			struct net_bridge_vlan_group *vg, struct sk_buff *skb,
-			u16 *vid, u8 *state,
-			struct net_bridge_vlan **vlan)
+			u8 *state, struct net_bridge_vlan **vlan)
 {
 	/* If VLAN filtering is disabled on the bridge, all packets are
 	 * permitted.
@@ -692,7 +697,7 @@ bool br_allowed_ingress(const struct net_bridge *br,
 		return true;
 	}
 
-	return __allowed_ingress(br, vg, skb, vid, state, vlan);
+	return __allowed_ingress(br, vg, skb, state, vlan);
 }
 
 /* Called under RCU. */
@@ -716,11 +721,15 @@ bool br_allowed_egress(struct net_bridge_vlan_group *vg,
 }
 
 /* Called under RCU */
-bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid)
+bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb,
+		     struct net_bridge_vlan **vlan)
 {
 	struct net_bridge_vlan_group *vg;
 	struct net_bridge *br = p->br;
 	struct net_bridge_vlan *v;
+	u16 vid;
+
+	*vlan = NULL;
 
 	/* If filtering was disabled at input, let it pass. */
 	if (!br_opt_get(br, BROPT_VLAN_ENABLED))
@@ -730,20 +739,22 @@ bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid)
 	if (!vg || !READ_ONCE(vg->num_vlans))
 		return false;
 
-	if (!br_vlan_get_tag(skb, vid) && skb->vlan_proto != br->vlan_proto)
-		*vid = 0;
+	if (!br_vlan_get_tag(skb, &vid) && skb->vlan_proto != br->vlan_proto)
+		vid = 0;
 
-	if (!*vid) {
+	if (!vid) {
 		v = rcu_dereference(vg->pvid);
 		if (!v || !br_vlan_state_allowed(br_vlan_get_state(v), true))
 			return false;
-		*vid = v->vid;
+		*vlan = v;
 		return true;
 	}
 
-	v = br_vlan_find(vg, *vid);
-	if (v && br_vlan_state_allowed(br_vlan_get_state(v), true))
+	v = br_vlan_find(vg, vid);
+	if (v && br_vlan_state_allowed(br_vlan_get_state(v), true)) {
+		*vlan = v;
 		return true;
+	}
 
 	return false;
 }
@@ -866,10 +877,11 @@ int br_vlan_delete(struct net_bridge *br, u16 vid)
 		return -ENOENT;
 
 	br_fdb_find_delete_local(br, NULL, br->dev->dev_addr, vid);
-	br_fdb_delete_by_port(br, NULL, vid, 0);
+	br_fdb_cleanup_by_dst(br, br_port_to_dst(NULL), vid, 0);
 
 	vlan_tunnel_info_del(vg, v);
-	__vlan_del(v);
+	__vlan_unpublish(vg, v);
+	__vlan_del(vg, v);
 
 	return 0;
 }
@@ -1385,30 +1397,41 @@ int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
  */
 int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
 {
+	struct net_bridge_vlan_group *vg;
 	struct net_bridge_vlan *v;
 
 	ASSERT_RTNL();
 
-	v = br_vlan_find(nbp_vlan_group(port), vid);
+	vg = nbp_vlan_group(port);
+	v = br_vlan_find(vg, vid);
 	if (!v)
 		return -ENOENT;
-	br_fdb_find_delete_local(port->br, port, port->dev->dev_addr, vid);
-	br_fdb_delete_by_port(port->br, port, vid, 0);
-	__vlan_del(v);
+	__vlan_unpublish(vg, v);
+	synchronize_net();
+	/* Traffic may still use v through cached fdb dsts until they are
+	 * cleaned below. This is acceptable during vlan deletion. Above we
+	 * drain the readers that could republish the dst before cleaning it
+	 */
+	br_fdb_cleanup_by_dst(port->br, br_vlan_to_dst(v), vid, 0);
+	__vlan_del(vg, v);
 
 	return 0;
 }
 
-void nbp_vlan_flush(struct net_bridge_port *port)
+void nbp_vlan_group_unpublish(struct net_bridge_port *port)
 {
-	struct net_bridge_vlan_group *vg;
-
 	ASSERT_RTNL();
 
-	vg = nbp_vlan_group(port);
-	__vlan_flush(port->br, port, vg);
 	RCU_INIT_POINTER(port->vlgrp, NULL);
 	synchronize_net();
+}
+
+void nbp_vlan_flush(struct net_bridge_port *port,
+		    struct net_bridge_vlan_group *vg)
+{
+	ASSERT_RTNL();
+
+	__vlan_flush(port->br, port, vg);
 	__vlan_group_free(vg);
 }
 
diff --git a/net/bridge/netfilter/nft_reject_bridge.c b/net/bridge/netfilter/nft_reject_bridge.c
index cd2b04236a99c..92b488793914a 100644
--- a/net/bridge/netfilter/nft_reject_bridge.c
+++ b/net/bridge/netfilter/nft_reject_bridge.c
@@ -55,7 +55,7 @@ static void nft_reject_br_send_v4_tcp_reset(struct net *net,
 
 	nft_reject_br_push_etherhdr(oldskb, nskb);
 
-	br_forward(br_port_get_rcu(dev), nskb, false, true);
+	br_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);
 }
 
 static void nft_reject_br_send_v4_unreach(struct net *net,
@@ -71,7 +71,7 @@ static void nft_reject_br_send_v4_unreach(struct net *net,
 
 	nft_reject_br_push_etherhdr(oldskb, nskb);
 
-	br_forward(br_port_get_rcu(dev), nskb, false, true);
+	br_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);
 }
 
 static void nft_reject_br_send_v6_tcp_reset(struct net *net,
@@ -87,7 +87,7 @@ static void nft_reject_br_send_v6_tcp_reset(struct net *net,
 
 	nft_reject_br_push_etherhdr(oldskb, nskb);
 
-	br_forward(br_port_get_rcu(dev), nskb, false, true);
+	br_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);
 }
 
 
@@ -104,7 +104,7 @@ static void nft_reject_br_send_v6_unreach(struct net *net,
 
 	nft_reject_br_push_etherhdr(oldskb, nskb);
 
-	br_forward(br_port_get_rcu(dev), nskb, false, true);
+	br_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);
 }
 
 static void nft_reject_bridge_eval(const struct nft_expr *expr,

3/2 2026/10/01 04:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 23883
							output: 25
							thoughts: 503
						

Thoughts:
**Initial Assessment of Kernel Patch Series**

Okay, so the user wants me to dive into a patch series applied to the kernel. My first thought is to meticulously evaluate this, so I need to understand what's been changed. The most immediate step is to get the lowdown on the commit itself – the details, the log, and most importantly, the actual `diff`.

Let's see what tools I have available... I've got `grepper`, `read-file`, `codesearch-dir-index`, and `set-results`. Right, `grepper` is basically a wrapper around `git grep`, so that looks like a good starting point for poking around. Time to inspect the `git log` or commit messages, or something similar, if possible.

It looks like the changes touch a whole slew of files. Looking at the modified files, it's pretty clear this impacts the Linux bridge networking code: `net/bridge/*`.

Okay, time for a quick sanity check: is this going to be easily reproducible and testable? Thankfully, Linux bridge is a core feature, totally reachable and fuzzable. This should be testable in standard virtualized environments like QEMU or GCE. It's accessible via `rtnetlink` (for `ip link`, bridge `fdb`, etc.), `tun/tap`, `veth`, and packet sockets. Syzkaller even heavily fuzzez bridge networking. Good, that makes life easier!

Now, back to the core of it all – what's the actual *patch* doing? I need to understand the fundamental changes. Let's read the `git log` or commit message to get some context, if available. If not, I'll need to analyze the code changes directly, focusing on those `net/bridge/br_*.c` files. I can even use `grepper` and search for something within those files? I should start by looking at `net/bridge/Kconfig`.



4/2 2026/10/01 04:45 tool grepper
0m Args:
{
  "Expression": "config BRIDGE",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/Kconfig-5-\nnet/bridge/Kconfig:6:config BRIDGE\nnet/bridge/Kconfig-7-\ttristate \"802.1d Ethernet Bridging\"\n--\nnet/bridge/Kconfig-35-\nnet/bridge/Kconfig:36:config BRIDGE_IGMP_SNOOPING\nnet/bridge/Kconfig-37-\tbool \"IGMP/MLD snooping\"\n--\nnet/bridge/Kconfig-49-\nnet/bridge/Kconfig:50:config BRIDGE_VLAN_FILTERING\nnet/bridge/Kconfig-51-\tbool \"VLAN filtering\"\n--\nnet/bridge/Kconfig-63-\nnet/bridge/Kconfig:64:config BRIDGE_MRP\nnet/bridge/Kconfig-65-\tbool \"MRP protocol\"\n--\nnet/bridge/Kconfig-75-\nnet/bridge/Kconfig:76:config BRIDGE_CFM\nnet/bridge/Kconfig-77-\tbool \"CFM protocol\"\n--\nnet/bridge/netfilter/Kconfig=28=config NF_CONNTRACK_BRIDGE\n--\nnet/bridge/netfilter/Kconfig-42-# old sockopt interface and eval loop\nnet/bridge/netfilter/Kconfig:43:config BRIDGE_NF_EBTABLES_LEGACY\nnet/bridge/netfilter/Kconfig-44-\ttristate \"Legacy EBTABLES support\"\n--\nnet/bridge/netfilter/Kconfig-52-\nnet/bridge/netfilter/Kconfig:53:menuconfig BRIDGE_NF_EBTABLES\nnet/bridge/netfilter/Kconfig-54-\ttristate \"Ethernet Bridge tables (ebtables) support\"\n--\nnet/bridge/netfilter/Kconfig=62=if BRIDGE_NF_EBTABLES\n--\nnet/bridge/netfilter/Kconfig-66-#\nnet/bridge/netfilter/Kconfig:67:config BRIDGE_EBT_BROUTE\nnet/bridge/netfilter/Kconfig-68-\ttristate \"ebt: broute table support\"\n--\nnet/bridge/netfilter/Kconfig-77-\nnet/bridge/netfilter/Kconfig:78:config BRIDGE_EBT_T_FILTER\nnet/bridge/netfilter/Kconfig-79-\ttristate \"ebt: filter table support\"\n--\nnet/bridge/netfilter/Kconfig-87-\nnet/bridge/netfilter/Kconfig:88:config BRIDGE_EBT_T_NAT\nnet/bridge/netfilter/Kconfig-89-\ttristate \"ebt: nat table support\"\n--\nnet/bridge/netfilter/Kconfig-99-#\nnet/bridge/netfilter/Kconfig:100:config BRIDGE_EBT_802_3\nnet/bridge/netfilter/Kconfig-101-\ttristate \"ebt: 802.3 filter support\"\n--\nnet/bridge/netfilter/Kconfig-106-\nnet/bridge/netfilter/Kconfig:107:config BRIDGE_EBT_AMONG\nnet/bridge/netfilter/Kconfig-108-\ttristate \"ebt: among filter support\"\n--\nnet/bridge/netfilter/Kconfig-115-\nnet/bridge/netfilter/Kconfig:116:config BRIDGE_EBT_ARP\nnet/bridge/netfilter/Kconfig-117-\ttristate \"ebt: ARP filter support\"\n--\nnet/bridge/netfilter/Kconfig-123-\nnet/bridge/netfilter/Kconfig:124:config BRIDGE_EBT_IP\nnet/bridge/netfilter/Kconfig-125-\ttristate \"ebt: IP filter support\"\n--\nnet/bridge/netfilter/Kconfig-131-\nnet/bridge/netfilter/Kconfig:132:config BRIDGE_EBT_IP6\nnet/bridge/netfilter/Kconfig-133-\ttristate \"ebt: IP6 filter support\"\n--\nnet/bridge/netfilter/Kconfig-140-\nnet/bridge/netfilter/Kconfig:141:config BRIDGE_EBT_LIMIT\nnet/bridge/netfilter/Kconfig-142-\ttristate \"ebt: limit match support\"\n--\nnet/bridge/netfilter/Kconfig-150-\nnet/bridge/netfilter/Kconfig:151:config BRIDGE_EBT_MARK\nnet/bridge/netfilter/Kconfig-152-\ttristate \"ebt: mark filter support\"\n--\nnet/bridge/netfilter/Kconfig-160-\nnet/bridge/netfilter/Kconfig:161:config BRIDGE_EBT_PKTTYPE\nnet/bridge/netfilter/Kconfig-162-\ttristate \"ebt: packet type filter support\"\n--\nnet/bridge/netfilter/Kconfig-170-\nnet/bridge/netfilter/Kconfig:171:config BRIDGE_EBT_STP\nnet/bridge/netfilter/Kconfig-172-\ttristate \"ebt: STP filter support\"\n--\nnet/bridge/netfilter/Kconfig-178-\nnet/bridge/netfilter/Kconfig:179:config BRIDGE_EBT_VLAN\nnet/bridge/netfilter/Kconfig-180-\ttristate \"ebt: 802.1Q VLAN filter support\"\n--\nnet/bridge/netfilter/Kconfig-188-#\nnet/bridge/netfilter/Kconfig:189:config BRIDGE_EBT_ARPREPLY\nnet/bridge/netfilter/Kconfig-190-\ttristate \"ebt: arp reply target support\"\n--\nnet/bridge/netfilter/Kconfig-197-\nnet/bridge/netfilter/Kconfig:198:config BRIDGE_EBT_DNAT\nnet/bridge/netfilter/Kconfig-199-\ttristate \"ebt: dnat target support\"\n--\nnet/bridge/netfilter/Kconfig-205-\nnet/bridge/netfilter/Kconfig:206:config BRIDGE_EBT_MARK_T\nnet/bridge/netfilter/Kconfig-207-\ttristate \"ebt: mark target support\"\n--\nnet/bridge/netfilter/Kconfig-215-\nnet/bridge/netfilter/Kconfig:216:config BRIDGE_EBT_REDIRECT\nnet/bridge/netfilter/Kconfig-217-\ttristate \"ebt: redirect target support\"\n--\nnet/bridge/netfilter/Kconfig-223-\nnet/bridge/netfilter/Kconfig:224:config BRIDGE_EBT_SNAT\nnet/bridge/netfilter/Kconfig-225-\ttristate \"ebt: snat target support\"\n--\nnet/bridge/netfilter/Kconfig-233-#\nnet/bridge/netfilter/Kconfig:234:config BRIDGE_EBT_LOG\nnet/bridge/netfilter/Kconfig-235-\ttristate \"ebt: log support\"\n--\nnet/bridge/netfilter/Kconfig-242-\nnet/bridge/netfilter/Kconfig:243:config BRIDGE_EBT_NFLOG\nnet/bridge/netfilter/Kconfig-244-\ttristate \"ebt: nflog support\"\n"
}

5/2 2026/10/01 04:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 26621
							output: 32
							thoughts: 20
						

Thoughts:
Here's a summary of my thought process, aimed at an expert like yourself:

**Diving into the Bridge Configuration**

Okay, so I need to get a handle on the bridge configuration options. Let's start with `net/bridge/Kconfig`. My gut feeling is that the core parameters and dependencies will be defined in that file, so let's check around lines 5 to 60. I expect to see a high-level overview of the configurable features related to bridging, potentially including things like whether bridging functionality is even enabled by default and what the core configuration parameters are likely to be. I'm hoping it clearly outlines the dependencies on other kernel subsystems as well, which will allow me to track the effects of enabling or disabling particular bridge features. With a solid understanding of the base configuration, I can begin to refine my investigation.



6/2 2026/10/01 04:45 tool read-file
0m Args:
{
  "File": "net/bridge/Kconfig",
  "FirstLine": 1,
  "LineCount": 60
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0-only\n   2:\t#\n   3:\t# 802.1d Ethernet Bridging\n   4:\t#\n   5:\t\n   6:\tconfig BRIDGE\n   7:\t\ttristate \"802.1d Ethernet Bridging\"\n   8:\t\tselect LLC\n   9:\t\tselect STP\n  10:\t\thelp\n  11:\t\t  If you say Y here, then your Linux box will be able to act as an\n  12:\t\t  Ethernet bridge, which means that the different Ethernet segments it\n  13:\t\t  is connected to will appear as one Ethernet to the participants.\n  14:\t\t  Several such bridges can work together to create even larger\n  15:\t\t  networks of Ethernets using the IEEE 802.1 spanning tree algorithm.\n  16:\t\t  As this is a standard, Linux bridges will cooperate properly with\n  17:\t\t  other third party bridge products.\n  18:\t\n  19:\t\t  In order to use the Ethernet bridge, you'll need the bridge\n  20:\t\t  configuration tools; see \u003cfile:Documentation/networking/bridge.rst\u003e\n  21:\t\t  for location. Please read the Bridge mini-HOWTO for more\n  22:\t\t  information.\n  23:\t\n  24:\t\t  If you enable iptables support along with the bridge support then you\n  25:\t\t  turn your bridge into a bridging IP firewall.\n  26:\t\t  iptables will then see the IP packets being bridged, so you need to\n  27:\t\t  take this into account when setting up your firewall rules.\n  28:\t\t  Enabling arptables support when bridging will let arptables see\n  29:\t\t  bridged ARP traffic in the arptables FORWARD chain.\n  30:\t\n  31:\t\t  To compile this code as a module, choose M here: the module\n  32:\t\t  will be called bridge.\n  33:\t\n  34:\t\t  If unsure, say N.\n  35:\t\n  36:\tconfig BRIDGE_IGMP_SNOOPING\n  37:\t\tbool \"IGMP/MLD snooping\"\n  38:\t\tdepends on BRIDGE\n  39:\t\tdepends on INET\n  40:\t\tdefault y\n  41:\t\thelp\n  42:\t\t  If you say Y here, then the Ethernet bridge will be able selectively\n  43:\t\t  forward multicast traffic based on IGMP/MLD traffic received from\n  44:\t\t  each port.\n  45:\t\n  46:\t\t  Say N to exclude this support and reduce the binary size.\n  47:\t\n  48:\t\t  If unsure, say Y.\n  49:\t\n  50:\tconfig BRIDGE_VLAN_FILTERING\n  51:\t\tbool \"VLAN filtering\"\n  52:\t\tdepends on BRIDGE\n  53:\t\tdepends on VLAN_8021Q\n  54:\t\tdefault n\n  55:\t\thelp\n  56:\t\t  If you say Y here, then the Ethernet bridge will be able selectively\n  57:\t\t  receive and forward traffic based on VLAN information in the packet\n  58:\t\t  any VLAN information configured on the bridge port or bridge device.\n  59:\t\n  60:\t\t  Say N to exclude this support and reduce the binary size.\n"
}

7/2 2026/10/01 04:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 27677
							output: 31
							thoughts: 1370
						

Thoughts:
**FDB and VLAN Subsystem Deep Dive: WorthFuzzing=true**

Okay, let's break this down. Seeing `CONFIG_BRIDGE` and `CONFIG_BRIDGE_VLAN_FILTERING` in the diff immediately flags this as potentially interesting. The changes touch VLAN filtering and FDB management within the Ethernet bridge, a core networking component. This isn't just a minor tweak; we're looking at a fundamental shift in how the bridge handles destinations.

Looking at the code, the key change is in `br_private.h`. The `dst` field in the `net_bridge_fdb_entry` is now a `struct net_bridge_dst`, which cleverly packs either a `struct net_bridge_port *` or a tagged `struct net_bridge_vlan *`. This is a significant architectural decision, allowing FDB entries to directly point to VLAN destinations. Numerous functions are introduced/modified to handle this new structure:  `br_dst_read`, `br_dst_write`,  `br_dst_equal` and various others for decoding, port/vlan access, and FDB manipulation.

My initial thoughts are this will involve significant changes to concurrency management and, likely, locking. The new functions for updating the FDB, like `br_fdb_dst_replace`, are the focus, because it is using `cmpxchg`. The presence of `lockdep_assert(rcu_read_lock_held() || lockdep_rtnl_is_held());` in `br_fdb_resolve_dst` is a huge red flag: it means this code is sensitive to locking and concurrency. Also, `synchronize_net()` calls in `nbp_vlan_delete` and `nbp_vlan_group_unpublish` signal careful reference management and the handling of potentially concurrent readers and writers of the FDB and VLAN groups. This is a complex area.

This is a substantial architectural change! We're talking about direct VLAN destination support in the FDB, atomic replacement, and synchronization during VLAN/port deletion, unpublishing, etc. This has the potential for race conditions and subtle memory corruption bugs if not handled perfectly.

Is this reachable code? Absolutely. The Linux bridge is a core networking feature. It's fully configurable and easily exercised using standard environments, like QEMU with virtual interfaces. Netlink (rtnetlink) messages like `RTM_NEWLINK`, `RTM_NEWNEIGH`, `RTM_DELNEIGH`, and packet transmission are how the bridge functionality is utilized.

Does this warrant fuzzing? Yes, without a doubt. `WorthFuzzing = true`. This patch modifies core networking data structures, alters locking/RCU semantics, introduces lockdep assertions, changes concurrency patterns (cmpxchg on dst), and handles lifetime and deletion of bridge VLANs and FDB entries. It checks all the "WorthFuzzing" criteria: core subsystem modifications (networking), refactoring/restructuring of data structures, assertions, and is reachable via virtual buses (netlink).

Now, to determine `EnableConfigs` and `FocusSymbols`, I'll start by checking `net/bridge/Makefile` to see exactly what configurations are needed to build and reach this code.



8/2 2026/10/01 04:45 tool read-file
0m Args:
{
  "File": "net/bridge/Makefile",
  "FirstLine": 1,
  "LineCount": 50
}

Results:
{
  "Contents": "   1:\t# SPDX-License-Identifier: GPL-2.0\n   2:\t#\n   3:\t# Makefile for the IEEE 802.1d ethernet bridging layer.\n   4:\t#\n   5:\t\n   6:\tobj-$(CONFIG_BRIDGE) += bridge.o\n   7:\t\n   8:\tbridge-y\t:= br.o br_device.o br_fdb.o br_forward.o br_if.o br_input.o \\\n   9:\t\t\t\tbr_ioctl.o br_stp.o br_stp_bpdu.o \\\n  10:\t\t\t\tbr_stp_if.o br_stp_timer.o br_netlink.o \\\n  11:\t\t\t\tbr_netlink_tunnel.o br_arp_nd_proxy.o\n  12:\t\n  13:\tbridge-$(CONFIG_SYSFS) += br_sysfs_if.o br_sysfs_br.o\n  14:\t\n  15:\tbridge-$(subst m,y,$(CONFIG_BRIDGE_NETFILTER)) += br_nf_core.o\n  16:\t\n  17:\tbr_netfilter-y := br_netfilter_hooks.o\n  18:\tbr_netfilter-$(subst m,y,$(CONFIG_IPV6)) += br_netfilter_ipv6.o\n  19:\tobj-$(CONFIG_BRIDGE_NETFILTER) += br_netfilter.o\n  20:\t\n  21:\tbridge-$(CONFIG_BRIDGE_IGMP_SNOOPING) += br_multicast.o br_mdb.o br_multicast_eht.o\n  22:\t\n  23:\tbridge-$(CONFIG_BRIDGE_VLAN_FILTERING) += br_vlan.o br_vlan_tunnel.o br_vlan_options.o br_mst.o\n  24:\t\n  25:\tbridge-$(CONFIG_NET_SWITCHDEV) += br_switchdev.o\n  26:\t\n  27:\tobj-$(CONFIG_NETFILTER) += netfilter/\n  28:\t\n  29:\tbridge-$(CONFIG_BRIDGE_MRP)\t+= br_mrp_switchdev.o br_mrp.o br_mrp_netlink.o\n  30:\t\n  31:\tbridge-$(CONFIG_BRIDGE_CFM)\t+= br_cfm.o br_cfm_netlink.o\n  32:\t\n  33:\tifdef CONFIG_GCOV_PROFILE_NETFILTER\n  34:\tGCOV_PROFILE_br_nf_core.o := y\n  35:\tGCOV_PROFILE_br_netfilter_hooks.o := y\n  36:\tGCOV_PROFILE_br_netfilter_ipv6.o := y\n  37:\tendif\n"
}

9/2 2026/10/01 04:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 30466
							output: 30
							thoughts: 210
						

Thoughts:
Okay, let me break this down.

**Investigating VLAN Filtering in the Linux Bridge Code**

Alright, I'm digging into the bridge code, specifically looking at the VLAN filtering configuration. First, I'm checking out the `net/bridge/Makefile`. I see the core structure: `obj-$(CONFIG_BRIDGE) += bridge.o` is the fundamental inclusion. Then, the `bridge-y` variable lists the base object files. Now, focusing on VLAN filtering, the line `bridge-$(CONFIG_BRIDGE_VLAN_FILTERING) += br_vlan.o br_vlan_tunnel.o br_vlan_options.o br_mst.o` is key. It's clear that the presence of `br_vlan.o`, etc. depends on `CONFIG_BRIDGE_VLAN_FILTERING` being set, which makes perfect sense.

Next, to confirm my understanding and to see where this gets defined, I jumped over to `net/bridge/Kconfig`. Bingo! The `config BRIDGE_VLAN_FILTERING` block explicitly ties it to a boolean option. Crucially, it lists the dependencies: `depends on BRIDGE` (which aligns with the Makefile's initial setup) and `depends on VLAN_8021Q`. So, to have VLAN filtering in the bridge, I need both the base bridge support AND 802.1Q VLAN support.

Now, to solidify this, I'm going to quickly check the definition of `CONFIG_VLAN_8021Q`. I'll head over to `net/8021q/Kconfig` to see the specifics of that configuration option. I need to understand that dependency in more depth.



10/2 2026/10/01 04:45 tool grepper
0m Args:
{
  "Expression": "config VLAN_8021Q",
  "PathPrefix": "net/"
}

Results:
{
  "Output": "net/8021q/Kconfig-5-\nnet/8021q/Kconfig:6:config VLAN_8021Q\nnet/8021q/Kconfig-7-\ttristate \"802.1Q/802.1ad VLAN Support\"\n--\nnet/8021q/Kconfig-21-\nnet/8021q/Kconfig:22:config VLAN_8021Q_GVRP\nnet/8021q/Kconfig-23-\tbool \"GVRP (GARP VLAN Registration Protocol) support\"\n--\nnet/8021q/Kconfig-31-\nnet/8021q/Kconfig:32:config VLAN_8021Q_MVRP\nnet/8021q/Kconfig-33-\tbool \"MVRP (Multiple VLAN Registration Protocol) support\"\n"
}

11/2 2026/10/01 04:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 31300
							output: 31
							thoughts: 91
						

Thoughts:
Okay, let's see what we have here.

**Navigating Bridge Configuration Dependencies**

Alright, I need to make sure I haven't missed any crucial configuration dependencies. My initial thought is to specifically check for other related configurations. My immediate focus is on the `BRIDGE` option. Now, `BRIDGE` relies on `LLC` and `STP`, and the system automatically selects both. Got it. Now, what about `BRIDGE_VLAN_FILTERING`? I know that depends on `BRIDGE` and `VLAN_8021Q`. I need to ensure those are handled correctly.

Just to be thorough, I should also consider how `nft_reject_bridge.c` factors in. Time to check the `net/bridge/netfilter/Makefile` to see how it's integrated and what, if any, dependencies I'm missing.



12/2 2026/10/01 04:45 tool grepper
0m Args:
{
  "Expression": "nft_reject_bridge",
  "PathPrefix": "net/bridge/netfilter"
}

Results:
{
  "Output": "net/bridge/netfilter/Makefile=6=obj-$(CONFIG_NFT_BRIDGE_META)  += nft_meta_bridge.o\nnet/bridge/netfilter/Makefile:7:obj-$(CONFIG_NFT_BRIDGE_REJECT)  += nft_reject_bridge.o\nnet/bridge/netfilter/Makefile-8-\n--\nnet/bridge/netfilter/nft_reject_bridge.c=94=static void nft_reject_br_send_v6_unreach(struct net *net,\n--\nnet/bridge/netfilter/nft_reject_bridge.c-109-\nnet/bridge/netfilter/nft_reject_bridge.c:110:static void nft_reject_bridge_eval(const struct nft_expr *expr,\nnet/bridge/netfilter/nft_reject_bridge.c-111-\t\t\t\t   struct nft_regs *regs,\n--\nnet/bridge/netfilter/nft_reject_bridge.c-171-\nnet/bridge/netfilter/nft_reject_bridge.c:172:static int nft_reject_bridge_validate(const struct nft_ctx *ctx,\nnet/bridge/netfilter/nft_reject_bridge.c-173-\t\t\t\t      const struct nft_expr *expr)\n--\nnet/bridge/netfilter/nft_reject_bridge.c-178-\nnet/bridge/netfilter/nft_reject_bridge.c:179:static struct nft_expr_type nft_reject_bridge_type;\nnet/bridge/netfilter/nft_reject_bridge.c:180:static const struct nft_expr_ops nft_reject_bridge_ops = {\nnet/bridge/netfilter/nft_reject_bridge.c:181:\t.type\t\t= \u0026nft_reject_bridge_type,\nnet/bridge/netfilter/nft_reject_bridge.c-182-\t.size\t\t= NFT_EXPR_SIZE(sizeof(struct nft_reject)),\nnet/bridge/netfilter/nft_reject_bridge.c:183:\t.eval\t\t= nft_reject_bridge_eval,\nnet/bridge/netfilter/nft_reject_bridge.c-184-\t.init\t\t= nft_reject_init,\nnet/bridge/netfilter/nft_reject_bridge.c-185-\t.dump\t\t= nft_reject_dump,\nnet/bridge/netfilter/nft_reject_bridge.c:186:\t.validate\t= nft_reject_bridge_validate,\nnet/bridge/netfilter/nft_reject_bridge.c-187-};\nnet/bridge/netfilter/nft_reject_bridge.c-188-\nnet/bridge/netfilter/nft_reject_bridge.c:189:static struct nft_expr_type nft_reject_bridge_type __read_mostly = {\nnet/bridge/netfilter/nft_reject_bridge.c-190-\t.family\t\t= NFPROTO_BRIDGE,\nnet/bridge/netfilter/nft_reject_bridge.c-191-\t.name\t\t= \"reject\",\nnet/bridge/netfilter/nft_reject_bridge.c:192:\t.ops\t\t= \u0026nft_reject_bridge_ops,\nnet/bridge/netfilter/nft_reject_bridge.c-193-\t.policy\t\t= nft_reject_policy,\n--\nnet/bridge/netfilter/nft_reject_bridge.c-197-\nnet/bridge/netfilter/nft_reject_bridge.c:198:static int __init nft_reject_bridge_module_init(void)\nnet/bridge/netfilter/nft_reject_bridge.c-199-{\nnet/bridge/netfilter/nft_reject_bridge.c:200:\treturn nft_register_expr(\u0026nft_reject_bridge_type);\nnet/bridge/netfilter/nft_reject_bridge.c-201-}\nnet/bridge/netfilter/nft_reject_bridge.c-202-\nnet/bridge/netfilter/nft_reject_bridge.c:203:static void __exit nft_reject_bridge_module_exit(void)\nnet/bridge/netfilter/nft_reject_bridge.c-204-{\nnet/bridge/netfilter/nft_reject_bridge.c:205:\tnft_unregister_expr(\u0026nft_reject_bridge_type);\nnet/bridge/netfilter/nft_reject_bridge.c-206-}\nnet/bridge/netfilter/nft_reject_bridge.c-207-\nnet/bridge/netfilter/nft_reject_bridge.c:208:module_init(nft_reject_bridge_module_init);\nnet/bridge/netfilter/nft_reject_bridge.c:209:module_exit(nft_reject_bridge_module_exit);\nnet/bridge/netfilter/nft_reject_bridge.c-210-\n"
}

13/2 2026/10/01 04:45 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 32789
							output: 35
							thoughts: 1854
						

Thoughts:
**VLAN-Aware FDB Destination Analysis for Linux Bridge**

Okay, so I'm diving into this patch set.  My initial assessment is that `CONFIG_BRIDGE` and `CONFIG_BRIDGE_VLAN_FILTERING` are the key configs here, as expected.  I quickly checked for other relevant files.  `br_mrp.c` relies on `CONFIG_BRIDGE_MRP`, but that seems like a minor adaptation; it's simply updating a call to the new `br_forward` signature. `nft_reject_bridge.c` is also just adapting to the new `br_forward` API.

The real meat of this change is in `net/bridge/br_fdb.c`, `net/bridge/br_vlan.c`, `net/bridge/br_forward.c`, `net/bridge/br_input.c`, and `net/bridge/br_device.c`. This is about implementing VLAN-aware FDB destinations in the Linux bridge, which fits perfectly with those main config options, and of course `CONFIG_VLAN_8021Q` as a dependency.

Now, let's get into the details by looking at the specific functions modified:

In `br_fdb.c`: I see `br_fdb_cleanup_by_dst` (a rename/change from `br_fdb_delete_by_port`), `__fdb_update` (an extracted helper), `br_fdb_update`, `fdb_create`, `fdb_add_entry`, `__br_fdb_add`, `br_fdb_external_learn_add`, `br_fdb_resolve_dst` (a new static function), `br_fdb_find_delete_local`, `fdb_delete_local`, `fdb_fill_info`, `br_fdb_dump`, `br_fdb_changeaddr`, `br_fdb_change_mac_address`, `br_fdb_clear_offload`, `br_fdb_fillbuf`, `fdb_delete`, and `fdb_delete_by_addr_and_port`.

In `br_vlan.c`, there are `__vlan_unpublish` (a new static helper), `__vlan_del`, `__vlan_flush`, `__allowed_ingress`, `br_allowed_ingress`, `br_should_learn`, `br_vlan_delete`, `nbp_vlan_delete`, `nbp_vlan_group_unpublish` (a new function), and `nbp_vlan_flush`.

In `br_forward.c`: `br_forward` has a changed signature and logic, now taking a `struct net_bridge_dst` and using `br_dst_decode`.

In `br_input.c`: `br_handle_frame_finish` and `__br_handle_local_finish`.

In `br_device.c`: `br_dev_xmit` and `br_fill_forward_path`.

In `br_if.c`: `del_nbp`, `br_dev_delete`, and `br_add_if`.

The next step is to identify the important symbols for targeting. I am checking which functions are *non-static* and distinct in the kernel image, vmlinux, using `grepper` and by inspecting the declarations:

I see `br_fdb_cleanup_by_dst`, `br_fdb_update`, `br_fdb_external_learn_add`, `br_fdb_add`, `nbp_vlan_delete`, `nbp_vlan_group_unpublish`, `nbp_vlan_flush`, `br_vlan_delete`, `br_forward`, `br_handle_frame_finish`, and `br_dev_xmit`.

Now, the crucial point: static functions need special consideration. Static inlines in headers are not directly targetable. However, if they are called by non-static functions, those callers are important.

So, from `br_fdb.c`, I've verified that `br_fdb_cleanup_by_dst`, `br_fdb_update`, `br_fdb_external_learn_add`, and `br_fdb_add` are non-static.

From `br_vlan.c`, I am certain that `nbp_vlan_delete`, `nbp_vlan_group_unpublish`, `nbp_vlan_flush`, `br_vlan_delete`, `br_allowed_ingress`, and `br_should_learn`


14/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "^void nbp_vlan_group_unpublish",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/br_private.h=1755=int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);\nnet/bridge/br_private.h:1756:void nbp_vlan_group_unpublish(struct net_bridge_port *port);\nnet/bridge/br_private.h-1757-void nbp_vlan_flush(struct net_bridge_port *port,\n--\nnet/bridge/br_vlan.c=1398=int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)\n--\nnet/bridge/br_vlan.c-1420-\nnet/bridge/br_vlan.c:1421:void nbp_vlan_group_unpublish(struct net_bridge_port *port)\nnet/bridge/br_vlan.c-1422-{\n"
}

15/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 35941
							output: 35
							thoughts: 16
						

Thoughts:
Okay, let's dive into this. Here's how I'd approach that particular function, *br\_fdb\_cleanup\_by\_dst*:

**Analyzing `br_fdb_cleanup_by_dst`**

Alright, so `br_fdb_cleanup_by_dst`... the name itself gives us some clues. "Cleanup" and "by destination" – I'm immediately thinking this is a function dedicated to removing entries from a bridge's Forwarding Database (FDB) based on the destination MAC address. That tells me a few things right off the bat, assuming this is a standard implementation:

*   **Potential use-cases:** Could be triggered by a stale entry, a host disconnecting, or perhaps a change in topology detected by something like STP.
*   **Likely data structures:** It's almost certain it needs to interact with an FDB data structure within a bridge instance. Probably a hash table or similar for efficient lookups. We'll need to see how the code is structured around this function to see if my assumption is correct.
*   **Concurrency considerations:** Depending on the system's architecture, this function might need to be thread-safe. If multiple threads/processes can access the FDB simultaneously, then we need to ensure that this function correctly handles locks, mutexes, etc., to avoid race conditions and data corruption.
*   **Memory management:** This is critical. Are we deallocating memory for the FDB entries, or simply marking them as invalid? We need to verify how any memory associated with the entry is handled and what could go wrong, such as a memory leak or use-after-free situation if not handled properly.
*   **Error handling:** Is there any error handling? What happens if the destination MAC isn't found? What happens if there's a problem during the cleanup process (e.g., a locking issue, memory allocation failure)? Are there any error codes being returned? How is this information relayed?
*   **Performance:** Given this is a cleanup function, this needs to be implemented efficiently, especially if the bridge is under heavy load. A slow cleanup routine could block other operations or introduce latency. How does this compare to other cleanup functions?

Essentially, I need to know where it's being called from and the code itself to understand the full context. I'll need to look for any related functions as part of this process to better evaluate its contribution to the bridge. Now, I'm ready to dig into the implementation details and verify these initial thoughts. Let's see how well my assumptions hold up... time to read the code!



16/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "^void br_fdb_cleanup_by_dst",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/br_fdb.c=798=int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,\n--\nnet/bridge/br_fdb.c-874- */\nnet/bridge/br_fdb.c:875:void br_fdb_cleanup_by_dst(struct net_bridge *br,\nnet/bridge/br_fdb.c-876-\t\t\t   struct net_bridge_dst cleanup_dst, u16 vid,\n--\nnet/bridge/br_private.h=1002=int br_fdb_toggle_local_vlan_0(struct net_bridge *br, bool on,\nnet/bridge/br_private.h-1003-\t\t\t       struct netlink_ext_ack *extack);\nnet/bridge/br_private.h:1004:void br_fdb_cleanup_by_dst(struct net_bridge *br,\nnet/bridge/br_private.h-1005-\t\t\t   struct net_bridge_dst dst, u16 vid, int do_all);\n"
}

17/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 36829
							output: 31
							thoughts: 12
						

Thoughts:
Okay, let's dive into this. Here's how I'd approach summarizing the prompt, keeping in mind my expertise:

**Checking `br_fdb_update` - The Crucial Component**

Right, so we're talking about `br_fdb_update`. Just seeing that name sparks some assumptions, but let's break it down methodically. My immediate thought is, what's its context? What system or component is it part of? Based on the naming convention, I'm already formulating some hypotheses. Is this a database update function? Is it related to some kind of feedback mechanism or error reporting? The "br" prefix often signifies something, perhaps a business rule, a specific branch of code, or a particular application's identifier. It's a quick mental checklist I always run. "FDB" could mean "feedback data base" or "forward data base" depending on context, or something else entirely. Whatever it is, I need to understand its functionality within the larger architecture. I'm going to start by looking for documentation, code comments, or any related modules that provide more context. This is the lynchpin, it's critical to understand the data, dependencies, and potential impact.



18/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "^void br_fdb_update",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/br_fdb.c=997=static void __fdb_update(struct net_bridge *br,\n--\nnet/bridge/br_fdb.c-1060-\nnet/bridge/br_fdb.c:1061:void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,\nnet/bridge/br_fdb.c-1062-\t\t   struct net_bridge_vlan *vlan, const unsigned char *addr,\n--\nnet/bridge/br_private.h=1011=int br_fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,\nnet/bridge/br_private.h-1012-\t\t     const unsigned char *addr, u16 vid);\nnet/bridge/br_private.h:1013:void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,\nnet/bridge/br_private.h-1014-\t\t   struct net_bridge_vlan *vlan, const unsigned char *addr,\n"
}

19/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 37418
							output: 28
							thoughts: 9
						

Thoughts:
Okay, here's my attempt at summarizing the thought process, tailored for an expert audience, and written in the first person:

**Analyzing `br_forward`**

Alright, let's take a look at this `br_forward` variable. My initial thought process is to dissect its potential meaning and usage within the context of whatever system we're dealing with. Knowing my audience, I'll be direct. I'm expecting `br_forward` likely stands for "branch forward," or potentially "break forward," depending on the function, but I need more context to be sure. I'll need to immediately consider how this value interacts with control flow. Is it a boolean, an integer representing an offset, or something more complex like a pointer?

I'm thinking about the implications:

*   **Boolean:** If it's boolean, a straightforward true/false condition for a conditional jump is the obvious interpretation. I'll need to trace where this boolean is set and what logic controls it. Are there potential race conditions in its modification?
*   **Offset:** If it's an integer, it probably represents the number of instructions to jump ahead. I'll need to mentally map the surrounding code and ensure the offset is correctly calculated and that it doesn't lead to out-of-bounds access or infinite loops. How does it handle negative values? Is there any bounds checking?
*   **Pointer:** If it's a pointer, it would represent the direct address to jump to. It’s more complex, and I'd need to consider memory management issues, potential for unintended behavior if the pointer is not initialized properly, and the security vulnerabilities associated with jumping to an arbitrary address.

I need to confirm its data type, how it is used, and it's intended usage. I'll quickly look for where `br_forward` is defined or initialized and where it is subsequently used in control flow statements (like `if`, `switch`, or jump instructions). Any related code, variable or function names would be helpful. Understanding these contexts will determine the most efficient method to assess its correctness.



20/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "^void br_forward",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/br_forward.c=135=static int deliver_clone(const struct br_fwd_dst *fwd,\n--\nnet/bridge/br_forward.c-158- */\nnet/bridge/br_forward.c:159:void br_forward(struct net_bridge_dst dst,\nnet/bridge/br_forward.c-160-\t\tstruct sk_buff *skb, bool local_rcv, bool local_orig)\n--\nnet/bridge/br_private.h=1047=int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb);\nnet/bridge/br_private.h:1048:void br_forward(struct net_bridge_dst dst, struct sk_buff *skb,\nnet/bridge/br_private.h-1049-\t\tbool local_rcv, bool local_orig);\n"
}

21/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 38135
							output: 35
							thoughts: 16
						

Thoughts:
Okay, here's my interpretation of that thought process, tailored for an expert audience, and written in the first person:

**Analyzing the `br_fdb_external_learn_add` Function**

Alright, let's dive into this `br_fdb_external_learn_add` function. Just the name itself suggests it's likely responsible for incorporating external learning data into the broader FDB (presumably Fast Data Buffer or a similar system) framework. My immediate concerns are around integration strategy. Is it append-only, overwrite, or some more sophisticated merge/update mechanism? What data formats does it support as input, and how does it handle potential schema mismatches or data inconsistencies with the existing FDB structure? I need to quickly ascertain the level of validation being performed on the incoming data. Are we checking for nulls, duplicates, data types, and any other anomalies before ingestion? Any gaps in these validations open the door to all sorts of nasty data quality issues further down the pipeline. I'll need to scrutinize the function's internal error handling too. How are exceptions caught, logged, and handled? Are there appropriate fallback mechanisms in place to avoid cascading failures if there's a problem during the learning process? Efficiency is also paramount. I expect this to be optimized for fast insertion and query, but I'll need to confirm that this is not coming at the expense of data integrity. I'll start by looking at its dependencies and any associated documentation, I expect to start looking at where it writes, and the potential downstream effects.



22/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "^int br_fdb_external_learn_add",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/br_fdb.c=1567=static struct net_bridge_dst br_fdb_resolve_dst(const struct net_bridge_port *p,\n--\nnet/bridge/br_fdb.c-1586-\nnet/bridge/br_fdb.c:1587:int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,\nnet/bridge/br_fdb.c-1588-\t\t\t      const unsigned char *addr, u16 vid, bool locked,\n--\nnet/bridge/br_private.h=1031=void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p);\nnet/bridge/br_private.h:1032:int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,\nnet/bridge/br_private.h-1033-\t\t\t      const unsigned char *addr, u16 vid,\n"
}

23/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 38778
							output: 32
							thoughts: 13
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience, and delivered as a first-person summary:

**Assessing the `nbp_vlan_delete` Function**

Alright, let's dive into this `nbp_vlan_delete` function. My initial thought process is to treat this as a potentially crucial piece of infrastructure. I need to understand its role in the overall network fabric, and how it interacts with the broader VLAN management system. Specifically, I need to understand its impact. What are the dependencies? What checks are in place? Are we talking about a clean VLAN removal, or something more complex with state transitions and potential data loss implications? I will need to verify that it is properly error-handled. Is it just a simple deletion, or does it also need to ensure resources are released correctly? We would need to consider implications for spanning tree, routing protocols, and any other relevant network services that might be affected by the VLAN's removal. I'm going to look for any documentation, design specs, or existing test cases associated with this function to get a better handle on its purpose and behavior before I start digging into the code itself.



24/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "^int nbp_vlan_delete",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/br_private.h=1753=int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,\nnet/bridge/br_private.h-1754-\t\t bool *changed, struct netlink_ext_ack *extack);\nnet/bridge/br_private.h:1755:int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);\nnet/bridge/br_private.h-1756-void nbp_vlan_group_unpublish(struct net_bridge_port *port);\n--\nnet/bridge/br_vlan.c=1353=int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,\n--\nnet/bridge/br_vlan.c-1397- */\nnet/bridge/br_vlan.c:1398:int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)\nnet/bridge/br_vlan.c-1399-{\n"
}

25/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 39357
							output: 31
							thoughts: 12
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience:

**Analyzing the `br_vlan_delete` Function**

Alright, let's dive into the `br_vlan_delete` function. My initial thought is to immediately consider this function in the context of the broader bridging and VLAN management subsystem. I'm already anticipating the typical challenges: race conditions, potential memory leaks, and the need for careful error handling when removing VLAN configurations. I’ll start by mentally tracing the execution flow: where does this function get called from? What are the calling contexts, and what resources are being held at that point? Are we dealing with mutexes or other synchronization primitives? I also need to verify that we are removing the VLAN configurations securely to prevent any denial of service attacks. We also must consider how this function interacts with the hardware, especially if there's any hardware offload involved. I expect there to be interactions with the bridge data structures, likely involving updates to the forwarding database (FDB) and possibly MAC address learning tables. What kind of cleanup is performed? Are there any dangling pointers or references after the VLAN is removed? I need to look for any potential for orphaned packets. Finally, I'll need to scrutinize the error handling: are errors handled gracefully, and are appropriate error codes returned to the caller? The devil is in the details, so let's start digging deeper.



26/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "^int br_vlan_delete",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/br_private.h=1734=int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags,\nnet/bridge/br_private.h-1735-\t\tbool *changed, struct netlink_ext_ack *extack);\nnet/bridge/br_private.h:1736:int br_vlan_delete(struct net_bridge *br, u16 vid);\nnet/bridge/br_private.h-1737-void br_vlan_flush(struct net_bridge *br);\n--\nnet/bridge/br_vlan.c=822=int br_vlan_add(struct net_bridge *br, u16 vid, u16 flags, bool *changed,\n--\nnet/bridge/br_vlan.c-866- */\nnet/bridge/br_vlan.c:867:int br_vlan_delete(struct net_bridge *br, u16 vid)\nnet/bridge/br_vlan.c-868-{\n"
}

27/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 39964
							output: 31
							thoughts: 12
						

Thoughts:
Okay, here's my take on those thoughts, tailored for an expert audience, presented in the first person:

**Deep Dive into `br_fdb_add`**

Alright, let's get down to brass tacks and dissect this `br_fdb_add` function. My initial thought process immediately focuses on its role within the broader bridging framework. I'm implicitly asking myself: what are the likely data structures involved? What level of locking or concurrency control is implemented or implied? Is this a simple addition to an FDB (Forwarding DataBase) table, or are there more complex interactions with other modules? My expertise quickly guides my expectations; I am thinking it is more than just a trivial operation. I'm already formulating hypotheses about potential performance bottlenecks if not carefully architected, especially in high-traffic environments. I'm wondering if this routine is designed to handle multicast entries differently, or if there's any clever optimization or caching at play. Time to get my hands dirty.



28/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "^int br_fdb_add",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/br_fdb.c=928=int br_fdb_fillbuf(struct net_bridge *br, void *buf,\n--\nnet/bridge/br_fdb.c-978-/* Add entry for local address of interface */\nnet/bridge/br_fdb.c:979:int br_fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,\nnet/bridge/br_fdb.c-980-\t\t     const unsigned char *addr, u16 vid)\n--\nnet/bridge/br_fdb.c=1344=static const struct nla_policy br_nda_fdb_pol[NFEA_MAX + 1] = {\n--\nnet/bridge/br_fdb.c-1349-/* Add new permanent fdb entry with RTM_NEWNEIGH */\nnet/bridge/br_fdb.c:1350:int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],\nnet/bridge/br_fdb.c-1351-\t       struct net_device *dev,\n--\nnet/bridge/br_private.h=1009=int br_fdb_fillbuf(struct net_bridge *br, void *buf, unsigned long count,\nnet/bridge/br_private.h-1010-\t\t   unsigned long off);\nnet/bridge/br_private.h:1011:int br_fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,\nnet/bridge/br_private.h-1012-\t\t     const unsigned char *addr, u16 vid);\n--\nnet/bridge/br_private.h=1020=int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,\nnet/bridge/br_private.h-1021-\t\t       struct netlink_ext_ack *extack);\nnet/bridge/br_private.h:1022:int br_fdb_add(struct ndmsg *nlh, struct nlattr *tb[], struct net_device *dev,\nnet/bridge/br_private.h-1023-\t       const unsigned char *addr, u16 vid, u16 nlh_flags,\n"
}

29/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 40795
							output: 33
							thoughts: 67
						

Thoughts:
Here's my take on the thought process, as requested:

**Navigating the FDB Updates**

Okay, so `br_fdb_add` is the crucial netlink handler for when a user wants to add entries to the Forwarding Database, got it. The key update I'm seeing is that it's now passing the `vlan` information down the line to `__br_fdb_add` and ultimately to `fdb_add_entry`. That's important; it means we're now correctly associating VLAN tags with these newly added FDB entries, which is a significant change. Makes sense, given the focus on VLAN handling improvements across the board. Now, to get a handle on the broader picture, I should also shift my attention to `br_fdb_find_delete_local` to see how it might relate to the additions!



30/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "br_fdb_find_delete_local",
  "PathPrefix": "net/bridge"
}

Results:
{
  "Output": "net/bridge/br_fdb.c=338=static void fdb_delete_local(struct net_bridge *br,\n--\nnet/bridge/br_fdb.c-371-\nnet/bridge/br_fdb.c:372:void br_fdb_find_delete_local(struct net_bridge *br,\nnet/bridge/br_fdb.c-373-\t\t\t      const struct net_bridge_port *p,\n--\nnet/bridge/br_fdb.c=593=static void br_fdb_delete_locals_per_vlan_port(struct net_bridge *br,\n--\nnet/bridge/br_fdb.c-611-\tlist_for_each_entry(v, \u0026vg-\u003evlan_list, vlist)\nnet/bridge/br_fdb.c:612:\t\tbr_fdb_find_delete_local(br, p, dev-\u003edev_addr, v-\u003evid);\nnet/bridge/br_fdb.c-613-}\n--\nnet/bridge/br_private.h=994=void br_fdb_flush(struct net_bridge *br,\nnet/bridge/br_private.h-995-\t\t  const struct net_bridge_fdb_flush_desc *desc);\nnet/bridge/br_private.h:996:void br_fdb_find_delete_local(struct net_bridge *br,\nnet/bridge/br_private.h-997-\t\t\t      const struct net_bridge_port *p,\n--\nnet/bridge/br_vlan.c=302=static int __vlan_add(struct net_bridge_vlan *v, u16 flags,\n--\nnet/bridge/br_vlan.c-409-\tif (br_vlan_should_use(v)) {\nnet/bridge/br_vlan.c:410:\t\tbr_fdb_find_delete_local(br, p, dev-\u003edev_addr, v-\u003evid);\nnet/bridge/br_vlan.c-411-\t\tWRITE_ONCE(vg-\u003enum_vlans, vg-\u003enum_vlans - 1);\n--\nnet/bridge/br_vlan.c=867=int br_vlan_delete(struct net_bridge *br, u16 vid)\n--\nnet/bridge/br_vlan.c-878-\nnet/bridge/br_vlan.c:879:\tbr_fdb_find_delete_local(br, NULL, br-\u003edev-\u003edev_addr, vid);\nnet/bridge/br_vlan.c-880-\tbr_fdb_cleanup_by_dst(br, br_port_to_dst(NULL), vid, 0);\n"
}

31/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 41769
							output: 27
							thoughts: 254
						

Thoughts:
**Reviewing Bridge VLAN Configuration Options**

Okay, let's make sure I understand the relevant configurations here. I need to be sure the bridge setup is correct. I'm focusing on the core aspects: `BRIDGE` for Ethernet Bridging, `BRIDGE_VLAN_FILTERING` to enable VLAN filtering within the bridge, and `VLAN_8021Q` since it's a dependency of `BRIDGE_VLAN_FILTERING`. I don't see any immediate red flags, but I want to be certain I haven't missed anything, so I should see if `CONFIG_NET_SWITCHDEV` needs to be considered.

I recall some recent modifications to the switchdev notifier, specifically that `br_switchdev_event` calls `br_fdb_cleanup_by_dst`, and `br_switchdev.c` itself was altered. That's a strong hint to look into `NET_SWITCHDEV`. It seems like `NET_SWITCHDEV` is a standard component within the networking subsystem, but is it a strict dependency for VLAN filtering in a bridge? No, that doesn't seem to be the case, and bridge VLAN filtering itself is strictly software, so it's not strictly necessary.

However, I should evaluate if it's still beneficial. I see in the `net/bridge/Makefile` that `br_switchdev.o` is conditionally included based on `CONFIG_NET_SWITCHDEV`. So, having `NET_SWITCHDEV` enabled *could* be helpful, especially if I'm planning to test or utilize switchdev FDB offload, even if VLAN filtering doesn't directly rely on it. It might expand the possibilities. I'll need to double-check the Kconfig file to confirm any potential dependencies for `NET_SWITCHDEV`, but in general, including `NET_SWITCHDEV` is likely a good idea.



32/2 2026/10/01 04:46 tool grepper
0m Args:
{
  "Expression": "config NET_SWITCHDEV",
  "PathPrefix": "net/"
}

Results:
{
  "Output": "net/switchdev/Kconfig-5-\nnet/switchdev/Kconfig:6:config NET_SWITCHDEV\nnet/switchdev/Kconfig-7-\tbool \"Switch (and switch-ish) device support\"\n"
}

33/2 2026/10/01 04:46 llm patch-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 42511
							output: 241
							thoughts: 1009
						

Thoughts:
**Analysis of Bridge VLAN Filtering Configuration Options and Focus Symbols**

Okay, let's break this down. We're dealing with a patch that introduces VLAN support directly into the bridge forwarding database (FDB) destination representation. This means we're fundamentally altering how the bridge handles and forwards packets, so it demands careful consideration.

First, the relevant configuration options. We've got `NET_SWITCHDEV`, a boolean, and `BRIDGE`, a tristate (or boolean if built-in), which is the base bridge functionality. Then we have `BRIDGE_VLAN_FILTERING`, a boolean that depends on `BRIDGE` and `VLAN_8021Q`. And finally, `VLAN_8021Q`, which is also a tristate.

I checked for relevance with `BRIDGE_NETFILTER` and noticed adaptations for the `br_forward` API change in `nft_reject_bridge.c`, but the core of the patch revolves around this FDB destination change to support VLANs. So, the key options are: `BRIDGE`, `BRIDGE_VLAN_FILTERING`, `VLAN_8021Q`, and `NET_SWITCHDEV`.

Now, for the important part: the focus symbols. We need to identify the functions that are directly impacted by this change and, therefore, are the best candidates for deeper analysis.

Looking at the code, these functions stand out:

*   `br_fdb_cleanup_by_dst`: This function is central to cleaning up FDB entries when ports or VLANs are removed or flushed. The changes here directly reflect the new VLAN-aware logic. This one is key, and the addition of VLAN-specific logic in the cleanup path is very interesting.
*   `br_fdb_update`: This function is being modified to handle VLANs, specifically updating the destination via `__fdb_update` and using `cmpxchg` for destination replacement. A core FDB function, so it makes sense.
*   `br_fdb_external_learn_add`: Modified to use `br_fdb_resolve_dst` and include `lockdep_assert`, indicating locking changes related to VLAN handling.
*   `br_fdb_add`: This is the entrypoint for users adding FDB entries via netlink. The fact that it calls `__br_fdb_add` and `fdb_add_entry` is relevant.
*   `br_forward`: The destination decoding logic has changed to support VLAN destinations. This is central to the core forwarding logic, and now it must handle VLANs.
*   `nbp_vlan_delete`: This function now has a modified deletion sequence using `__vlan_unpublish`, `synchronize_net`, and `br_fdb_cleanup_by_dst`, again touching FDB cleanup and VLAN unpublishing.
*   `nbp_vlan_group_unpublish`: A new non-static function called during deletion of an NBP.
*   `br_vlan_delete`: Modified for bridge VLAN deletion.

These functions are not ubiquitous, they are non-static, and they directly implement the core logic altered by this patch.

I've done a sanity check on the instruction set. The result is: WorthFuzzing: true, concise reasoning that explains this verdict (restructures bridge FDB entry representation to support pointing to VLANs as well as ports, introduces atomic destination replacement, unpublishing flows, and synchronization in VLAN and port deletion paths, along with lockdep assertions). FocusSymbols are non-ubiquitous functions implementing and exercising the changes, and the EnableConfigs stripped of the CONFIG\_ prefix.

Everything looks good. We are ready to execute `set-results`.



34/2 2026/10/01 04:46 tool set-results
0m Args:
{
  "EnableConfigs": [
    "BRIDGE",
    "BRIDGE_VLAN_FILTERING",
    "VLAN_8021Q",
    "NET_SWITCHDEV"
  ],
  "FocusSymbols": [
    "br_fdb_cleanup_by_dst",
    "br_fdb_update",
    "br_fdb_external_learn_add",
    "br_fdb_add",
    "br_forward",
    "nbp_vlan_delete",
    "nbp_vlan_group_unpublish",
    "br_vlan_delete"
  ],
  "Reasoning": "The patch modifies the Linux Ethernet bridge subsystem to allow FDB (Forwarding Database) entries to point directly to VLAN destinations in addition to ports. This refactors FDB entry destination handling, introduces atomic destination replacement via cmpxchg, alters concurrency and lifetime sequencing during port and VLAN deletion with RCU unpublishing/synchronize_net(), and adds lockdep assertions. These changes affect reachable core networking code configured via netlink and exercised during bridge frame reception, forwarding, and configuration.",
  "WorthFuzzing": true
}

Results:
{
  "EnableConfigs": [
    "BRIDGE",
    "BRIDGE_VLAN_FILTERING",
    "VLAN_8021Q",
    "NET_SWITCHDEV"
  ],
  "FocusSymbols": [
    "br_fdb_cleanup_by_dst",
    "br_fdb_update",
    "br_fdb_external_learn_add",
    "br_fdb_add",
    "br_forward",
    "nbp_vlan_delete",
    "nbp_vlan_group_unpublish",
    "br_vlan_delete"
  ],
  "Reasoning": "The patch modifies the Linux Ethernet bridge subsystem to allow FDB (Forwarding Database) entries to point directly to VLAN destinations in addition to ports. This refactors FDB entry destination handling, introduces atomic destination replacement via cmpxchg, alters concurrency and lifetime sequencing during port and VLAN deletion with RCU unpublishing/synchronize_net(), and adds lockdep assertions. These changes affect reachable core networking code configured via netlink and exercised during bridge frame reception, forwarding, and configuration.",
  "WorthFuzzing": true
}

35/1 2026/10/01 04:46 action If
1m Args:
{
  "WorthFuzzing": true
}

Results:
null

36/2 2026/10/01 04:46 agent kmsan-evaluator
1m Model:
core

Args:
null

Results:
{
  "KMSANReasoning": "The patch refactors bridge Forwarding Database (FDB) entries to support VLAN-aware destinations. It introduces a wrapper type `struct net_bridge_dst` containing a tagged pointer (`unsigned long value`) that references either a `struct net_bridge_port` or a `struct net_bridge_vlan`.\n\nKMSAN vs KASAN Applicability:\n- Uninitialized Memory Risks (KMSAN): None. `struct net_bridge_dst` consists of a single scalar field (`unsigned long value`) with no padding, and every instance created via `br_port_to_dst()`, `br_vlan_to_dst()`, or `br_dst_read()` is fully initialized before being read, copied, or stored. Local variables across callers (such as `struct br_fwd_dst`, `vid`, `vlan`, and `state`) are explicitly initialized (e.g., `br_should_learn()` sets `*vlan = NULL` at function entry; `br_allowed_ingress()` sets `*vlan` on success; `br_dst_decode()` unconditionally sets both output pointers). No kernel structures with uninitialized padding or uninitialized fields are exposed to userspace.\n- Lifetime and Concurrency Risks (KASAN/LOCKDEP): The main risks introduced by caching pointers to `struct net_bridge_vlan` inside FDB entries revolve around object lifetimes, RCU synchronization, and potential use-after-free (UAF) or race conditions during VLAN deletion (`nbp_vlan_delete`) or port unbinding (`del_nbp`). These issues fall strictly under the detection capabilities of KASAN (use-after-free) and LOCKDEP (locking/synchronization).\n\nBecause the changes do not introduce or expose uninitialized memory reads or information leaks, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Instruction:
You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.

CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
  a comprehensive suite of debugging tools and sanitizers, including KASAN
  (out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
  (locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
  or page allocations) and kernel-to-user memory info-leaks.

Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.

Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.

Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
   attributes, ioctl output arguments, socket options, or BPF buffers) where fields
   or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
   or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
   could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
   uninitialized bytes of existing buffers.

Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
  dereferences, locking deadlocks, or use-after-free bugs (these are already caught
  by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
  or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.

Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.


Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.

Prompt:
Target architecture: amd64

For your convenience, here is the diff of the changes:
commit f871cd2676b17c6338ab86a38d0a4690b5626b96
Author: syz-cluster <triage@syzkaller.com>
Date:   Thu Oct 1 04:45:06 2026 +0000

    syz-cluster: applied patch under review

diff --git a/include/trace/events/bridge.h b/include/trace/events/bridge.h
index 3fe4725c83ffe..f676516b33fa5 100644
--- a/include/trace/events/bridge.h
+++ b/include/trace/events/bridge.h
@@ -68,13 +68,14 @@ TRACE_EVENT(br_fdb_external_learn_add,
 
 TRACE_EVENT(fdb_delete,
 
-	TP_PROTO(struct net_bridge *br, struct net_bridge_fdb_entry *f),
+	TP_PROTO(struct net_bridge *br, struct net_bridge_fdb_entry *f,
+		 const struct net_bridge_port *dst),
 
-	TP_ARGS(br, f),
+	TP_ARGS(br, f, dst),
 
 	TP_STRUCT__entry(
 		__string(br_dev, br->dev->name)
-		__string(dev, f->dst ? f->dst->dev->name : "null")
+		__string(dev, dst ? dst->dev->name : "null")
 		__array(unsigned char, addr, ETH_ALEN)
 		__field(u16, vid)
 	),
diff --git a/net/bridge/br.c b/net/bridge/br.c
index 09a120b3b76cb..b1abe1c5bbdd2 100644
--- a/net/bridge/br.c
+++ b/net/bridge/br.c
@@ -202,7 +202,7 @@ static int br_switchdev_event(struct notifier_block *unused,
 	case SWITCHDEV_FDB_FLUSH_TO_BRIDGE:
 		fdb_info = ptr;
 		/* Don't delete static entries */
-		br_fdb_delete_by_port(br, p, fdb_info->vid, 0);
+		br_fdb_cleanup_by_dst(br, br_port_to_dst(p), fdb_info->vid, 0);
 		break;
 	}
 
diff --git a/net/bridge/br_arp_nd_proxy.c b/net/bridge/br_arp_nd_proxy.c
index da15f4d7c1aef..ba4a63840b219 100644
--- a/net/bridge/br_arp_nd_proxy.c
+++ b/net/bridge/br_arp_nd_proxy.c
@@ -223,7 +223,7 @@ void br_do_proxy_suppress_arp(struct sk_buff *skb, struct net_bridge *br,
 		neigh_ha_snapshot(ha, n, n->dev);
 		f = br_fdb_find_rcu(br, ha, vid);
 		if (f) {
-			const struct net_bridge_port *dst = READ_ONCE(f->dst);
+			const struct net_bridge_port *dst = br_fdb_dst_port(f);
 			bool replied = false;
 
 			if ((p && test_bit(BR_PROXYARP_BIT, &p->flags)) ||
@@ -500,7 +500,7 @@ void br_do_suppress_nd(struct sk_buff *skb, struct net_bridge *br,
 		neigh_ha_snapshot(ha, n, n->dev);
 		f = br_fdb_find_rcu(br, ha, vid);
 		if (f) {
-			const struct net_bridge_port *dst = READ_ONCE(f->dst);
+			const struct net_bridge_port *dst = br_fdb_dst_port(f);
 			bool replied = false;
 
 			if (br_is_neigh_suppress_enabled_vid(dst, vid)) {
diff --git a/net/bridge/br_device.c b/net/bridge/br_device.c
index ce9ea9ac3d0ad..0a1ce9e59a4d4 100644
--- a/net/bridge/br_device.c
+++ b/net/bridge/br_device.c
@@ -65,9 +65,10 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 	skb_reset_mac_header(skb);
 	skb_pull(skb, ETH_HLEN);
 
-	if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &vid,
-				&state, &vlan))
+	if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &state,
+				&vlan))
 		goto out;
+	vid = vlan ? vlan->vid : 0;
 
 	if (IS_ENABLED(CONFIG_INET) &&
 	    (eth_hdr(skb)->h_proto == htons(ETH_P_ARP) ||
@@ -107,7 +108,7 @@ netdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)
 		else
 			br_flood(br, vlan, skb, BR_PKT_MULTICAST, false, true);
 	} else if ((dst = br_fdb_find_rcu(br, dest, vid)) != NULL) {
-		br_forward(READ_ONCE(dst->dst), skb, false, true);
+		br_forward(br_fdb_dst_read(dst), skb, false, true);
 	} else {
 		br_flood(br, vlan, skb, BR_PKT_UNICAST, false, true);
 	}
@@ -400,7 +401,7 @@ static int br_fill_forward_path(struct net_device_path_ctx *ctx,
 	if (!f)
 		return -1;
 
-	dst = READ_ONCE(f->dst);
+	dst = br_fdb_dst_port(f);
 	if (!dst)
 		return -1;
 
diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c
index e4570bbed8544..730b178cf6c44 100644
--- a/net/bridge/br_fdb.c
+++ b/net/bridge/br_fdb.c
@@ -90,7 +90,7 @@ static int fdb_fill_info(struct sk_buff *skb, const struct net_bridge *br,
 			 const struct net_bridge_fdb_entry *fdb,
 			 u32 portid, u32 seq, int type, unsigned int flags)
 {
-	const struct net_bridge_port *dst = READ_ONCE(fdb->dst);
+	const struct net_bridge_port *dst = br_fdb_dst_port(fdb);
 	unsigned long now = jiffies;
 	struct nda_cacheinfo ci;
 	struct nlmsghdr *nlh;
@@ -250,7 +250,7 @@ struct net_device *br_fdb_find_port(const struct net_device *br_dev,
 	rcu_read_lock();
 	f = br_fdb_find_rcu(br, addr, vid);
 	if (f) {
-		dst = READ_ONCE(f->dst);
+		dst = br_fdb_dst_port(f);
 		if (dst)
 			dev = dst->dev;
 	}
@@ -315,7 +315,7 @@ static void fdb_del_hw_addr(struct net_bridge *br, const unsigned char *addr)
 static void fdb_delete(struct net_bridge *br, struct net_bridge_fdb_entry *f,
 		       bool swdev_notify)
 {
-	trace_fdb_delete(br, f);
+	trace_fdb_delete(br, f, br_fdb_dst_port(f));
 
 	if (test_bit(BR_FDB_STATIC, &f->flags))
 		fdb_del_hw_addr(br, f->key.addr.addr);
@@ -350,7 +350,7 @@ static void fdb_delete_local(struct net_bridge *br,
 		vg = nbp_vlan_group(op);
 		if (op != p && ether_addr_equal(op->dev->dev_addr, addr) &&
 		    (!vid || br_vlan_find(vg, vid))) {
-			WRITE_ONCE(f->dst, op);
+			br_fdb_dst_write(f, br_port_to_dst(op));
 			clear_bit(BR_FDB_ADDED_BY_USER, &f->flags);
 			return;
 		}
@@ -361,7 +361,7 @@ static void fdb_delete_local(struct net_bridge *br,
 	/* Maybe bridge device has same hw addr? */
 	if (p && ether_addr_equal(br->dev->dev_addr, addr) &&
 	    (!vid || (v && br_vlan_should_use(v)))) {
-		WRITE_ONCE(f->dst, NULL);
+		br_fdb_dst_write(f, br_port_to_dst(NULL));
 		clear_bit(BR_FDB_ADDED_BY_USER, &f->flags);
 		return;
 	}
@@ -378,13 +378,14 @@ void br_fdb_find_delete_local(struct net_bridge *br,
 	spin_lock_bh(&br->hash_lock);
 	f = br_fdb_find(br, addr, vid);
 	if (f && test_bit(BR_FDB_LOCAL, &f->flags) &&
-	    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags) && f->dst == p)
+	    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags) &&
+	    br_fdb_dst_port(f) == p)
 		fdb_delete_local(br, p, f);
 	spin_unlock_bh(&br->hash_lock);
 }
 
 static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,
-					       struct net_bridge_port *source,
+					       struct net_bridge_dst dst,
 					       const unsigned char *addr,
 					       __u16 vid,
 					       unsigned long flags)
@@ -408,7 +409,7 @@ static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,
 		return NULL;
 
 	memcpy(fdb->key.addr.addr, addr, ETH_ALEN);
-	WRITE_ONCE(fdb->dst, source);
+	br_fdb_dst_write(fdb, dst);
 	fdb->key.vlan_id = vid;
 	fdb->flags = flags;
 	fdb->updated = fdb->used = jiffies;
@@ -447,7 +448,7 @@ static int fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,
 		fdb_delete(br, fdb, true);
 	}
 
-	fdb = fdb_create(br, source, addr, vid,
+	fdb = fdb_create(br, br_port_to_dst(source), addr, vid,
 			 BIT(BR_FDB_LOCAL) | BIT(BR_FDB_STATIC));
 	if (!fdb)
 		return -ENOMEM;
@@ -470,7 +471,7 @@ void br_fdb_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr)
 	spin_lock_bh(&br->hash_lock);
 	vg = nbp_vlan_group(p);
 	hlist_for_each_entry(f, &br->fdb_list, fdb_node) {
-		if (READ_ONCE(f->dst) == p &&
+		if (br_fdb_dst_port(f) == p &&
 		    test_bit(BR_FDB_LOCAL, &f->flags) &&
 		    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags)) {
 			/* delete old one */
@@ -517,7 +518,8 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr)
 	/* If old entry was unassociated with any port, then delete it. */
 	f = br_fdb_find(br, br->dev->dev_addr, 0);
 	if (f && test_bit(BR_FDB_LOCAL, &f->flags) &&
-	    !f->dst && !test_bit(BR_FDB_ADDED_BY_USER, &f->flags))
+	    !br_fdb_dst_port(f) &&
+	    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags))
 		fdb_delete_local(br, NULL, f);
 
 	fdb_add_local(br, NULL, newaddr, 0);
@@ -533,7 +535,8 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr)
 			continue;
 		f = br_fdb_find(br, br->dev->dev_addr, v->vid);
 		if (f && test_bit(BR_FDB_LOCAL, &f->flags) &&
-		    !f->dst && !test_bit(BR_FDB_ADDED_BY_USER, &f->flags))
+		    !br_fdb_dst_port(f) &&
+		    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags))
 			fdb_delete_local(br, NULL, f);
 		fdb_add_local(br, NULL, newaddr, v->vid);
 	}
@@ -693,7 +696,7 @@ static bool __fdb_flush_matches(const struct net_bridge *br,
 				const struct net_bridge_fdb_entry *f,
 				const struct net_bridge_fdb_flush_desc *desc)
 {
-	const struct net_bridge_port *dst = READ_ONCE(f->dst);
+	const struct net_bridge_port *dst = br_fdb_dst_port(f);
 	int port_ifidx = dst ? dst->dev->ifindex : br->dev->ifindex;
 
 	if (desc->vlan_id && desc->vlan_id != f->key.vlan_id)
@@ -865,29 +868,50 @@ int br_fdb_delete_bulk(struct nlmsghdr *nlh, struct net_device *dev,
 	return 0;
 }
 
-/* Flush all entries referring to a specific port.
+/* Clean up all entries referring to a specific destination.
  * if do_all is set also flush static entries
  * if vid is set delete all entries that match the vlan_id
  */
-void br_fdb_delete_by_port(struct net_bridge *br,
-			   const struct net_bridge_port *p,
-			   u16 vid,
+void br_fdb_cleanup_by_dst(struct net_bridge *br,
+			   struct net_bridge_dst cleanup_dst, u16 vid,
 			   int do_all)
 {
+	const struct net_bridge_vlan *vlan = br_dst_vlan(cleanup_dst);
+	const struct net_bridge_port *p = br_dst_port(cleanup_dst);
 	struct net_bridge_fdb_entry *f;
 	struct hlist_node *tmp;
 
 	spin_lock_bh(&br->hash_lock);
 	hlist_for_each_entry_safe(f, tmp, &br->fdb_list, fdb_node) {
-		if (READ_ONCE(f->dst) != p)
+		struct net_bridge_dst dst = br_fdb_dst_read(f);
+
+		if (br_dst_port(dst) != p)
+			continue;
+
+		if (vlan && f->key.vlan_id == vlan->vid &&
+		    test_bit(BR_FDB_LOCAL, &f->flags) &&
+		    !test_bit(BR_FDB_ADDED_BY_USER, &f->flags) &&
+		    ether_addr_equal(f->key.addr.addr, p->dev->dev_addr)) {
+			fdb_delete_local(br, p, f);
 			continue;
+		}
+
+		if (!do_all) {
+			if (vid && f->key.vlan_id != vid)
+				continue;
 
-		if (!do_all)
 			if (test_bit(BR_FDB_STATIC, &f->flags) ||
 			    (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &f->flags) &&
-			     !test_bit(BR_FDB_OFFLOADED, &f->flags)) ||
-			    (vid && f->key.vlan_id != vid))
+			     !test_bit(BR_FDB_OFFLOADED, &f->flags))) {
+				/* The entry outlives the VLAN, so it must fall
+				 * back to the raw port destination
+				 */
+				if (vlan && br_dst_vlan(dst) == vlan)
+					br_fdb_dst_replace(f, dst,
+							   br_port_to_dst(p));
 				continue;
+			}
+		}
 
 		if (test_bit(BR_FDB_LOCAL, &f->flags))
 			fdb_delete_local(br, p, f);
@@ -921,7 +945,7 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf,
 			continue;
 
 		/* ignore pseudo entry for local MAC address */
-		dst = READ_ONCE(f->dst);
+		dst = br_fdb_dst_port(f);
 		if (!dst)
 			continue;
 
@@ -970,10 +994,78 @@ static bool __fdb_mark_active(struct net_bridge_fdb_entry *fdb)
 		  test_and_clear_bit(BR_FDB_NOTIFY_INACTIVE, &fdb->flags));
 }
 
+static void __fdb_update(struct net_bridge *br,
+			 struct net_bridge_fdb_entry *fdb,
+			 struct net_bridge_port *source,
+			 struct net_bridge_dst dst,
+			 const unsigned char *addr, u16 vid,
+			 unsigned long flags)
+{
+	struct net_bridge_port *old_port;
+	struct net_bridge_dst old_dst;
+	bool fdb_modified = false;
+	unsigned long now;
+
+	/* attempt to update an entry for a local interface */
+	if (unlikely(test_bit(BR_FDB_LOCAL, &fdb->flags))) {
+		if (net_ratelimit())
+			br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
+				source->dev->name, addr, vid);
+		return;
+	}
+
+	now = jiffies;
+	if (now != READ_ONCE(fdb->updated)) {
+		WRITE_ONCE(fdb->updated, now);
+		fdb_modified = __fdb_mark_active(fdb);
+	}
+
+	old_dst = br_fdb_dst_read(fdb);
+	old_port = br_dst_port(old_dst);
+	/* fastpath: update of existing entry */
+	if (unlikely(!br_dst_equal(dst, old_dst) &&
+		     (source == old_port ||
+		      !test_bit(BR_FDB_STICKY, &fdb->flags)))) {
+		if (source != old_port) {
+			br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
+			br_fdb_dst_write(fdb, dst);
+			fdb_modified = true;
+			/* take over HW learned entry */
+			if (unlikely(test_bit(BR_FDB_ADDED_BY_EXT_LEARN,
+					      &fdb->flags)))
+				clear_bit(BR_FDB_ADDED_BY_EXT_LEARN,
+					  &fdb->flags);
+			/* clear locked flag when roaming to an unlocked port */
+			if (unlikely(test_bit(BR_FDB_LOCKED, &fdb->flags)))
+				clear_bit(BR_FDB_LOCKED, &fdb->flags);
+		} else {
+			/* raw port-to-VLAN promotion shouldn't overwrite a
+			 * concurrent roam to another port
+			 */
+			br_fdb_dst_replace(fdb, old_dst, dst);
+		}
+	}
+
+	if (unlikely(test_bit(BR_FDB_ADDED_BY_USER, &flags))) {
+		set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags);
+		if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &fdb->flags))
+			atomic_dec(&br->fdb_n_learned);
+	}
+
+	if (unlikely(fdb_modified)) {
+		trace_br_fdb_update(br, source, addr, vid, flags);
+		fdb_notify(br, fdb, RTM_NEWNEIGH, true);
+	}
+}
+
 void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
-		   const unsigned char *addr, u16 vid, unsigned long flags)
+		   struct net_bridge_vlan *vlan, const unsigned char *addr,
+		   unsigned long flags)
 {
+	struct net_bridge_dst dst = vlan ? br_vlan_to_dst(vlan) :
+					   br_port_to_dst(source);
 	struct net_bridge_fdb_entry *fdb;
+	u16 vid = vlan ? vlan->vid : 0;
 
 	/* some users want to always flood. */
 	if (hold_time(br) == 0)
@@ -981,59 +1073,14 @@ void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
 
 	fdb = fdb_find_rcu(&br->fdb_hash_tbl, addr, vid);
 	if (likely(fdb)) {
-		/* attempt to update an entry for a local interface */
-		if (unlikely(test_bit(BR_FDB_LOCAL, &fdb->flags))) {
-			if (net_ratelimit())
-				br_warn(br, "received packet on %s with own address as source address (addr:%pM, vlan:%u)\n",
-					source->dev->name, addr, vid);
-		} else {
-			unsigned long now = jiffies;
-			bool fdb_modified = false;
-
-			if (now != READ_ONCE(fdb->updated)) {
-				WRITE_ONCE(fdb->updated, now);
-				fdb_modified = __fdb_mark_active(fdb);
-			}
-
-			/* fastpath: update of existing entry */
-			if (unlikely(source != READ_ONCE(fdb->dst) &&
-				     !test_bit(BR_FDB_STICKY, &fdb->flags))) {
-				br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH);
-				WRITE_ONCE(fdb->dst, source);
-				fdb_modified = true;
-				/* Take over HW learned entry */
-				if (unlikely(test_bit(BR_FDB_ADDED_BY_EXT_LEARN,
-						      &fdb->flags)))
-					clear_bit(BR_FDB_ADDED_BY_EXT_LEARN,
-						  &fdb->flags);
-				/* Clear locked flag when roaming to an
-				 * unlocked port.
-				 */
-				if (unlikely(test_bit(BR_FDB_LOCKED, &fdb->flags)))
-					clear_bit(BR_FDB_LOCKED, &fdb->flags);
-			}
-
-			if (unlikely(test_bit(BR_FDB_ADDED_BY_USER, &flags))) {
-				set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags);
-				if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED,
-						       &fdb->flags))
-					atomic_dec(&br->fdb_n_learned);
-			}
-			if (unlikely(fdb_modified)) {
-				trace_br_fdb_update(br, source, addr, vid, flags);
-				fdb_notify(br, fdb, RTM_NEWNEIGH, true);
-			}
-		}
+		__fdb_update(br, fdb, source, dst, addr, vid, flags);
 	} else {
 		spin_lock(&br->hash_lock);
-		fdb = fdb_create(br, source, addr, vid, flags);
+		fdb = fdb_create(br, dst, addr, vid, flags);
 		if (fdb) {
 			trace_br_fdb_update(br, source, addr, vid, flags);
 			fdb_notify(br, fdb, RTM_NEWNEIGH, true);
 		}
-		/* else  we lose race and someone else inserts
-		 * it first, don't bother updating
-		 */
 		spin_unlock(&br->hash_lock);
 	}
 }
@@ -1061,17 +1108,17 @@ int br_fdb_dump(struct sk_buff *skb,
 
 	rcu_read_lock();
 	hlist_for_each_entry_rcu(f, &br->fdb_list, fdb_node) {
-		const struct net_bridge_port *dst = READ_ONCE(f->dst);
+		const struct net_bridge_port *dst = br_fdb_dst_port(f);
 
 		if (*idx < ctx->fdb_idx)
 			goto skip;
 		if (filter_dev && (!dst || dst->dev != filter_dev)) {
 			if (filter_dev != dev)
 				goto skip;
-			/* !f->dst is a special case for bridge
+			/* A NULL destination is a special case for bridge
 			 * It means the MAC belongs to the bridge
 			 * Therefore need a little more filtering
-			 * we only want to dump the !f->dst case
+			 * we only want to dump the NULL destination case
 			 */
 			if (dst)
 				goto skip;
@@ -1145,10 +1192,11 @@ static bool fdb_handle_notify(struct net_bridge_fdb_entry *fdb, u8 notify)
 }
 
 /* Update (create or replace) forwarding database entry */
-static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source,
+static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst,
 			 const u8 *addr, struct ndmsg *ndm, u16 flags, u16 vid,
 			 struct nlattr *nfea_tb[])
 {
+	struct net_bridge_port *source = br_dst_port(dst);
 	bool is_sticky = !!(ndm->ndm_flags & NTF_STICKY);
 	bool refresh = !nfea_tb[NFEA_DONT_REFRESH];
 	struct net_bridge_fdb_entry *fdb;
@@ -1183,19 +1231,26 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source,
 		if (!(flags & NLM_F_CREATE))
 			return -ENOENT;
 
-		fdb = fdb_create(br, source, addr, vid,
+		fdb = fdb_create(br, dst, addr, vid,
 				 BIT(BR_FDB_ADDED_BY_USER));
 		if (!fdb)
 			return -ENOMEM;
 
 		modified = true;
 	} else {
+		struct net_bridge_dst old_dst;
+
 		if (flags & NLM_F_EXCL)
 			return -EEXIST;
 
-		if (READ_ONCE(fdb->dst) != source) {
-			WRITE_ONCE(fdb->dst, source);
-			modified = true;
+		old_dst = br_fdb_dst_read(fdb);
+		if (!br_dst_equal(old_dst, dst)) {
+			if (br_dst_port(old_dst) != source) {
+				modified = true;
+				br_fdb_dst_write(fdb, dst);
+			} else {
+				br_fdb_dst_replace(fdb, old_dst, dst);
+			}
 		}
 
 		set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags);
@@ -1244,9 +1299,12 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_port *source,
 
 static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
 			struct net_bridge_port *p, const unsigned char *addr,
-			u16 nlh_flags, u16 vid, struct nlattr *nfea_tb[],
+			u16 nlh_flags, struct net_bridge_vlan *vlan,
+			struct nlattr *nfea_tb[],
 			bool *notified, struct netlink_ext_ack *extack)
 {
+	u16 vid = vlan ? vlan->vid : 0;
+	struct net_bridge_dst dst;
 	int err = 0;
 
 	if (ndm->ndm_flags & NTF_USE) {
@@ -1260,7 +1318,7 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
 
 		local_bh_disable();
 		rcu_read_lock();
-		br_fdb_update(br, p, addr, vid, BIT(BR_FDB_ADDED_BY_USER));
+		br_fdb_update(br, p, vlan, addr, BIT(BR_FDB_ADDED_BY_USER));
 		rcu_read_unlock();
 		local_bh_enable();
 	} else if (ndm->ndm_flags & NTF_EXT_LEARNED) {
@@ -1271,8 +1329,10 @@ static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,
 		}
 		err = br_fdb_external_learn_add(br, p, addr, vid, false, true);
 	} else {
+		dst = p && vlan ? br_vlan_to_dst(vlan) : br_port_to_dst(p);
 		spin_lock_bh(&br->hash_lock);
-		err = fdb_add_entry(br, p, addr, ndm, nlh_flags, vid, nfea_tb);
+		err = fdb_add_entry(br, dst, addr, ndm, nlh_flags, vid,
+				    nfea_tb);
 		spin_unlock_bh(&br->hash_lock);
 	}
 
@@ -1352,10 +1412,10 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 		}
 
 		/* VID was specified, so use it. */
-		err = __br_fdb_add(ndm, br, p, addr, nlh_flags, vid, nfea_tb,
+		err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v, nfea_tb,
 				   notified, extack);
 	} else {
-		err = __br_fdb_add(ndm, br, p, addr, nlh_flags, 0, nfea_tb,
+		err = __br_fdb_add(ndm, br, p, addr, nlh_flags, NULL, nfea_tb,
 				   notified, extack);
 		if (err || !vg || !vg->num_vlans)
 			goto out;
@@ -1367,7 +1427,7 @@ int br_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],
 		list_for_each_entry(v, &vg->vlan_list, vlist) {
 			if (!br_vlan_should_use(v))
 				continue;
-			err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v->vid,
+			err = __br_fdb_add(ndm, br, p, addr, nlh_flags, v,
 					   nfea_tb, notified, extack);
 			if (err)
 				goto out;
@@ -1385,7 +1445,7 @@ static int fdb_delete_by_addr_and_port(struct net_bridge *br,
 	struct net_bridge_fdb_entry *fdb;
 
 	fdb = br_fdb_find(br, addr, vlan);
-	if (!fdb || READ_ONCE(fdb->dst) != p)
+	if (!fdb || br_fdb_dst_port(fdb) != p)
 		return -ENOENT;
 
 	fdb_delete(br, fdb, true);
@@ -1504,10 +1564,31 @@ void br_fdb_unsync_static(struct net_bridge *br, struct net_bridge_port *p)
 	rcu_read_unlock();
 }
 
+static struct net_bridge_dst br_fdb_resolve_dst(const struct net_bridge_port *p,
+						u16 vid)
+{
+	struct net_bridge_dst dst = br_port_to_dst(p);
+	struct net_bridge_vlan *v;
+
+	lockdep_assert(rcu_read_lock_held() || lockdep_rtnl_is_held());
+
+	if (!p || !vid)
+		return dst;
+
+	rcu_read_lock();
+	v = br_vlan_find(nbp_vlan_group_rcu(p), vid);
+	if (v)
+		dst = br_vlan_to_dst(v);
+	rcu_read_unlock();
+
+	return dst;
+}
+
 int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
 			      const unsigned char *addr, u16 vid, bool locked,
 			      bool swdev_notify)
 {
+	struct net_bridge_dst dst = br_fdb_resolve_dst(p, vid);
 	struct net_bridge_fdb_entry *fdb;
 	bool modified = false;
 	int err = 0;
@@ -1532,25 +1613,32 @@ int br_fdb_external_learn_add(struct net_bridge *br, struct net_bridge_port *p,
 		if (locked)
 			flags |= BIT(BR_FDB_LOCKED);
 
-		fdb = fdb_create(br, p, addr, vid, flags);
+		fdb = fdb_create(br, dst, addr, vid, flags);
 		if (!fdb) {
 			err = -ENOMEM;
 			goto err_unlock;
 		}
 		fdb_notify(br, fdb, RTM_NEWNEIGH, swdev_notify);
 	} else {
+		struct net_bridge_dst old_dst;
+
+		old_dst = br_fdb_dst_read(fdb);
 		if (locked &&
 		    (!test_bit(BR_FDB_LOCKED, &fdb->flags) ||
-		     READ_ONCE(fdb->dst) != p)) {
+		     br_dst_port(old_dst) != p)) {
 			err = -EINVAL;
 			goto err_unlock;
 		}
 
 		WRITE_ONCE(fdb->updated, jiffies);
 
-		if (READ_ONCE(fdb->dst) != p) {
-			WRITE_ONCE(fdb->dst, p);
-			modified = true;
+		if (!br_dst_equal(old_dst, dst)) {
+			if (br_dst_port(old_dst) != p) {
+				modified = true;
+				br_fdb_dst_write(fdb, dst);
+			} else {
+				br_fdb_dst_replace(fdb, old_dst, dst);
+			}
 		}
 
 		if (test_and_set_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) {
@@ -1632,7 +1720,7 @@ void br_fdb_clear_offload(const struct net_device *dev, u16 vid)
 
 	spin_lock_bh(&p->br->hash_lock);
 	hlist_for_each_entry(f, &p->br->fdb_list, fdb_node) {
-		if (READ_ONCE(f->dst) == p && f->key.vlan_id == vid)
+		if (br_fdb_dst_port(f) == p && f->key.vlan_id == vid)
 			clear_bit(BR_FDB_OFFLOADED, &f->flags);
 	}
 	spin_unlock_bh(&p->br->hash_lock);
diff --git a/net/bridge/br_forward.c b/net/bridge/br_forward.c
index b5eece1ff9e8c..82645db32efbe 100644
--- a/net/bridge/br_forward.c
+++ b/net/bridge/br_forward.c
@@ -17,7 +17,7 @@
 #include "br_private.h"
 
 struct br_fwd_dst {
-	const struct net_bridge_port *port;
+	struct net_bridge_port *port;
 	struct net_bridge_vlan *vlan;
 };
 
@@ -149,35 +149,37 @@ static int deliver_clone(const struct br_fwd_dst *fwd,
 
 /**
  * br_forward - forward a packet to a specific port
- * @to: destination port
+ * @dst: bridge destination
  * @skb: packet being forwarded
  * @local_rcv: packet will be received locally after forwarding
  * @local_orig: packet is locally originated
  *
  * Should be called with rcu_read_lock.
  */
-void br_forward(const struct net_bridge_port *to,
+void br_forward(struct net_bridge_dst dst,
 		struct sk_buff *skb, bool local_rcv, bool local_orig)
 {
 	struct br_fwd_dst fwd;
 
-	if (unlikely(!to))
+	br_dst_decode(dst, &fwd.port, &fwd.vlan);
+
+	if (unlikely(!fwd.port))
 		goto out;
 
 	/* redirect to backup link if the destination port is down */
-	if (rcu_access_pointer(to->backup_port) &&
-	    (!netif_carrier_ok(to->dev) || !netif_running(to->dev))) {
+	if (rcu_access_pointer(fwd.port->backup_port) &&
+	    (!netif_carrier_ok(fwd.port->dev) ||
+	     !netif_running(fwd.port->dev))) {
 		struct net_bridge_port *backup_port;
 
-		backup_port = rcu_dereference(to->backup_port);
+		backup_port = rcu_dereference(fwd.port->backup_port);
 		if (unlikely(!backup_port))
 			goto out;
-		BR_INPUT_SKB_CB(skb)->backup_nhid = READ_ONCE(to->backup_nhid);
-		to = backup_port;
+		BR_INPUT_SKB_CB(skb)->backup_nhid = READ_ONCE(fwd.port->backup_nhid);
+		fwd.port = backup_port;
+		fwd.vlan = NULL;
 	}
 
-	fwd.port = to;
-	fwd.vlan = NULL;
 	if (should_deliver(&fwd, skb)) {
 		if (local_rcv)
 			deliver_clone(&fwd, skb, local_orig);
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c
index c52613431f886..2c05ebc1299d1 100644
--- a/net/bridge/br_if.c
+++ b/net/bridge/br_if.c
@@ -333,8 +333,9 @@ static void update_headroom(struct net_bridge *br, int new_hr)
  */
 static void del_nbp(struct net_bridge_port *p)
 {
-	struct net_bridge *br = p->br;
+	struct net_bridge_vlan_group *vg;
 	struct net_device *dev = p->dev;
+	struct net_bridge *br = p->br;
 
 	sysfs_remove_link(br->ifobj, p->dev->name);
 
@@ -354,8 +355,10 @@ static void del_nbp(struct net_bridge_port *p)
 		update_headroom(br, get_max_headroom(br));
 	netdev_reset_rx_headroom(dev);
 
-	nbp_vlan_flush(p);
-	br_fdb_delete_by_port(br, p, 0, 1);
+	vg = nbp_vlan_group(p);
+	nbp_vlan_group_unpublish(p);
+	br_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 1);
+	nbp_vlan_flush(p, vg);
 	switchdev_deferred_process();
 	nbp_backup_clear(p);
 
@@ -390,7 +393,7 @@ void br_dev_delete(struct net_device *dev, struct list_head *head)
 	br_mst_uninit(br);
 	br_recalculate_neigh_suppress_enabled(br);
 
-	br_fdb_delete_by_port(br, NULL, 0, 1);
+	br_fdb_cleanup_by_dst(br, br_port_to_dst(NULL), 0, 1);
 
 	timer_shutdown_sync(&br->hello_timer);
 	timer_shutdown_sync(&br->topology_change_timer);
@@ -696,7 +699,7 @@ int br_add_if(struct net_bridge *br, struct net_device *dev,
 	if (fdb_synced)
 		br_fdb_unsync_static(br, p);
 	list_del_rcu(&p->list);
-	br_fdb_delete_by_port(br, p, 0, 1);
+	br_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 1);
 	nbp_update_port_count(br);
 	netdev_upper_dev_unlink(dev, br->dev);
 err5:
diff --git a/net/bridge/br_input.c b/net/bridge/br_input.c
index 4357d78524a68..fc2e381c4fe03 100644
--- a/net/bridge/br_input.c
+++ b/net/bridge/br_input.c
@@ -86,8 +86,8 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 	struct net_bridge_vlan *vlan;
 	struct net_bridge *br;
 	bool promisc;
-	u16 vid = 0;
 	u8 state;
+	u16 vid;
 
 	if (!p)
 		goto drop;
@@ -107,9 +107,10 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 
 	brmctx = &p->br->multicast_ctx;
 	pmctx = &p->multicast_ctx;
-	if (!br_allowed_ingress(p->br, nbp_vlan_group_rcu(p), skb, &vid,
-				&state, &vlan))
+	if (!br_allowed_ingress(p->br, nbp_vlan_group_rcu(p), skb, &state,
+				&vlan))
 		goto out;
+	vid = vlan ? vlan->vid : 0;
 
 	if (test_bit(BR_PORT_LOCKED_BIT, &p->flags)) {
 		struct net_bridge_fdb_entry *fdb_src =
@@ -120,10 +121,11 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 			 * 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));
+				br_fdb_update(br, p, vlan,
+					      eth_hdr(skb)->h_source,
+					      BIT(BR_FDB_LOCKED));
 			goto drop;
-		} else if (READ_ONCE(fdb_src->dst) != p ||
+		} else if (br_fdb_dst_port(fdb_src) != p ||
 			   test_bit(BR_FDB_LOCAL, &fdb_src->flags)) {
 			/* FDB mismatch. Drop the packet without roaming. */
 			goto drop;
@@ -131,7 +133,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 			/* FDB match, but entry is locked. Refresh it and drop
 			 * the packet.
 			 */
-			br_fdb_update(br, p, eth_hdr(skb)->h_source, vid,
+			br_fdb_update(br, p, vlan, eth_hdr(skb)->h_source,
 				      BIT(BR_FDB_LOCKED));
 			goto drop;
 		}
@@ -141,7 +143,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *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);
+		br_fdb_update(br, p, vlan, eth_hdr(skb)->h_source, 0);
 
 	promisc = !!(br->dev->flags & IFF_PROMISC);
 	local_rcv = promisc;
@@ -223,7 +225,7 @@ int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb
 
 		if (now != READ_ONCE(dst->used))
 			WRITE_ONCE(dst->used, now);
-		br_forward(READ_ONCE(dst->dst), skb, local_rcv, false);
+		br_forward(br_fdb_dst_read(dst), skb, local_rcv, false);
 	} else {
 		if (!mcast_hit)
 			br_flood(br, vlan, skb, pkt_type, local_rcv, false);
@@ -245,14 +247,14 @@ EXPORT_SYMBOL_GPL(br_handle_frame_finish);
 static void __br_handle_local_finish(struct sk_buff *skb)
 {
 	struct net_bridge_port *p = br_port_get_rcu(skb->dev);
-	u16 vid = 0;
+	struct net_bridge_vlan *vlan;
 
 	/* check if vlan is allowed, to avoid spoofing */
 	if (test_bit(BR_LEARNING_BIT, &p->flags) &&
 	    nbp_state_should_learn(p) &&
 	    !br_opt_get(p->br, BROPT_NO_LL_LEARN) &&
-	    br_should_learn(p, skb, &vid))
-		br_fdb_update(p->br, p, eth_hdr(skb)->h_source, vid, 0);
+	    br_should_learn(p, skb, &vlan))
+		br_fdb_update(p->br, p, vlan, eth_hdr(skb)->h_source, 0);
 }
 
 /* note: already called with rcu_read_lock */
diff --git a/net/bridge/br_mrp.c b/net/bridge/br_mrp.c
index dce6efa96c4c6..c8cd5b4f3af8f 100644
--- a/net/bridge/br_mrp.c
+++ b/net/bridge/br_mrp.c
@@ -1219,11 +1219,11 @@ static int br_mrp_rcv(struct net_bridge_port *p,
 
 forward:
 	if (p_dst)
-		br_forward(p_dst, skb, true, false);
+		br_forward(br_port_to_dst(p_dst), skb, true, false);
 	if (s_dst)
-		br_forward(s_dst, skb, true, false);
+		br_forward(br_port_to_dst(s_dst), skb, true, false);
 	if (i_dst)
-		br_forward(i_dst, skb, true, false);
+		br_forward(br_port_to_dst(i_dst), skb, true, false);
 
 no_forward:
 	return 1;
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index ae76df0de05a0..f65b8b6ca97c0 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -1044,7 +1044,7 @@ static int br_setport(struct net_bridge_port *p, struct nlattr *tb[],
 	}
 
 	if (tb[IFLA_BRPORT_FLUSH])
-		br_fdb_delete_by_port(p->br, p, 0, 0);
+		br_fdb_cleanup_by_dst(p->br, br_port_to_dst(p), 0, 0);
 
 #ifdef CONFIG_BRIDGE_IGMP_SNOOPING
 	if (tb[IFLA_BRPORT_MULTICAST_ROUTER]) {
diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h
index 67117fb3dc880..05921192ebda1 100644
--- a/net/bridge/br_private.h
+++ b/net/bridge/br_private.h
@@ -306,9 +306,15 @@ struct net_bridge_fdb_key {
 	u16 vlan_id;
 };
 
+#define BR_DST_VLAN_TAG	BIT(0)
+
+struct net_bridge_dst {
+	unsigned long __private value;
+};
+
 struct net_bridge_fdb_entry {
 	struct rhash_head		rhnode;
-	struct net_bridge_port		*dst;
+	struct net_bridge_dst		dst;
 
 	struct net_bridge_fdb_key	key;
 	struct hlist_node		fdb_node;
@@ -670,6 +676,122 @@ struct br_input_skb_cb {
 #define br_debug(br, format, args...)			\
 	pr_debug("%s: " format,  (br)->dev->name, ##args)
 
+static inline struct net_bridge_dst
+br_dst_read(const struct net_bridge_dst *src)
+{
+	struct net_bridge_dst dst;
+
+	ACCESS_PRIVATE(&dst, value) =
+		READ_ONCE(ACCESS_PRIVATE(src, value));
+
+	return dst;
+}
+
+static inline void br_dst_write(struct net_bridge_dst *dst,
+				struct net_bridge_dst src)
+{
+	WRITE_ONCE(ACCESS_PRIVATE(dst, value),
+		   ACCESS_PRIVATE(&src, value));
+}
+
+static inline bool br_dst_equal(struct net_bridge_dst dst1,
+				struct net_bridge_dst dst2)
+{
+	return ACCESS_PRIVATE(&dst1, value) ==
+	       ACCESS_PRIVATE(&dst2, value);
+}
+
+static inline struct net_bridge_dst
+br_port_to_dst(const struct net_bridge_port *p)
+{
+	struct net_bridge_dst dst;
+
+	ACCESS_PRIVATE(&dst, value) = (unsigned long)p;
+
+	return dst;
+}
+
+static inline struct net_bridge_dst
+br_vlan_to_dst(const struct net_bridge_vlan *v)
+{
+	struct net_bridge_dst dst;
+
+	ACCESS_PRIVATE(&dst, value) = (unsigned long)v | BR_DST_VLAN_TAG;
+
+	return dst;
+}
+
+static inline void br_dst_decode(struct net_bridge_dst dst,
+				 struct net_bridge_port **port,
+				 struct net_bridge_vlan **vlan)
+{
+	struct net_bridge_vlan *v;
+	unsigned long value;
+
+	value = ACCESS_PRIVATE(&dst, value);
+	if (!(value & BR_DST_VLAN_TAG)) {
+		*port = (struct net_bridge_port *)value;
+		*vlan = NULL;
+		return;
+	}
+
+	v = (struct net_bridge_vlan *)(value & ~BR_DST_VLAN_TAG);
+	*port = v->port;
+	*vlan = v;
+}
+
+static inline struct net_bridge_port *
+br_dst_port(struct net_bridge_dst dst)
+{
+	struct net_bridge_port *p;
+	struct net_bridge_vlan *v;
+
+	br_dst_decode(dst, &p, &v);
+
+	return p;
+}
+
+static inline struct net_bridge_vlan *
+br_dst_vlan(struct net_bridge_dst dst)
+{
+	unsigned long value;
+
+	value = ACCESS_PRIVATE(&dst, value);
+	if (!(value & BR_DST_VLAN_TAG))
+		return NULL;
+
+	return (struct net_bridge_vlan *)(value & ~BR_DST_VLAN_TAG);
+}
+
+static inline struct net_bridge_dst
+br_fdb_dst_read(const struct net_bridge_fdb_entry *fdb)
+{
+	return br_dst_read(&fdb->dst);
+}
+
+static inline void br_fdb_dst_write(struct net_bridge_fdb_entry *fdb,
+				    struct net_bridge_dst dst)
+{
+	br_dst_write(&fdb->dst, dst);
+}
+
+static inline bool
+br_fdb_dst_replace(struct net_bridge_fdb_entry *fdb,
+		   struct net_bridge_dst old,
+		   struct net_bridge_dst new)
+{
+	unsigned long old_value = ACCESS_PRIVATE(&old, value);
+
+	return cmpxchg(&ACCESS_PRIVATE(&fdb->dst, value), old_value,
+		       ACCESS_PRIVATE(&new, value)) == old_value;
+}
+
+static inline struct net_bridge_port *
+br_fdb_dst_port(const struct net_bridge_fdb_entry *fdb)
+{
+	return br_dst_port(br_fdb_dst_read(fdb));
+}
+
 /* called under bridge lock */
 static inline int br_is_root_bridge(const struct net_bridge *br)
 {
@@ -879,8 +1001,8 @@ void br_fdb_change_mac_address(struct net_bridge *br, const u8 *newaddr);
 void br_fdb_cleanup(struct work_struct *work);
 int br_fdb_toggle_local_vlan_0(struct net_bridge *br, bool on,
 			       struct netlink_ext_ack *extack);
-void br_fdb_delete_by_port(struct net_bridge *br,
-			   const struct net_bridge_port *p, u16 vid, int do_all);
+void br_fdb_cleanup_by_dst(struct net_bridge *br,
+			   struct net_bridge_dst dst, u16 vid, int do_all);
 struct net_bridge_fdb_entry *br_fdb_find_rcu(struct net_bridge *br,
 					     const unsigned char *addr,
 					     __u16 vid);
@@ -889,7 +1011,8 @@ int br_fdb_fillbuf(struct net_bridge *br, void *buf, unsigned long count,
 int br_fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,
 		     const unsigned char *addr, u16 vid);
 void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,
-		   const unsigned char *addr, u16 vid, unsigned long flags);
+		   struct net_bridge_vlan *vlan, const unsigned char *addr,
+		   unsigned long flags);
 
 int br_fdb_delete(struct ndmsg *ndm, struct nlattr *tb[],
 		  struct net_device *dev, const unsigned char *addr, u16 vid,
@@ -922,7 +1045,7 @@ enum br_pkt_type {
 	BR_PKT_BROADCAST
 };
 int br_dev_queue_push_xmit(struct net *net, struct sock *sk, struct sk_buff *skb);
-void br_forward(const struct net_bridge_port *to, struct sk_buff *skb,
+void br_forward(struct net_bridge_dst dst, struct sk_buff *skb,
 		bool local_rcv, bool local_orig);
 int br_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
 void br_flood(struct net_bridge *br, struct net_bridge_vlan *v,
@@ -1598,11 +1721,11 @@ br_multicast_ctx_options_equal(const struct net_bridge_mcast *brmctx1,
 #ifdef CONFIG_BRIDGE_VLAN_FILTERING
 bool br_allowed_ingress(const struct net_bridge *br,
 			struct net_bridge_vlan_group *vg, struct sk_buff *skb,
-			u16 *vid, u8 *state,
-			struct net_bridge_vlan **vlan);
+			u8 *state, struct net_bridge_vlan **vlan);
 bool br_allowed_egress(struct net_bridge_vlan_group *vg,
 		       const struct sk_buff *skb);
-bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid);
+bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb,
+		     struct net_bridge_vlan **vlan);
 struct sk_buff *br_handle_vlan(struct net_bridge *br,
 			       const struct net_bridge_port *port,
 			       struct net_bridge_vlan_group *vg,
@@ -1630,7 +1753,9 @@ int __br_vlan_set_default_pvid(struct net_bridge *br, u16 pvid,
 int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
 		 bool *changed, struct netlink_ext_ack *extack);
 int nbp_vlan_delete(struct net_bridge_port *port, u16 vid);
-void nbp_vlan_flush(struct net_bridge_port *port);
+void nbp_vlan_group_unpublish(struct net_bridge_port *port);
+void nbp_vlan_flush(struct net_bridge_port *port,
+		    struct net_bridge_vlan_group *vg);
 int nbp_vlan_init(struct net_bridge_port *port, struct netlink_ext_ack *extack);
 int nbp_get_num_vlan_infos(struct net_bridge_port *p, u32 filter_mask);
 void br_vlan_get_stats(const struct net_bridge_vlan *v,
@@ -1721,7 +1846,7 @@ static inline u16 br_vlan_flags(const struct net_bridge_vlan *v, u16 pvid)
 static inline bool br_allowed_ingress(const struct net_bridge *br,
 				      struct net_bridge_vlan_group *vg,
 				      struct sk_buff *skb,
-				      u16 *vid, u8 *state,
+				      u8 *state,
 				      struct net_bridge_vlan **vlan)
 
 {
@@ -1736,8 +1861,10 @@ static inline bool br_allowed_egress(struct net_bridge_vlan_group *vg,
 }
 
 static inline bool br_should_learn(struct net_bridge_port *p,
-				   struct sk_buff *skb, u16 *vid)
+				   struct sk_buff *skb,
+				   struct net_bridge_vlan **vlan)
 {
+	*vlan = NULL;
 	return true;
 }
 
@@ -1787,7 +1914,13 @@ static inline int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
 	return -EOPNOTSUPP;
 }
 
-static inline void nbp_vlan_flush(struct net_bridge_port *port)
+static inline void nbp_vlan_group_unpublish(struct net_bridge_port *port)
+{
+}
+
+static inline void
+nbp_vlan_flush(struct net_bridge_port *port,
+	       struct net_bridge_vlan_group *vg)
 {
 }
 
diff --git a/net/bridge/br_stp_if.c b/net/bridge/br_stp_if.c
index a7e5422eb5d14..2e5190278c903 100644
--- a/net/bridge/br_stp_if.c
+++ b/net/bridge/br_stp_if.c
@@ -114,7 +114,7 @@ void br_stp_disable_port(struct net_bridge_port *p)
 	timer_delete(&p->hold_timer);
 
 	if (!rcu_access_pointer(p->backup_port))
-		br_fdb_delete_by_port(br, p, 0, 0);
+		br_fdb_cleanup_by_dst(br, br_port_to_dst(p), 0, 0);
 	br_multicast_disable_port(p);
 
 	br_configuration_update(br);
diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index 990c6b38fd397..10f3aea6a1f82 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -129,7 +129,7 @@ static void br_switchdev_fdb_populate(struct net_bridge *br,
 				      const struct net_bridge_fdb_entry *fdb,
 				      const void *ctx)
 {
-	const struct net_bridge_port *p = READ_ONCE(fdb->dst);
+	const struct net_bridge_port *p = br_fdb_dst_port(fdb);
 
 	item->addr = fdb->key.addr.addr;
 	item->vid = fdb->key.vlan_id;
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index b9bcafa7f034c..621d62a063d98 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -191,7 +191,8 @@ static BRPORT_ATTR(hold_timer, 0444, show_hold_timer, NULL);
 
 static int store_flush(struct net_bridge_port *p, unsigned long v)
 {
-	br_fdb_delete_by_port(p->br, p, 0, 0); // Don't delete local entry
+	/* Don't delete local entry */
+	br_fdb_cleanup_by_dst(p->br, br_port_to_dst(p), 0, 0);
 	return 0;
 }
 static BRPORT_ATTR(flush, 0200, NULL, store_flush);
diff --git a/net/bridge/br_vlan.c b/net/bridge/br_vlan.c
index ce5aa15c45402..0675f74cf1b99 100644
--- a/net/bridge/br_vlan.c
+++ b/net/bridge/br_vlan.c
@@ -429,22 +429,34 @@ static int __vlan_add(struct net_bridge_vlan *v, u16 flags,
 	goto out;
 }
 
-static void __vlan_del(struct net_bridge_vlan *v)
+static void __vlan_unpublish(struct net_bridge_vlan_group *vg,
+			     struct net_bridge_vlan *v)
+{
+	__vlan_delete_pvid(vg, v);
+	if (!br_vlan_is_master(v)) {
+		struct net_bridge_vlan *masterv = v->brvlan;
+
+		rhashtable_remove_fast(&vg->vlan_hash, &v->vnode,
+				       br_vlan_rht_params);
+		__vlan_del_list(v);
+		/* -1 because br_vlan_put_master() is called later */
+		br_vlan_rebuild_port_array(masterv,
+					   br_vlan_num_ports(masterv) - 1);
+	}
+}
+
+static void __vlan_del(struct net_bridge_vlan_group *vg,
+		       struct net_bridge_vlan *v)
 {
 	struct net_bridge_vlan *masterv = v;
-	struct net_bridge_vlan_group *vg;
 	struct net_bridge_port *p = NULL;
 	int err;
 
-	if (br_vlan_is_master(v)) {
-		vg = br_vlan_group(v->br);
-	} else {
+	if (!br_vlan_is_master(v)) {
 		p = v->port;
-		vg = nbp_vlan_group(v->port);
 		masterv = v->brvlan;
 	}
 
-	__vlan_delete_pvid(vg, v);
 	if (p) {
 		err = __vlan_vid_del(p->dev, p->br, v);
 		if (err)
@@ -467,12 +479,6 @@ static void __vlan_del(struct net_bridge_vlan *v)
 
 	if (masterv != v) {
 		vlan_tunnel_info_del(vg, v);
-		rhashtable_remove_fast(&vg->vlan_hash, &v->vnode,
-				       br_vlan_rht_params);
-		__vlan_del_list(v);
-		/* -1 because br_vlan_put_master() is called later */
-		br_vlan_rebuild_port_array(masterv,
-					   br_vlan_num_ports(masterv) - 1);
 		nbp_vlan_set_vlan_dev_state(p, v->vid);
 		br_multicast_toggle_one_vlan(v, false);
 		br_multicast_port_ctx_deinit(&v->port_mcast_ctx);
@@ -509,7 +515,8 @@ static void __vlan_flush(const struct net_bridge *br,
 		}
 		v_end = vlan->vid;
 
-		__vlan_del(vlan);
+		__vlan_unpublish(vg, vlan);
+		__vlan_del(vg, vlan);
 	}
 
 	/* notify about the last/whole vlan range */
@@ -583,13 +590,13 @@ struct sk_buff *br_handle_vlan(struct net_bridge *br,
 /* Called under RCU */
 static bool __allowed_ingress(const struct net_bridge *br,
 			      struct net_bridge_vlan_group *vg,
-			      struct sk_buff *skb, u16 *vid,
-			      u8 *state,
+			      struct sk_buff *skb, u8 *state,
 			      struct net_bridge_vlan **vlan)
 {
 	struct pcpu_sw_netstats *stats;
 	struct net_bridge_vlan *v;
 	bool tagged;
+	u16 vid;
 
 	BR_INPUT_SKB_CB(skb)->vlan_filtered = true;
 	/* If vlan tx offload is disabled on bridge device and frame was
@@ -603,7 +610,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 			return false;
 	}
 
-	if (!br_vlan_get_tag(skb, vid)) {
+	if (!br_vlan_get_tag(skb, &vid)) {
 		/* Tagged frame */
 		if (skb->vlan_proto != br->vlan_proto) {
 			/* Protocol-mismatch, empty out vlan_tci for new tag */
@@ -615,7 +622,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 
 			skb_pull(skb, ETH_HLEN);
 			skb_reset_mac_len(skb);
-			*vid = 0;
+			vid = 0;
 			tagged = false;
 		} else {
 			tagged = true;
@@ -625,7 +632,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 		tagged = false;
 	}
 
-	if (!*vid) {
+	if (!vid) {
 		v = vg ? rcu_dereference(vg->pvid) : NULL;
 		/* Frame had a tag with VID 0 or did not have a tag.
 		 * See if pvid is set on this port.  That tells us which
@@ -637,7 +644,6 @@ static bool __allowed_ingress(const struct net_bridge *br,
 		/* PVID is set on this port.  Any untagged or priority-tagged
 		 * ingress frame is considered to belong to this vlan.
 		 */
-		*vid = v->vid;
 		if (likely(!tagged))
 			/* Untagged Frame. */
 			__vlan_hwaccel_put_tag(skb, br->vlan_proto, v->vid);
@@ -649,7 +655,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 			 */
 			skb->vlan_tci |= v->vid;
 	} else {
-		v = br_vlan_find(vg, *vid);
+		v = br_vlan_find(vg, vid);
 	}
 
 	if (!v || !br_vlan_should_use(v))
@@ -680,8 +686,7 @@ static bool __allowed_ingress(const struct net_bridge *br,
 
 bool br_allowed_ingress(const struct net_bridge *br,
 			struct net_bridge_vlan_group *vg, struct sk_buff *skb,
-			u16 *vid, u8 *state,
-			struct net_bridge_vlan **vlan)
+			u8 *state, struct net_bridge_vlan **vlan)
 {
 	/* If VLAN filtering is disabled on the bridge, all packets are
 	 * permitted.
@@ -692,7 +697,7 @@ bool br_allowed_ingress(const struct net_bridge *br,
 		return true;
 	}
 
-	return __allowed_ingress(br, vg, skb, vid, state, vlan);
+	return __allowed_ingress(br, vg, skb, state, vlan);
 }
 
 /* Called under RCU. */
@@ -716,11 +721,15 @@ bool br_allowed_egress(struct net_bridge_vlan_group *vg,
 }
 
 /* Called under RCU */
-bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid)
+bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb,
+		     struct net_bridge_vlan **vlan)
 {
 	struct net_bridge_vlan_group *vg;
 	struct net_bridge *br = p->br;
 	struct net_bridge_vlan *v;
+	u16 vid;
+
+	*vlan = NULL;
 
 	/* If filtering was disabled at input, let it pass. */
 	if (!br_opt_get(br, BROPT_VLAN_ENABLED))
@@ -730,20 +739,22 @@ bool br_should_learn(struct net_bridge_port *p, struct sk_buff *skb, u16 *vid)
 	if (!vg || !READ_ONCE(vg->num_vlans))
 		return false;
 
-	if (!br_vlan_get_tag(skb, vid) && skb->vlan_proto != br->vlan_proto)
-		*vid = 0;
+	if (!br_vlan_get_tag(skb, &vid) && skb->vlan_proto != br->vlan_proto)
+		vid = 0;
 
-	if (!*vid) {
+	if (!vid) {
 		v = rcu_dereference(vg->pvid);
 		if (!v || !br_vlan_state_allowed(br_vlan_get_state(v), true))
 			return false;
-		*vid = v->vid;
+		*vlan = v;
 		return true;
 	}
 
-	v = br_vlan_find(vg, *vid);
-	if (v && br_vlan_state_allowed(br_vlan_get_state(v), true))
+	v = br_vlan_find(vg, vid);
+	if (v && br_vlan_state_allowed(br_vlan_get_state(v), true)) {
+		*vlan = v;
 		return true;
+	}
 
 	return false;
 }
@@ -866,10 +877,11 @@ int br_vlan_delete(struct net_bridge *br, u16 vid)
 		return -ENOENT;
 
 	br_fdb_find_delete_local(br, NULL, br->dev->dev_addr, vid);
-	br_fdb_delete_by_port(br, NULL, vid, 0);
+	br_fdb_cleanup_by_dst(br, br_port_to_dst(NULL), vid, 0);
 
 	vlan_tunnel_info_del(vg, v);
-	__vlan_del(v);
+	__vlan_unpublish(vg, v);
+	__vlan_del(vg, v);
 
 	return 0;
 }
@@ -1385,30 +1397,41 @@ int nbp_vlan_add(struct net_bridge_port *port, u16 vid, u16 flags,
  */
 int nbp_vlan_delete(struct net_bridge_port *port, u16 vid)
 {
+	struct net_bridge_vlan_group *vg;
 	struct net_bridge_vlan *v;
 
 	ASSERT_RTNL();
 
-	v = br_vlan_find(nbp_vlan_group(port), vid);
+	vg = nbp_vlan_group(port);
+	v = br_vlan_find(vg, vid);
 	if (!v)
 		return -ENOENT;
-	br_fdb_find_delete_local(port->br, port, port->dev->dev_addr, vid);
-	br_fdb_delete_by_port(port->br, port, vid, 0);
-	__vlan_del(v);
+	__vlan_unpublish(vg, v);
+	synchronize_net();
+	/* Traffic may still use v through cached fdb dsts until they are
+	 * cleaned below. This is acceptable during vlan deletion. Above we
+	 * drain the readers that could republish the dst before cleaning it
+	 */
+	br_fdb_cleanup_by_dst(port->br, br_vlan_to_dst(v), vid, 0);
+	__vlan_del(vg, v);
 
 	return 0;
 }
 
-void nbp_vlan_flush(struct net_bridge_port *port)
+void nbp_vlan_group_unpublish(struct net_bridge_port *port)
 {
-	struct net_bridge_vlan_group *vg;
-
 	ASSERT_RTNL();
 
-	vg = nbp_vlan_group(port);
-	__vlan_flush(port->br, port, vg);
 	RCU_INIT_POINTER(port->vlgrp, NULL);
 	synchronize_net();
+}
+
+void nbp_vlan_flush(struct net_bridge_port *port,
+		    struct net_bridge_vlan_group *vg)
+{
+	ASSERT_RTNL();
+
+	__vlan_flush(port->br, port, vg);
 	__vlan_group_free(vg);
 }
 
diff --git a/net/bridge/netfilter/nft_reject_bridge.c b/net/bridge/netfilter/nft_reject_bridge.c
index cd2b04236a99c..92b488793914a 100644
--- a/net/bridge/netfilter/nft_reject_bridge.c
+++ b/net/bridge/netfilter/nft_reject_bridge.c
@@ -55,7 +55,7 @@ static void nft_reject_br_send_v4_tcp_reset(struct net *net,
 
 	nft_reject_br_push_etherhdr(oldskb, nskb);
 
-	br_forward(br_port_get_rcu(dev), nskb, false, true);
+	br_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);
 }
 
 static void nft_reject_br_send_v4_unreach(struct net *net,
@@ -71,7 +71,7 @@ static void nft_reject_br_send_v4_unreach(struct net *net,
 
 	nft_reject_br_push_etherhdr(oldskb, nskb);
 
-	br_forward(br_port_get_rcu(dev), nskb, false, true);
+	br_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);
 }
 
 static void nft_reject_br_send_v6_tcp_reset(struct net *net,
@@ -87,7 +87,7 @@ static void nft_reject_br_send_v6_tcp_reset(struct net *net,
 
 	nft_reject_br_push_etherhdr(oldskb, nskb);
 
-	br_forward(br_port_get_rcu(dev), nskb, false, true);
+	br_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);
 }
 
 
@@ -104,7 +104,7 @@ static void nft_reject_br_send_v6_unreach(struct net *net,
 
 	nft_reject_br_push_etherhdr(oldskb, nskb);
 
-	br_forward(br_port_get_rcu(dev), nskb, false, true);
+	br_forward(br_port_to_dst(br_port_get_rcu(dev)), nskb, false, true);
 }
 
 static void nft_reject_bridge_eval(const struct nft_expr *expr,

37/3 2026/10/01 04:46 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 23095
							output: 36
							thoughts: 789
						

Thoughts:
**KMSAN Fuzzing Session Justification: Bridge Forwarding Patch Analysis**

Okay, so the task at hand is to determine if this refactoring of the bridge forwarding destination warrants a dedicated KMSAN fuzzing session. Let's break this down. First, I need to understand what this patch actually *does*. Right, looking at the commit, it's refactoring the `struct net_bridge_fdb_entry` and the FDB destination concept. Instead of directly storing a `struct net_bridge_port *dst`, we now have `struct net_bridge_dst`, which cleverly encapsulates either a `net_bridge_port *` or a tagged pointer to a `net_bridge_vlan *`. They've implemented a few helper functions to manage this new structure: `br_dst_read`, `br_dst_write`, etc.

Now, let's see how this change ripples through the relevant functions. `br_forward()` now takes the `struct net_bridge_dst dst` instead of a plain port pointer. It decodes the destination into `fwd.port` and `fwd.vlan`. This looks reasonable.  Similarly, `br_fdb_update()` now takes a `struct net_bridge_vlan *vlan` instead of just a `u16 vid`, calculates the destination and assigns vid accordingly. The `br_allowed_ingress()` and `br_should_learn()` functions are adapted too.  Interesting, `br_allowed_ingress()` no longer takes a `u16 *vid` pointer directly. Instead, the caller now initializes the `vid` locally. `br_should_learn()` takes a `struct net_bridge_vlan **vlan` pointer now. Also note the tracepoint change to reflect the updated `net_bridge_fdb_entry`.

Right, the key concern here is uninitialized memory. With this kind of refactoring, where pointers and structures are being manipulated and decoded, it's a prime target for introducing subtle bugs if not handled carefully. So I need to go through this with a fine-tooth comb and check if any new uninitialized variables are being introduced or if existing ones are being mishandled.

Let's focus on `net/bridge/br_device.c` particularly around the br_dev_xmit() function. It now reads:

```c
	if (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, &state,
				&vlan))
		goto out;
	vid = vlan ? vlan->vid : 0;
```

Hmm... What was `vid` before this patch?  I need to review that code block closely, specifically around lines 60-70 of `br_device.c` to see how `vid`, `state`, and `vlan` were initialized and used *before* this refactoring. I need to make sure the flow of data is still correct and that no assumptions are being made about the initial state of these variables, especially given the change in function signatures. If the prior initialization pattern is not preserved, then this might be risky. This is the critical piece that I need to investigate further to determine the necessity of a KMSAN fuzzing session. This code is my main suspect.



38/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_device.c",
  "FirstLine": 40,
  "LineCount": 50
}

Results:
{
  "Contents": "  40:\t\tstruct net_bridge_vlan *vlan;\n  41:\t\tconst unsigned char *dest;\n  42:\t\tu16 vid = 0;\n  43:\t\n  44:\t\tif (unlikely(reason != SKB_NOT_DROPPED_YET)) {\n  45:\t\t\tkfree_skb_reason(skb, reason);\n  46:\t\t\treturn NETDEV_TX_OK;\n  47:\t\t}\n  48:\t\n  49:\t\tmemset(skb-\u003ecb, 0, sizeof(struct br_input_skb_cb));\n  50:\t\tbr_tc_skb_miss_set(skb, false);\n  51:\t\n  52:\t\trcu_read_lock();\n  53:\t\tnf_ops = rcu_dereference(nf_br_ops);\n  54:\t\tif (nf_ops \u0026\u0026 nf_ops-\u003ebr_dev_xmit_hook(skb)) {\n  55:\t\t\trcu_read_unlock();\n  56:\t\t\treturn NETDEV_TX_OK;\n  57:\t\t}\n  58:\t\n  59:\t\tdev_sw_netstats_tx_add(dev, 1, skb-\u003elen);\n  60:\t\n  61:\t\tbr_switchdev_frame_unmark(skb);\n  62:\t\tBR_INPUT_SKB_CB(skb)-\u003ebrdev = dev;\n  63:\t\tBR_INPUT_SKB_CB(skb)-\u003efrag_max_size = 0;\n  64:\t\n  65:\t\tskb_reset_mac_header(skb);\n  66:\t\tskb_pull(skb, ETH_HLEN);\n  67:\t\n  68:\t\tif (!br_allowed_ingress(br, br_vlan_group_rcu(br), skb, \u0026state,\n  69:\t\t\t\t\t\u0026vlan))\n  70:\t\t\tgoto out;\n  71:\t\tvid = vlan ? vlan-\u003evid : 0;\n  72:\t\n  73:\t\tif (IS_ENABLED(CONFIG_INET) \u0026\u0026\n  74:\t\t    (eth_hdr(skb)-\u003eh_proto == htons(ETH_P_ARP) ||\n  75:\t\t     eth_hdr(skb)-\u003eh_proto == htons(ETH_P_RARP)) \u0026\u0026\n  76:\t\t    br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED)) {\n  77:\t\t\tbr_do_proxy_suppress_arp(skb, br, vid, NULL);\n  78:\t\t} else if (ipv6_mod_enabled() \u0026\u0026\n  79:\t\t\t   skb-\u003eprotocol == htons(ETH_P_IPV6) \u0026\u0026\n  80:\t\t\t   br_opt_get(br, BROPT_NEIGH_SUPPRESS_ENABLED) \u0026\u0026\n  81:\t\t\t   pskb_may_pull(skb, sizeof(struct ipv6hdr) +\n  82:\t\t\t\t\t sizeof(struct nd_msg)) \u0026\u0026\n  83:\t\t\t   ipv6_hdr(skb)-\u003enexthdr == IPPROTO_ICMPV6) {\n  84:\t\t\t\tstruct nd_msg *msg;\n  85:\t\n  86:\t\t\t\tmsg = br_is_nd_neigh_msg(skb);\n  87:\t\t\t\tif (msg)\n  88:\t\t\t\t\tbr_do_suppress_nd(skb, br, vid, NULL, msg);\n  89:\t\t}\n"
}

39/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 25492
							output: 38
							thoughts: 387
						

Thoughts:
**Analyzing VLAN Filtering in Bridge Configuration**

Okay, so I'm looking at this code and I see `vid` initialized to 0. But then `br_allowed_ingress` sets `*vlan` upon success. I need to be sure I understand the logic flow here. My immediate question is, what does `br_allowed_ingress` *actually* do if VLAN filtering is disabled? I'm going to jump to `net/bridge/br_vlan.c` to check `br_allowed_ingress`. Ah, here it is:

```c
bool br_allowed_ingress(const struct net_bridge *br,
			struct net_bridge_vlan_group *vg, struct sk_buff *skb,
			u8 *state, struct net_bridge_vlan **vlan)
{
	/* If VLAN filtering is disabled on the bridge, all packets are
	 * permitted.
	 */
	if (!br_opt_get(br, BROPT_VLAN_ENABLED)) {
		*vlan = NULL;
		return true;
	}

	return __allowed_ingress(br, vg, skb, state, vlan);
}
```

Right, it checks `BROPT_VLAN_ENABLED`. If it's disabled, then `*vlan` is set to `NULL` and the function returns true, meaning it's allowed. That makes sense.

But wait a minute... what if `CONFIG_BRIDGE_VLAN_FILTERING` is NOT enabled? I need to double check that too, so I'll check `br_private.h`. Let's see what happens if the filtering is *completely* disabled (line 1846 and onwards):

```c
static inline bool br_allowed_ingress(const struct net_bridge *br,
				      struct net_bridge_vlan_group *vg,
				      struct sk_buff *skb,
				      u8 *state,
				      struct net_bridge_vlan **vlan)

{
	*vlan = NULL;
	return true;
}
```

Perfect, it's identical! No matter how VLAN is configured, if the option is disabled, `*vlan` is `NULL` and the packet is allowed. Excellent, so I understand the logic.



40/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_private.h",
  "FirstLine": 1840,
  "LineCount": 40
}

Results:
{
  "Contents": "1840:\t\n1841:\tstatic inline u16 br_vlan_flags(const struct net_bridge_vlan *v, u16 pvid)\n1842:\t{\n1843:\t\treturn v-\u003evid == pvid ? v-\u003eflags | BRIDGE_VLAN_INFO_PVID : v-\u003eflags;\n1844:\t}\n1845:\t#else\n1846:\tstatic inline bool br_allowed_ingress(const struct net_bridge *br,\n1847:\t\t\t\t\t      struct net_bridge_vlan_group *vg,\n1848:\t\t\t\t\t      struct sk_buff *skb,\n1849:\t\t\t\t\t      u8 *state,\n1850:\t\t\t\t\t      struct net_bridge_vlan **vlan)\n1851:\t\n1852:\t{\n1853:\t\t*vlan = NULL;\n1854:\t\treturn true;\n1855:\t}\n1856:\t\n1857:\tstatic inline bool br_allowed_egress(struct net_bridge_vlan_group *vg,\n1858:\t\t\t\t\t     const struct sk_buff *skb)\n1859:\t{\n1860:\t\treturn true;\n1861:\t}\n1862:\t\n1863:\tstatic inline bool br_should_learn(struct net_bridge_port *p,\n1864:\t\t\t\t\t   struct sk_buff *skb,\n1865:\t\t\t\t\t   struct net_bridge_vlan **vlan)\n1866:\t{\n1867:\t\t*vlan = NULL;\n1868:\t\treturn true;\n1869:\t}\n1870:\t\n1871:\tstatic inline struct sk_buff *br_handle_vlan(struct net_bridge *br,\n1872:\t\t\t\t\t\t     const struct net_bridge_port *port,\n1873:\t\t\t\t\t\t     struct net_bridge_vlan_group *vg,\n1874:\t\t\t\t\t\t     struct net_bridge_vlan *vlan,\n1875:\t\t\t\t\t\t     struct sk_buff *skb)\n1876:\t{\n1877:\t\treturn skb;\n1878:\t}\n1879:\t\n"
}

41/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 27007
							output: 38
							thoughts: 38
						

Thoughts:
Here's my analysis of the provided thought process, tailored for an expert audience:

**Diving into the `__allowed_ingress()` Function**

Okay, so we're looking at a function, `__allowed_ingress()`, likely related to VLAN filtering within a Linux bridge. My immediate instinct is to pinpoint its core functionality. Where is this implemented? Based on context, it looks like this is a networking function. Let's start with the most obvious place: `net/bridge/br_vlan.c`. Specifically, I need to see what's happening from lines 660 to 690. That range is likely where the real filtering logic resides. I suspect this will be the heart of understanding how ingress VLAN tagging is handled, how frames are processed and whether they are allowed based on the bridge's configuration. I'm anticipating that it's going to check the VLAN ID against some allowed list or range, and potentially perform other ingress-related checks. Time to dig in and see the details.



42/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_vlan.c",
  "FirstLine": 645,
  "LineCount": 45
}

Results:
{
  "Contents": " 645:\t\t\t * ingress frame is considered to belong to this vlan.\n 646:\t\t\t */\n 647:\t\t\tif (likely(!tagged))\n 648:\t\t\t\t/* Untagged Frame. */\n 649:\t\t\t\t__vlan_hwaccel_put_tag(skb, br-\u003evlan_proto, v-\u003evid);\n 650:\t\t\telse\n 651:\t\t\t\t/* Priority-tagged Frame.\n 652:\t\t\t\t * At this point, we know that skb-\u003evlan_tci VID\n 653:\t\t\t\t * field was 0.\n 654:\t\t\t\t * We update only VID field and preserve PCP field.\n 655:\t\t\t\t */\n 656:\t\t\t\tskb-\u003evlan_tci |= v-\u003evid;\n 657:\t\t} else {\n 658:\t\t\tv = br_vlan_find(vg, vid);\n 659:\t\t}\n 660:\t\n 661:\t\tif (!v || !br_vlan_should_use(v))\n 662:\t\t\tgoto drop;\n 663:\t\n 664:\t\tif (*state == BR_STATE_FORWARDING) {\n 665:\t\t\t*state = br_vlan_get_state(v);\n 666:\t\t\tif (!br_vlan_state_allowed(*state, true))\n 667:\t\t\t\tgoto drop;\n 668:\t\t}\n 669:\t\n 670:\t\tif (br_opt_get(br, BROPT_VLAN_STATS_ENABLED)) {\n 671:\t\t\tstats = this_cpu_ptr(v-\u003estats);\n 672:\t\t\tu64_stats_update_begin(\u0026stats-\u003esyncp);\n 673:\t\t\tu64_stats_add(\u0026stats-\u003erx_bytes, skb-\u003elen);\n 674:\t\t\tu64_stats_inc(\u0026stats-\u003erx_packets);\n 675:\t\t\tu64_stats_update_end(\u0026stats-\u003esyncp);\n 676:\t\t}\n 677:\t\n 678:\t\t*vlan = v;\n 679:\t\n 680:\t\treturn true;\n 681:\t\n 682:\tdrop:\n 683:\t\tkfree_skb(skb);\n 684:\t\treturn false;\n 685:\t}\n 686:\t\n 687:\tbool br_allowed_ingress(const struct net_bridge *br,\n 688:\t\t\t\tstruct net_bridge_vlan_group *vg, struct sk_buff *skb,\n 689:\t\t\t\tu8 *state, struct net_bridge_vlan **vlan)\n"
}

43/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 27987
							output: 37
							thoughts: 866
						

Thoughts:
**Analyzing VLAN Handling and Potential User-Space Exposure in the Linux Bridge Implementation**

Okay, let's break this down systematically. I'm focusing on how VLAN information is handled within the bridge code and whether any of this might be exposed to user space in a potentially unsafe way.

First, I'm examining how `*vlan` is handled in `__allowed_ingress()`. The key takeaway is that `*vlan` *is always initialized* by this function before it returns true, whether the VLAN is enabled or not.  If it returns true, `*vlan` will be assigned a value. If it's false, the `skb` is freed.  Crucially, it is also initialized to NULL when the VLAN is not enabled. This is important to remember.

Next, I checked `br_handle_frame_finish()` in `br_input.c`.  Again, `vlan` is initialized by `br_allowed_ingress`. And `vid` is set to `vlan ? vlan->vid : 0`, which is as expected, given the initialization in the previous function.

Then, I'm diving into `__br_handle_local_finish(struct sk_buff *skb)`. Here, the focus is on `br_should_learn()`. The crucial point here is that `*vlan` is *always* initialized to `NULL` at the beginning of the function. It's then updated if the learning conditions are met. So, the initialization is consistent here as well. This reduces my concern about uninitialized memory being used.

Now, I'm turning my attention to `struct net_bridge_dst`.  Its definition is very simple: it's just an `unsigned long __private value`.  The real question is, is this structure, or any part of it, ever exposed to user space? This is where potential vulnerabilities could exist if an internal structure is inadvertently leaked.

To investigate, I need to look at how FDB (Forwarding Database) entries are dumped or notified to user space.  I've found `fdb_fill_info` in `net/bridge/br_fdb.c`. This is where the core information is assembled for sending to user space, probably via netlink. Let's dig deeper into the code of `fdb_fill_info` to see if `struct net_bridge_dst` is involved at all, or if any part of the `net_bridge_vlan` data is copied. The variables passed to `fdb_fill_info` are what I need to watch.



44/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_fdb.c",
  "FirstLine": 90,
  "LineCount": 60
}

Results:
{
  "Contents": "  90:\t\t\t\t const struct net_bridge_fdb_entry *fdb,\n  91:\t\t\t\t u32 portid, u32 seq, int type, unsigned int flags)\n  92:\t{\n  93:\t\tconst struct net_bridge_port *dst = br_fdb_dst_port(fdb);\n  94:\t\tunsigned long now = jiffies;\n  95:\t\tstruct nda_cacheinfo ci;\n  96:\t\tstruct nlmsghdr *nlh;\n  97:\t\tstruct ndmsg *ndm;\n  98:\t\tu32 ext_flags = 0;\n  99:\t\n 100:\t\tnlh = nlmsg_put(skb, portid, seq, type, sizeof(*ndm), flags);\n 101:\t\tif (nlh == NULL)\n 102:\t\t\treturn -EMSGSIZE;\n 103:\t\n 104:\t\tndm = nlmsg_data(nlh);\n 105:\t\tndm-\u003endm_family\t = AF_BRIDGE;\n 106:\t\tndm-\u003endm_pad1    = 0;\n 107:\t\tndm-\u003endm_pad2    = 0;\n 108:\t\tndm-\u003endm_flags\t = 0;\n 109:\t\tndm-\u003endm_type\t = 0;\n 110:\t\tndm-\u003endm_ifindex = dst ? dst-\u003edev-\u003eifindex : br-\u003edev-\u003eifindex;\n 111:\t\tndm-\u003endm_state   = fdb_to_nud(br, fdb);\n 112:\t\n 113:\t\tif (test_bit(BR_FDB_OFFLOADED, \u0026fdb-\u003eflags))\n 114:\t\t\tndm-\u003endm_flags |= NTF_OFFLOADED;\n 115:\t\tif (test_bit(BR_FDB_ADDED_BY_EXT_LEARN, \u0026fdb-\u003eflags))\n 116:\t\t\tndm-\u003endm_flags |= NTF_EXT_LEARNED;\n 117:\t\tif (test_bit(BR_FDB_STICKY, \u0026fdb-\u003eflags))\n 118:\t\t\tndm-\u003endm_flags |= NTF_STICKY;\n 119:\t\tif (test_bit(BR_FDB_LOCKED, \u0026fdb-\u003eflags))\n 120:\t\t\text_flags |= NTF_EXT_LOCKED;\n 121:\t\n 122:\t\tif (nla_put(skb, NDA_LLADDR, ETH_ALEN, \u0026fdb-\u003ekey.addr))\n 123:\t\t\tgoto nla_put_failure;\n 124:\t\tif (nla_put_u32(skb, NDA_MASTER, br-\u003edev-\u003eifindex))\n 125:\t\t\tgoto nla_put_failure;\n 126:\t\tif (nla_put_u32(skb, NDA_FLAGS_EXT, ext_flags))\n 127:\t\t\tgoto nla_put_failure;\n 128:\t\n 129:\t\tci.ndm_used\t = jiffies_to_clock_t(now - READ_ONCE(fdb-\u003eused));\n 130:\t\tci.ndm_confirmed = 0;\n 131:\t\tci.ndm_updated\t = jiffies_to_clock_t(now - READ_ONCE(fdb-\u003eupdated));\n 132:\t\tci.ndm_refcnt\t = 0;\n 133:\t\tif (nla_put(skb, NDA_CACHEINFO, sizeof(ci), \u0026ci))\n 134:\t\t\tgoto nla_put_failure;\n 135:\t\n 136:\t\tif (fdb-\u003ekey.vlan_id \u0026\u0026 nla_put(skb, NDA_VLAN, sizeof(u16),\n 137:\t\t\t\t\t\t\u0026fdb-\u003ekey.vlan_id))\n 138:\t\t\tgoto nla_put_failure;\n 139:\t\n 140:\t\tif (test_bit(BR_FDB_NOTIFY, \u0026fdb-\u003eflags)) {\n 141:\t\t\tstruct nlattr *nest = nla_nest_start(skb, NDA_FDB_EXT_ATTRS);\n 142:\t\t\tu8 notify_bits = FDB_NOTIFY_BIT;\n 143:\t\n 144:\t\t\tif (!nest)\n 145:\t\t\t\tgoto nla_put_failure;\n 146:\t\t\tif (test_bit(BR_FDB_NOTIFY_INACTIVE, \u0026fdb-\u003eflags))\n 147:\t\t\t\tnotify_bits |= FDB_NOTIFY_INACTIVE_BIT;\n 148:\t\n 149:\t\t\tif (nla_put_u8(skb, NFEA_ACTIVITY_NOTIFY, notify_bits)) {\n"
}

45/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 30667
							output: 38
							thoughts: 257
						

Thoughts:
**Analyzing the FDB and Netlink Interface**

Okay, so I'm looking at how the Forwarding Database (FDB) information is handled, specifically within the bridging subsystem. The `fdb_fill_info` function is the key here. It seems like the critical step is pulling out the destination port using `br_fdb_dst_port(fdb)` into the `dst` variable. I see that the `ndm->ndm_ifindex` is then set based on this `dst`: if a destination port exists, we use its interface index; otherwise, we default to the bridge's own interface index. I know that `ndm` is a pointer to the Netlink Destination Message structure.

I'm paying close attention to this `struct net_bridge_dst`. It's essentially just a tagged pointer – a wrapper around an `unsigned long`, and it's never directly copied to user space via Netlink. That's good from a security perspective. It minimizes unnecessary exposure of internal structures.

Now, let's dive into the `br_fdb_fillbuf()` function. It's the one that actually populates the buffer with FDB entries, and I see it's doing the same thing. The code iterates through the FDB entries, and for each one, it calls `br_fdb_dst_port(f)` to get the destination port, as expected. It also explicitly ignores "pseudo entries" associated with the local MAC address, which makes sense. I see that if there's no destination, the loop continues.



46/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_fdb.c",
  "FirstLine": 940,
  "LineCount": 40
}

Results:
{
  "Contents": " 940:\t\thlist_for_each_entry_rcu(f, \u0026br-\u003efdb_list, fdb_node) {\n 941:\t\t\tif (num \u003e= maxnum)\n 942:\t\t\t\tbreak;\n 943:\t\n 944:\t\t\tif (has_expired(br, f))\n 945:\t\t\t\tcontinue;\n 946:\t\n 947:\t\t\t/* ignore pseudo entry for local MAC address */\n 948:\t\t\tdst = br_fdb_dst_port(f);\n 949:\t\t\tif (!dst)\n 950:\t\t\t\tcontinue;\n 951:\t\n 952:\t\t\tif (skip) {\n 953:\t\t\t\t--skip;\n 954:\t\t\t\tcontinue;\n 955:\t\t\t}\n 956:\t\n 957:\t\t\t/* convert from internal format to API */\n 958:\t\t\tmemcpy(fe-\u003emac_addr, f-\u003ekey.addr.addr, ETH_ALEN);\n 959:\t\n 960:\t\t\t/* due to ABI compat need to split into hi/lo */\n 961:\t\t\tfe-\u003eport_no = dst-\u003eport_no;\n 962:\t\t\tfe-\u003eport_hi = dst-\u003eport_no \u003e\u003e 8;\n 963:\t\n 964:\t\t\tfe-\u003eis_local = test_bit(BR_FDB_LOCAL, \u0026f-\u003eflags);\n 965:\t\t\tif (!test_bit(BR_FDB_STATIC, \u0026f-\u003eflags)) {\n 966:\t\t\t\tdelta = jiffies - READ_ONCE(f-\u003eupdated);\n 967:\t\t\t\tfe-\u003eageing_timer_value =\n 968:\t\t\t\t\tjiffies_delta_to_clock_t(delta);\n 969:\t\t\t}\n 970:\t\t\t++fe;\n 971:\t\t\t++num;\n 972:\t\t}\n 973:\t\trcu_read_unlock();\n 974:\t\n 975:\t\treturn num;\n 976:\t}\n 977:\t\n 978:\t/* Add entry for local address of interface */\n 979:\tint br_fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,\n"
}

47/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 31881
							output: 38
							thoughts: 438
						

Thoughts:
**Analyzing the FDB Changes**

Okay, so looking at the changes in `br_fdb_fillbuf`, it looks like the modification boils down to swapping `dst = READ_ONCE(f->dst);` with `dst = br_fdb_dst_port(f);`. The core buffer formatting or initialization remains untouched. I need to make sure I am not missing something, so let's start with a tracepoint analysis.

I've examined the `fdb_delete` tracepoint: the proto and args now include a `const struct net_bridge_port *dst`. Looking at the arguments passed, the change now passes `br_fdb_dst_port(f)` as the `dst` parameter. The structure also includes:

```c
TP_STRUCT__entry(
	__string(br_dev, br->dev->name)
	__string(dev, dst ? dst->dev->name : "null")
	__array(unsigned char, addr, ETH_ALEN)
	__field(u16, vid)
)
```
Crucially, the tracepoint passes `dst ? dst->dev->name : "null"`. `dev->name` is a null-terminated string, and "null" is a constant string. There's no immediately obvious vector for uninitialized data here, especially because we are handling the case where `dst` could be `NULL` in the ternary.

Now, I'll switch gears and analyze `fdb_create()`, specifically how the `fdb` struct is allocated and initialized in this function. This is a critical point to ensure we are creating the correct metadata.
```c
static struct net_bridge_fdb_entry *fdb_create(struct net_bridge *br,
					       struct net_bridge_dst dst,
					       const unsigned char *addr,
					       __u16 vid,
					       unsigned long flags)
```
The allocation and potential initialization in here is crucial to ensure we're creating the data correctly.



48/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_fdb.c",
  "FirstLine": 395,
  "LineCount": 35
}

Results:
{
  "Contents": " 395:\t\tu32 max_learned = READ_ONCE(br-\u003efdb_max_learned);\n 396:\t\tstruct net_bridge_fdb_entry *fdb;\n 397:\t\tint err;\n 398:\t\n 399:\t\tif (likely(learned)) {\n 400:\t\t\tint n_learned = atomic_read(\u0026br-\u003efdb_n_learned);\n 401:\t\n 402:\t\t\tif (unlikely(max_learned \u0026\u0026 n_learned \u003e= max_learned))\n 403:\t\t\t\treturn NULL;\n 404:\t\t\t__set_bit(BR_FDB_DYNAMIC_LEARNED, \u0026flags);\n 405:\t\t}\n 406:\t\n 407:\t\tfdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC);\n 408:\t\tif (!fdb)\n 409:\t\t\treturn NULL;\n 410:\t\n 411:\t\tmemcpy(fdb-\u003ekey.addr.addr, addr, ETH_ALEN);\n 412:\t\tbr_fdb_dst_write(fdb, dst);\n 413:\t\tfdb-\u003ekey.vlan_id = vid;\n 414:\t\tfdb-\u003eflags = flags;\n 415:\t\tfdb-\u003eupdated = fdb-\u003eused = jiffies;\n 416:\t\terr = rhashtable_lookup_insert_fast(\u0026br-\u003efdb_hash_tbl, \u0026fdb-\u003erhnode,\n 417:\t\t\t\t\t\t    br_fdb_rht_params);\n 418:\t\tif (err) {\n 419:\t\t\tkmem_cache_free(br_fdb_cache, fdb);\n 420:\t\t\treturn NULL;\n 421:\t\t}\n 422:\t\n 423:\t\tif (likely(learned))\n 424:\t\t\tatomic_inc(\u0026br-\u003efdb_n_learned);\n 425:\t\n 426:\t\thlist_add_head_rcu(\u0026fdb-\u003efdb_node, \u0026br-\u003efdb_list);\n 427:\t\n 428:\t\treturn fdb;\n 429:\t}\n"
}

49/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 33368
							output: 37
							thoughts: 1754
						

Thoughts:
**Analyzing the Destination Handling in the Bridging Code**

Okay, so I'm looking at this new `fdb = kmem_cache_alloc(br_fdb_cache, GFP_ATOMIC);` line. Previously, we were using `WRITE_ONCE(fdb->dst, source);` but now it's `br_fdb_dst_write(fdb, dst);`. The immediate question is, what is `br_fdb_dst_write` doing? I see it's calling `br_dst_write`, which is:

```c
static inline void br_dst_write(struct net_bridge_dst *dst,
				struct net_bridge_dst src)
{
	WRITE_ONCE(ACCESS_PRIVATE(dst, value),
		   ACCESS_PRIVATE(&src, value));
}
```

So, it appears to be a simple, atomic write to a private field within the `net_bridge_dst` structure. The key is to understand if `dst` is always fully initialized before being passed into `fdb_create`.

Let's check the call sites for `fdb_create`: I find four. The first is in `br_fdb_update` where it's called with `dst` being determined by whether `vlan` is set, and it calls either `br_vlan_to_dst` or `br_port_to_dst`. The second is `fdb_add_local`, which also calls `br_port_to_dst`. The third, `fdb_add_entry`, receives a `struct net_bridge_dst dst` as an argument. I note the fourth use is in `br_fdb_external_learn_add`, where `dst` is initialized by `br_fdb_resolve_dst`. So I need to dig into `br_fdb_resolve_dst`:

```c
static struct net_bridge_dst br_fdb_resolve_dst(const struct net_bridge_port *p,
						u16 vid)
{
	struct net_bridge_dst dst = br_port_to_dst(p);
	struct net_bridge_vlan *v;

	lockdep_assert(rcu_read_lock_held() || lockdep_rtnl_is_held());

	if (!p || !vid)
		return dst;

	rcu_read_lock();
	v = br_vlan_find(nbp_vlan_group_rcu(p), vid);
	if (v)
		dst = br_vlan_to_dst(v);
	rcu_read_unlock();

	return dst;
}
```

Okay, `br_fdb_resolve_dst` also uses `br_port_to_dst` or `br_vlan_to_dst`, which are inline functions.

Now, let's look closer at `br_port_to_dst` and `br_vlan_to_dst`:

```c
static inline struct net_bridge_dst
br_port_to_dst(const struct net_bridge_port *p)
{
	struct net_bridge_dst dst;

	ACCESS_PRIVATE(&dst, value) = (unsigned long)p;

	return dst;
}

static inline struct net_bridge_dst
br_vlan_to_dst(const struct net_bridge_vlan *v)
{
	struct net_bridge_dst dst;

	ACCESS_PRIVATE(&dst, value) = (unsigned long)v | BR_DST_VLAN_TAG;

	return dst;
}
```

It looks like the `net_bridge_dst` struct has only one private field, `value`, and these functions initialize it directly. So, these functions are definitely initializing the entire struct by assigning the pointer (or pointer + tag).

I then check `br_dst_read`:

```c
static inline struct net_bridge_dst
br_dst_read(const struct net_bridge_dst *src)
{
	struct net_bridge_dst dst;

	ACCESS_PRIVATE(&dst, value) =
		READ_ONCE(ACCESS_PRIVATE(src, value));

	return dst;
}
```

So, `br_dst_read` also fully initializes the dst struct.

Now, checking the `br_forward` function, which calls `br_dst_decode`:

```c
void br_forward(struct net_bridge_dst dst,
		struct sk_buff *skb, bool local_rcv, bool local_orig)


50/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_forward.c",
  "FirstLine": 115,
  "LineCount": 40
}

Results:
{
  "Contents": " 115:\t\t\tnet = dev_net(indev);\n 116:\t\t} else {\n 117:\t\t\tif (unlikely(netpoll_tx_running(to-\u003ebr-\u003edev))) {\n 118:\t\t\t\tskb_push(skb, ETH_HLEN);\n 119:\t\t\t\tif (!is_skb_forwardable(skb-\u003edev, skb))\n 120:\t\t\t\t\tkfree_skb(skb);\n 121:\t\t\t\telse\n 122:\t\t\t\t\tbr_netpoll_send_skb(to, skb);\n 123:\t\t\t\treturn;\n 124:\t\t\t}\n 125:\t\t\tbr_hook = NF_BR_LOCAL_OUT;\n 126:\t\t\tnet = dev_net(skb-\u003edev);\n 127:\t\t\tindev = NULL;\n 128:\t\t}\n 129:\t\n 130:\t\tNF_HOOK(NFPROTO_BRIDGE, br_hook,\n 131:\t\t\tnet, NULL, skb, indev, skb-\u003edev,\n 132:\t\t\tbr_forward_finish);\n 133:\t}\n 134:\t\n 135:\tstatic int deliver_clone(const struct br_fwd_dst *fwd,\n 136:\t\t\t\t struct sk_buff *skb, bool local_orig)\n 137:\t{\n 138:\t\tstruct net_device *dev = BR_INPUT_SKB_CB(skb)-\u003ebrdev;\n 139:\t\n 140:\t\tskb = skb_clone(skb, GFP_ATOMIC);\n 141:\t\tif (!skb) {\n 142:\t\t\tDEV_STATS_INC(dev, tx_dropped);\n 143:\t\t\treturn -ENOMEM;\n 144:\t\t}\n 145:\t\n 146:\t\t__br_forward(fwd, skb, local_orig);\n 147:\t\treturn 0;\n 148:\t}\n 149:\t\n 150:\t/**\n 151:\t * br_forward - forward a packet to a specific port\n 152:\t * @dst: bridge destination\n 153:\t * @skb: packet being forwarded\n 154:\t * @local_rcv: packet will be received locally after forwarding\n"
}

51/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 36787
							output: 36
							thoughts: 31
						

Thoughts:
Here's a summary of my thought process, as requested:

**Diving into `br_forward.c` to Analyze Packet Delivery**

Okay, time to get my hands dirty and dissect the packet forwarding logic within the Linux bridge. I need to understand the criteria that determine if a frame should be delivered, so I'm heading straight to `net/bridge/br_forward.c`. Specifically, I'm focusing on lines 80 through 114, where the `should_deliver` function should be. This is where the core decision making happens, and I want to see what conditions are being evaluated. I'm expecting to find checks related to the destination MAC address (whether it's known, flooded, or multicast), spanning tree states of the relevant ports, learning capabilities, and potential filtering rules. I'll be looking for any potential optimization opportunities, security implications, or any possible gotchas in the implementation that could lead to unexpected behavior. Let's see what the code reveals.



52/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_forward.c",
  "FirstLine": 80,
  "LineCount": 40
}

Results:
{
  "Contents": "  80:\t\treturn NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING,\n  81:\t\t\t       net, sk, skb, NULL, skb-\u003edev,\n  82:\t\t\t       br_dev_queue_push_xmit);\n  83:\t\n  84:\t}\n  85:\tEXPORT_SYMBOL_GPL(br_forward_finish);\n  86:\t\n  87:\tstatic void __br_forward(const struct br_fwd_dst *fwd,\n  88:\t\t\t\t struct sk_buff *skb, bool local_orig)\n  89:\t{\n  90:\t\tconst struct net_bridge_port *to = fwd-\u003eport;\n  91:\t\tstruct net_bridge_vlan_group *vg;\n  92:\t\tstruct net_device *indev;\n  93:\t\tstruct net *net;\n  94:\t\tint br_hook;\n  95:\t\n  96:\t\t/* Mark the skb for forwarding offload early so that br_handle_vlan()\n  97:\t\t * can know whether to pop the VLAN header on egress or keep it.\n  98:\t\t */\n  99:\t\tnbp_switchdev_frame_mark_tx_fwd_offload(to, skb);\n 100:\t\n 101:\t\tvg = fwd-\u003evlan ? NULL : nbp_vlan_group_rcu(to);\n 102:\t\tskb = br_handle_vlan(to-\u003ebr, to, vg, fwd-\u003evlan, skb);\n 103:\t\tif (!skb)\n 104:\t\t\treturn;\n 105:\t\n 106:\t\tindev = skb-\u003edev;\n 107:\t\tskb-\u003edev = to-\u003edev;\n 108:\t\tif (!local_orig) {\n 109:\t\t\tif (skb_warn_if_lro(skb)) {\n 110:\t\t\t\tkfree_skb(skb);\n 111:\t\t\t\treturn;\n 112:\t\t\t}\n 113:\t\t\tbr_hook = NF_BR_FORWARD;\n 114:\t\t\tskb_forward_csum(skb);\n 115:\t\t\tnet = dev_net(indev);\n 116:\t\t} else {\n 117:\t\t\tif (unlikely(netpoll_tx_running(to-\u003ebr-\u003edev))) {\n 118:\t\t\t\tskb_push(skb, ETH_HLEN);\n 119:\t\t\t\tif (!is_skb_forwardable(skb-\u003edev, skb))\n"
}

53/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 37727
							output: 36
							thoughts: 1453
						

Thoughts:
**Analyzing Potential Concurrency Issues in Bridge Forwarding**

Okay, so I'm digging into how forwarding decisions are made in the bridging code, and I see a potential area for bugs related to concurrency and memory management. The core issue seems to revolve around the handling of VLAN information and the lifetime of associated data structures, specifically `struct net_bridge_vlan`.

My initial thought process is to trace how the `fwd` structure, holding the `port` and `vlan` information, is used, and how it interacts with the VLAN group and FDB (Forwarding Database) cleanup. The `should_deliver` function uses `fwd->port` to check delivery rules, and in `__br_forward()`, the code checks for `fwd->vlan` to handle VLAN-tagged traffic. The key here is the use of `nbp_vlan_group_rcu` and `br_handle_vlan`.

Now, I'm getting suspicious, especially considering how `br_fdb_cleanup_by_dst`, `nbp_vlan_group_unpublish` and `nbp_vlan_delete` are involved. The `br_fdb_cleanup_by_dst` function is responsible for removing FDB entries associated with a particular destination. `nbp_vlan_group_unpublish` clears the VLAN group for a bridge port and it gets called from `del_nbp` function which is called when the bridge port is deleted, and `nbp_vlan_delete` deletes a specific VLAN from a bridge port.

My concern is that there could be a Use-After-Free scenario, specifically if a `struct net_bridge_vlan` is freed while a pointer to it is still held in the `br_fdb_entry` structure's `dst` field. This is related to the RCU (Read-Copy-Update) synchronization that's used. Let's see how `v` is freed. In `nbp_vlan_delete`, the value of `v` is `(struct net_bridge_vlan *)(value & ~BR_DST_VLAN_TAG)`. If `v` is freed by `__vlan_del` and before `br_fdb_cleanup_by_dst` is completed (which is called after the RCU synchronization point), accessing `v->port` during the `br_dst_decode` can be a problem.

The `br_dst_decode` function extracts the port and VLAN information from a `net_bridge_dst` structure, which looks like a tagged pointer. Now, if the VLAN has been unlinked before the FDB entry is cleaned up, a dereference would be a Use-After-Free, and this is detected by KASAN!

I need to confirm that there are no uninitialized memory reads or leaks. `struct net_bridge_dst` is initialized and safe to use. Then I check `struct br_fwd_dst`, it looks safe to use as `br_dst_decode` initializes it correctly.

After looking at `br_allowed_ingress` and `vid` used within `br_dev_xmit`, `vid` is initialized to 0 and the `state` is declared as a local variable. So, it should be fine. I need to be careful when `state` is read from `br_dev_xmit()`



54/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_device.c",
  "FirstLine": 20,
  "LineCount": 35
}

Results:
{
  "Contents": "  20:\t\n  21:\t#include \"br_private.h\"\n  22:\t\n  23:\t#define COMMON_FEATURES (NETIF_F_SG | NETIF_F_FRAGLIST | NETIF_F_HIGHDMA | \\\n  24:\t\t\t\t NETIF_F_GSO_MASK | NETIF_F_HW_CSUM)\n  25:\t\n  26:\tconst struct nf_br_ops __rcu *nf_br_ops __read_mostly;\n  27:\tEXPORT_SYMBOL_GPL(nf_br_ops);\n  28:\t\n  29:\t/* net device transmit always called with BH disabled */\n  30:\tnetdev_tx_t br_dev_xmit(struct sk_buff *skb, struct net_device *dev)\n  31:\t{\n  32:\t\tenum skb_drop_reason reason = pskb_may_pull_reason(skb, ETH_HLEN);\n  33:\t\tstruct net_bridge_mcast_port *pmctx_null = NULL;\n  34:\t\tstruct net_bridge *br = netdev_priv(dev);\n  35:\t\tstruct net_bridge_mcast *brmctx = \u0026br-\u003emulticast_ctx;\n  36:\t\tstruct net_bridge_fdb_entry *dst;\n  37:\t\tstruct net_bridge_mdb_entry *mdst;\n  38:\t\tconst struct nf_br_ops *nf_ops;\n  39:\t\tu8 state = BR_STATE_FORWARDING;\n  40:\t\tstruct net_bridge_vlan *vlan;\n  41:\t\tconst unsigned char *dest;\n  42:\t\tu16 vid = 0;\n  43:\t\n  44:\t\tif (unlikely(reason != SKB_NOT_DROPPED_YET)) {\n  45:\t\t\tkfree_skb_reason(skb, reason);\n  46:\t\t\treturn NETDEV_TX_OK;\n  47:\t\t}\n  48:\t\n  49:\t\tmemset(skb-\u003ecb, 0, sizeof(struct br_input_skb_cb));\n  50:\t\tbr_tc_skb_miss_set(skb, false);\n  51:\t\n  52:\t\trcu_read_lock();\n  53:\t\tnf_ops = rcu_dereference(nf_br_ops);\n  54:\t\tif (nf_ops \u0026\u0026 nf_ops-\u003ebr_dev_xmit_hook(skb)) {\n"
}

55/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 40578
							output: 36
							thoughts: 90
						

Thoughts:
Here's my analysis of the provided code snippet:

**State Tracking in the Bridging Module**

Okay, so we're starting with a variable `u8 state = BR_STATE_FORWARDING;` – this is a clear initialization. Excellent, `BR_STATE_FORWARDING` is our starting point for the bridge's operational state. Now, I need to see how this state variable is handled in the `br_input.c` module, specifically. Looking at `br_input.c`, I see a declared variable `u8 state;` – that's expected.

Now, I need to understand how the state changes. I see in `br_handle_frame_finish` that `state = p->state;`. This means the state is being copied from a packet structure (`p`). Okay, that makes sense. So, the state is being updated when a frame is finished being handled. To get the full picture, I should thoroughly review lines 90-115 of `br_input.c` to see the logic around `state`. I expect to find the conditional transitions and any potential side effects. That's where the real meat of the state machine likely resides.



56/3 2026/10/01 04:47 tool read-file
0m Args:
{
  "File": "net/bridge/br_input.c",
  "FirstLine": 90,
  "LineCount": 30
}

Results:
{
  "Contents": "  90:\t\tu16 vid;\n  91:\t\n  92:\t\tif (!p)\n  93:\t\t\tgoto drop;\n  94:\t\n  95:\t\tbr = p-\u003ebr;\n  96:\t\n  97:\t\tif (br_mst_is_enabled(p)) {\n  98:\t\t\tstate = BR_STATE_FORWARDING;\n  99:\t\t} else {\n 100:\t\t\tif (p-\u003estate == BR_STATE_DISABLED) {\n 101:\t\t\t\treason = SKB_DROP_REASON_BRIDGE_INGRESS_STP_STATE;\n 102:\t\t\t\tgoto drop;\n 103:\t\t\t}\n 104:\t\n 105:\t\t\tstate = p-\u003estate;\n 106:\t\t}\n 107:\t\n 108:\t\tbrmctx = \u0026p-\u003ebr-\u003emulticast_ctx;\n 109:\t\tpmctx = \u0026p-\u003emulticast_ctx;\n 110:\t\tif (!br_allowed_ingress(p-\u003ebr, nbp_vlan_group_rcu(p), skb, \u0026state,\n 111:\t\t\t\t\t\u0026vlan))\n 112:\t\t\tgoto out;\n 113:\t\tvid = vlan ? vlan-\u003evid : 0;\n 114:\t\n 115:\t\tif (test_bit(BR_PORT_LOCKED_BIT, \u0026p-\u003eflags)) {\n 116:\t\t\tstruct net_bridge_fdb_entry *fdb_src =\n 117:\t\t\t\tbr_fdb_find_rcu(br, eth_hdr(skb)-\u003eh_source, vid);\n 118:\t\n 119:\t\t\tif (!fdb_src) {\n"
}

57/3 2026/10/01 04:47 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 41404
							output: 21
							thoughts: 388
						

Thoughts:
**Analyzing the `br_fdb_update` Callers**

Okay, so I see that `state` was already initialized, either on line 98 or 105, *before* the call to `br_allowed_ingress`. And then, right after that, `vid` gets set to `vlan->vid` if `vlan` isn't null, otherwise it's set to 0. Now I need to figure out how `br_fdb_update()` is being used in relation to that. Let's see where that function is actually *called*. I'll check the codebase via grep or perhaps a patch diff.

Alright, here's what I've got so far. In `br_input.c`:
*   Line 123 has a call to `br_fdb_update()` with `br`, `p`, `vlan`, the source MAC address, and `BIT(BR_FDB_LOCKED)`.
*   Line 136, same parameters.
*   Line 146, again calling `br_fdb_update()` but this time with a 0 bitmask.
*   Line 257 in `__br_handle_local_finish`, also calling `br_fdb_update()` with similar parameters and a 0 bitmask.

And then, in `br_fdb.c`:
*   Line 1321 within `__br_fdb_add`, calling `br_fdb_update()` with `br`, `p`, `vlan`, the address, and `BIT(BR_FDB_ADDED_BY_USER)`.

Are there *any* other calls to `br_fdb_update` lurking in the code? I'll run another grep search just to be sure.



58/3 2026/10/01 04:48 tool grepper
0m Args:
{
  "Expression": "br_fdb_update\\("
}

Results:
{
  "Output": "net/bridge/br_fdb.c=997=static void __fdb_update(struct net_bridge *br,\n--\nnet/bridge/br_fdb.c-1055-\tif (unlikely(fdb_modified)) {\nnet/bridge/br_fdb.c:1056:\t\ttrace_br_fdb_update(br, source, addr, vid, flags);\nnet/bridge/br_fdb.c-1057-\t\tfdb_notify(br, fdb, RTM_NEWNEIGH, true);\n--\nnet/bridge/br_fdb.c-1060-\nnet/bridge/br_fdb.c:1061:void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,\nnet/bridge/br_fdb.c-1062-\t\t   struct net_bridge_vlan *vlan, const unsigned char *addr,\n--\nnet/bridge/br_fdb.c-1080-\t\tif (fdb) {\nnet/bridge/br_fdb.c:1081:\t\t\ttrace_br_fdb_update(br, source, addr, vid, flags);\nnet/bridge/br_fdb.c-1082-\t\t\tfdb_notify(br, fdb, RTM_NEWNEIGH, true);\n--\nnet/bridge/br_fdb.c=1300=static int __br_fdb_add(struct ndmsg *ndm, struct net_bridge *br,\n--\nnet/bridge/br_fdb.c-1320-\t\trcu_read_lock();\nnet/bridge/br_fdb.c:1321:\t\tbr_fdb_update(br, p, vlan, addr, BIT(BR_FDB_ADDED_BY_USER));\nnet/bridge/br_fdb.c-1322-\t\trcu_read_unlock();\n--\nnet/bridge/br_input.c=76=int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb)\n--\nnet/bridge/br_input.c-123-\t\t\tif (test_bit(BR_PORT_MAB_BIT, \u0026p-\u003eflags))\nnet/bridge/br_input.c:124:\t\t\t\tbr_fdb_update(br, p, vlan,\nnet/bridge/br_input.c-125-\t\t\t\t\t      eth_hdr(skb)-\u003eh_source,\n--\nnet/bridge/br_input.c-135-\t\t\t */\nnet/bridge/br_input.c:136:\t\t\tbr_fdb_update(br, p, vlan, eth_hdr(skb)-\u003eh_source,\nnet/bridge/br_input.c-137-\t\t\t\t      BIT(BR_FDB_LOCKED));\n--\nnet/bridge/br_input.c-145-\tif (test_bit(BR_LEARNING_BIT, \u0026p-\u003eflags))\nnet/bridge/br_input.c:146:\t\tbr_fdb_update(br, p, vlan, eth_hdr(skb)-\u003eh_source, 0);\nnet/bridge/br_input.c-147-\n--\nnet/bridge/br_input.c=247=static void __br_handle_local_finish(struct sk_buff *skb)\n--\nnet/bridge/br_input.c-256-\t    br_should_learn(p, skb, \u0026vlan))\nnet/bridge/br_input.c:257:\t\tbr_fdb_update(p-\u003ebr, p, vlan, eth_hdr(skb)-\u003eh_source, 0);\nnet/bridge/br_input.c-258-}\n--\nnet/bridge/br_private.h=1011=int br_fdb_add_local(struct net_bridge *br, struct net_bridge_port *source,\nnet/bridge/br_private.h-1012-\t\t     const unsigned char *addr, u16 vid);\nnet/bridge/br_private.h:1013:void br_fdb_update(struct net_bridge *br, struct net_bridge_port *source,\nnet/bridge/br_private.h-1014-\t\t   struct net_bridge_vlan *vlan, const unsigned char *addr,\n"
}

59/3 2026/10/01 04:48 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 43296
							output: 18
							thoughts: 100
						

Thoughts:
Okay, here's my understanding, assuming I'm an expert in this area:

**Checking FDB Consistency After Update**

Alright, the recent refactoring of `br_fdb_update` seems to have gone smoothly. Now, I need to methodically verify the downstream impact. My immediate concern is with the functions that interact with the FDB data structures after updates. Functions like `br_fdb_dst_read`, `br_fdb_dst_write`, and so on, are the next logical targets for inspection. I know those are key to how the forwarding database is accessed and potentially modified, so those need to be solid.

I've just come across a definition for `struct net_bridge_dst`, and that structure contains an element called `__private value`. The double underscores usually indicate some form of internal implementation detail, but I need to be absolutely sure. Is this a custom macro? An attribute used by the compiler to manage memory layout or visibility in a specific way? I need to know the semantic of that field, and how it is used. The most direct approach is a grep through the `include/` directory to track down exactly how `__private` is defined and used within this project. Knowing that will tell me how critical that is to the overall structure and how to test it.



60/3 2026/10/01 04:48 tool grepper
0m Args:
{
  "Expression": "#define __private"
}

Results:
{
  "Output": "lib/tests/list-private-test.c-15-#undef __private\nlib/tests/list-private-test.c:16:#define __private volatile\nlib/tests/list-private-test.c-17-\n--\ntools/testing/vma/vma_internal.h-37- */\ntools/testing/vma/vma_internal.h:38:#define __private\ntools/testing/vma/vma_internal.h-39-/* NUM_MM_FLAG_BITS defined by test code. */\n"
}

61/3 2026/10/01 04:48 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 43831
							output: 17
							thoughts: 13
						

Thoughts:
Here's my take on those thoughts:

**Pinpointing the Private Access Point**

Okay, so I need to understand how `ACCESS_PRIVATE` is being used in this codebase. My instinct is to trace its definition immediately. I can't just assume I remember where it's declared, or that it's consistent across all modules. A quick search for the declaration of `ACCESS_PRIVATE` is the first and most logical step. This is a crucial constant or macro, and understanding its scope and value is foundational to any deeper analysis. Let's get that done, and see what the code tells us.



62/3 2026/10/01 04:48 tool grepper
0m Args:
{
  "Expression": "ACCESS_PRIVATE"
}

Results:
{
  "Output": "\nFull output is too long, showing 200 out of 600 lines.\nUse more precise expression if possible.\n\ndrivers/iio/industrialio-buffer.c=1157=static int iio_enable_buffers(struct iio_dev *indio_dev,\n--\ndrivers/iio/industrialio-buffer.c-1164-\tindio_dev-\u003eactive_scan_mask = config-\u003escan_mask;\ndrivers/iio/industrialio-buffer.c:1165:\tACCESS_PRIVATE(indio_dev, scan_timestamp) = config-\u003escan_timestamp;\ndrivers/iio/industrialio-buffer.c-1166-\tindio_dev-\u003escan_bytes = config-\u003escan_bytes;\ndrivers/iio/industrialio-buffer.c:1167:\tACCESS_PRIVATE(indio_dev, scan_timestamp_offset) = config-\u003escan_timestamp_offset;\ndrivers/iio/industrialio-buffer.c-1168-\tiio_dev_opaque-\u003ecurrentmode = config-\u003emode;\n--\ndrivers/iio/industrialio-buffer.c=2290=int iio_buffers_alloc_sysfs_and_mask(struct iio_dev *indio_dev)\n--\ndrivers/iio/industrialio-buffer.c-2303-\t\t\tml = max(ml, channels[i].scan_index + 1);\ndrivers/iio/industrialio-buffer.c:2304:\t\tACCESS_PRIVATE(indio_dev, masklength) = ml;\ndrivers/iio/industrialio-buffer.c-2305-\t}\n--\ndrivers/iio/industrialio-core.c=1713=struct iio_dev *iio_device_alloc(struct device *parent, int sizeof_priv)\n--\ndrivers/iio/industrialio-core.c-1730-\tif (sizeof_priv)\ndrivers/iio/industrialio-core.c:1731:\t\tACCESS_PRIVATE(indio_dev, priv) = (char *)iio_dev_opaque +\ndrivers/iio/industrialio-core.c-1732-\t\t\tALIGN(sizeof(*iio_dev_opaque), IIO_DMA_MINALIGN);\n--\ndrivers/irqchip/irq-sifive-plic.c=84=struct plic_handler {\n--\ndrivers/irqchip/irq-sifive-plic.c-99-#define for_each_device_irq(iter, priv)\t\\\ndrivers/irqchip/irq-sifive-plic.c:100:\tfor (unsigned int iter = 1; iter \u003c ACCESS_PRIVATE(priv, total_irqs); iter++)\ndrivers/irqchip/irq-sifive-plic.c-101-\n--\ndrivers/irqchip/irq-sifive-plic.c=617=static int plic_probe(struct fwnode_handle *fwnode)\n--\ndrivers/irqchip/irq-sifive-plic.c-661-\tnr_irqs++;\ndrivers/irqchip/irq-sifive-plic.c:662:\tACCESS_PRIVATE(priv, total_irqs) = nr_irqs;\ndrivers/irqchip/irq-sifive-plic.c-663-\t/* Precalculate the number of register groups */\n--\ninclude/linux/compiler_types.h=55=static inline void __chk_io_ptr(const volatile void __iomem *ptr) { }\n--\ninclude/linux/compiler_types.h-60-# define __private\t__attribute__((noderef))\ninclude/linux/compiler_types.h:61:# define ACCESS_PRIVATE(p, member) (*((typeof((p)-\u003emember) __force *) \u0026(p)-\u003emember))\ninclude/linux/compiler_types.h-62-#else /* __CHECKER__ */\n--\ninclude/linux/compiler_types.h-80-# define __private\ninclude/linux/compiler_types.h:81:# define ACCESS_PRIVATE(p, member) ((p)-\u003emember)\ninclude/linux/compiler_types.h-82-# define __builtin_warning(x, y...) (1)\n--\ninclude/linux/iio/buffer.h=33=static inline int iio_push_to_buffers_with_timestamp(struct iio_dev *indio_dev,\n--\ninclude/linux/iio/buffer.h-35-{\ninclude/linux/iio/buffer.h:36:\tif (ACCESS_PRIVATE(indio_dev, scan_timestamp)) {\ninclude/linux/iio/buffer.h:37:\t\tsize_t ts_offset = ACCESS_PRIVATE(indio_dev, scan_timestamp_offset);\ninclude/linux/iio/buffer.h-38-\n--\ninclude/linux/iio/iio.h=978=static inline void *iio_priv(const struct iio_dev *indio_dev)\ninclude/linux/iio/iio.h-979-{\ninclude/linux/iio/iio.h:980:\treturn ACCESS_PRIVATE(indio_dev, priv);\ninclude/linux/iio/iio.h-981-}\n--\ninclude/linux/iio/iio.h=1081=static inline unsigned int iio_get_masklength(const struct iio_dev *indio_dev)\ninclude/linux/iio/iio.h-1082-{\ninclude/linux/iio/iio.h:1083:\treturn ACCESS_PRIVATE(indio_dev, masklength);\ninclude/linux/iio/iio.h-1084-}\n--\ninclude/linux/irq.h=228=enum {\n--\ninclude/linux/irq.h-253-\ninclude/linux/irq.h:254:#define __irqd_to_state(d) ACCESS_PRIVATE((d)-\u003ecommon, state_use_accessors)\ninclude/linux/irq.h-255-\n--\ninclude/linux/list_private.h-21-#define __list_private_offset(type, member)\t\t\t\t\t\\\ninclude/linux/list_private.h:22:\t((size_t)(\u0026ACCESS_PRIVATE(((type *)0), member)))\ninclude/linux/list_private.h-23-\n--\ninclude/linux/list_private.h-27- * @type:\tthe type of the struct this is embedded in.\ninclude/linux/list_private.h:28: * @member:\tthe identifier passed to ACCESS_PRIVATE.\ninclude/linux/list_private.h-29- */\n--\ninclude/linux/list_private.h-38- * @type:\tthe type of the struct this is embedded in.\ninclude/linux/list_private.h:39: * @member:\tthe identifier passed to ACCESS_PRIVATE.\ninclude/linux/list_private.h-40- */\n--\ninclude/linux/list_private.h-47- * @type:\tthe type of the struct this is embedded in.\ninclude/linux/list_private.h:48: * @member:\tthe identifier passed to ACCESS_PRIVATE.\ninclude/linux/list_private.h-49- */\n--\ninclude/linux/list_private.h-58-#define list_private_next_entry(pos, member)\t\t\t\t\t\\\ninclude/linux/list_private.h:59:\tlist_private_entry(ACCESS_PRIVATE(pos, member).next, typeof(*(pos)), member)\ninclude/linux/list_private.h-60-\n--\ninclude/linux/list_private.h-70-#define list_private_next_entry_circular(pos, head, member)\t\t\t\\\ninclude/linux/list_private.h:71:\t(list_is_last(\u0026ACCESS_PRIVATE(pos, member), head) ?\t\t\t\\\ninclude/linux/list_private.h-72-\tlist_private_first_entry(head, typeof(*(pos)), member) :\t\t\\\n--\ninclude/linux/list_private.h-80-#define list_private_prev_entry(pos, member)\t\t\t\t\t\\\ninclude/linux/list_private.h:81:\tlist_private_entry(ACCESS_PRIVATE(pos, member).prev, typeof(*(pos)), member)\ninclude/linux/list_private.h-82-\n--\ninclude/linux/list_private.h-92-#define list_private_prev_entry_circular(pos, head, member)\t\t\t\\\ninclude/linux/list_private.h:93:\t(list_is_first(\u0026ACCESS_PRIVATE(pos, member), head) ?\t\t\t\\\ninclude/linux/list_private.h-94-\tlist_private_last_entry(head, typeof(*(pos)), member) :\t\t\t\\\n--\ninclude/linux/list_private.h-103-#define list_private_entry_is_head(pos, head, member)\t\t\t\t\\\ninclude/linux/list_private.h:104:\tlist_is_head(\u0026ACCESS_PRIVATE(pos, member), (head))\ninclude/linux/list_private.h-105-\n--\ninclude/linux/mm.h=959=static inline bool mm_flags_test(int flag, const struct mm_struct *mm)\ninclude/linux/mm.h-960-{\ninclude/linux/mm.h:961:\treturn test_bit(flag, ACCESS_PRIVATE(\u0026mm-\u003eflags, __mm_flags));\ninclude/linux/mm.h-962-}\n--\ninclude/linux/mm.h=964=static inline bool mm_flags_test_and_set(int flag, struct mm_struct *mm)\ninclude/linux/mm.h-965-{\ninclude/linux/mm.h:966:\treturn test_and_set_bit(flag, ACCESS_PRIVATE(\u0026mm-\u003eflags, __mm_flags));\ninclude/linux/mm.h-967-}\n--\ninclude/linux/mm.h=969=static inline bool mm_flags_test_and_clear(int flag, struct mm_struct *mm)\ninclude/linux/mm.h-970-{\ninclude/linux/mm.h:971:\treturn test_and_clear_bit(flag, ACCESS_PRIVATE(\u0026mm-\u003eflags, __mm_flags));\ninclude/linux/mm.h-972-}\n--\ninclude/linux/mm.h=974=static inline void mm_flags_set(int flag, struct mm_struct *mm)\ninclude/linux/mm.h-975-{\ninclude/linux/mm.h:976:\tset_bit(flag, ACCESS_PRIVATE(\u0026mm-\u003eflags, __mm_flags));\ninclude/linux/mm.h-977-}\n--\ninclude/linux/mm.h=979=static inline void mm_flags_clear(int flag, struct mm_struct *mm)\ninclude/linux/mm.h-980-{\ninclude/linux/mm.h:981:\tclear_bit(flag, ACCESS_PRIVATE(\u0026mm-\u003eflags, __mm_flags));\ninclude/linux/mm.h-982-}\n--\ninclude/linux/mm.h=984=static inline void mm_flags_clear_all(struct mm_struct *mm)\ninclude/linux/mm.h-985-{\ninclude/linux/mm.h:986:\tbitmap_zero(ACCESS_PRIVATE(\u0026mm-\u003eflags, __mm_flags), NUM_MM_FLAG_BITS);\ninclude/linux/mm.h-987-}\n--\ninclude/linux/mm_types.h=1432=static inline void __mm_flags_overwrite_word(struct mm_struct *mm, unsigned long value)\ninclude/linux/mm_types.h-1433-{\ninclude/linux/mm_types.h:1434:\t*ACCESS_PRIVATE(\u0026mm-\u003eflags, __mm_flags) = value;\ninclude/linux/mm_types.h-1435-}\n--\ninclude/linux/mm_types.h=1438=static inline const unsigned long *__mm_flags_get_bitmap(const struct mm_struct *mm)\ninclude/linux/mm_types.h-1439-{\ninclude/linux/mm_types.h:1440:\treturn (const unsigned long *)ACCESS_PRIVATE(\u0026mm-\u003eflags, __mm_flags);\ninclude/linux/mm_types.h-1441-}\n--\ninclude/linux/mm_types.h=1453=static inline void __mm_flags_set_mask_bits_word(struct mm_struct *mm,\n--\ninclude/linux/mm_types.h-1455-{\ninclude/linux/mm_types.h:1456:\tunsigned long *bitmap = ACCESS_PRIVATE(\u0026mm-\u003eflags, __mm_flags);\ninclude/linux/mm_types.h-1457-\n--\ninclude/trace/events/timer.h=223=TRACE_EVENT(hrtimer_start,\n--\ninclude/trace/events/timer.h-239-\t\t__entry-\u003ehrtimer\t= hrtimer;\ninclude/trace/events/timer.h:240:\t\t__entry-\u003efunction\t= ACCESS_PRIVATE(hrtimer, function);\ninclude/trace/events/timer.h-241-\t\t__entry-\u003eexpires\t= hrtimer_get_expires(hrtimer);\n--\ninclude/trace/events/timer.h=261=TRACE_EVENT(hrtimer_expire_entry,\n--\ninclude/trace/events/timer.h-275-\t\t__entry-\u003enow\t\t= now;\ninclude/trace/events/timer.h:276:\t\t__entry-\u003efunction\t= ACCESS_PRIVATE(hrtimer, function);\ninclude/trace/events/timer.h-277-\t),\n--\nkernel/irq/internals.h=200=static inline class_irqdesc_lock_t class_irqdesc_lock_constructor(unsigned int irq, bool bus,\n--\nkernel/irq/internals.h-217-\nkernel/irq/internals.h:218:#define __irqd_to_state(d) ACCESS_PRIVATE((d)-\u003ecommon, state_use_accessors)\nkernel/irq/internals.h-219-\n--\nkernel/liveupdate/luo_file.c=874=int liveupdate_register_file_handler(struct liveupdate_file_handler *fh)\n--\nkernel/liveupdate/luo_file.c-898-\nkernel/liveupdate/luo_file.c:899:\tINIT_LIST_HEAD(\u0026ACCESS_PRIVATE(fh, flb_list));\nkernel/liveupdate/luo_file.c:900:\tINIT_LIST_HEAD(\u0026ACCESS_PRIVATE(fh, list));\nkernel/liveupdate/luo_file.c:901:\tlist_add_tail(\u0026ACCESS_PRIVATE(fh, list), \u0026luo_file_handler_list);\nkernel/liveupdate/luo_file.c-902-\tup_write(\u0026luo_register_rwlock);\n--\nkernel/liveupdate/luo_file.c=920=void liveupdate_unregister_file_handler(struct liveupdate_file_handler *fh)\n--\nkernel/liveupdate/luo_file.c-926-\tluo_flb_unregister_all(fh);\nkernel/liveupdate/luo_file.c:927:\tlist_del(\u0026ACCESS_PRIVATE(fh, list));\nkernel/liveupdate/luo_file.c-928-}\n--\nkernel/liveupdate/luo_flb.c=87=static struct luo_flb_private *luo_flb_get_private(struct liveupdate_flb *flb)\nkernel/liveupdate/luo_flb.c-88-{\nkernel/liveupdate/luo_flb.c:89:\tstruct luo_flb_private *private = \u0026ACCESS_PRIVATE(flb, private);\nkernel/liveupdate/luo_flb.c-90-\tstatic DEFINE_SPINLOCK(luo_flb_init_lock);\n--\nkernel/liveupdate/luo_flb.c=253=int luo_flb_file_preserve(struct liveupdate_file_handler *fh)\nkernel/liveupdate/luo_flb.c-254-{\nkernel/liveupdate/luo_flb.c:255:\tstruct list_head *flb_list = \u0026ACCESS_PRIVATE(fh, flb_list);\nkernel/liveupdate/luo_flb.c-256-\tstruct luo_flb_link *iter;\n--\nkernel/liveupdate/luo_flb.c=289=void luo_flb_file_unpreserve(struct liveupdate_file_handler *fh)\nkernel/liveupdate/luo_flb.c-290-{\nkernel/liveupdate/luo_flb.c:291:\tstruct list_head *flb_list = \u0026ACCESS_PRIVATE(fh, flb_list);\nkernel/liveupdate/luo_flb.c-292-\tstruct luo_flb_link *iter;\n--\nkernel/liveupdate/luo_flb.c=310=void luo_flb_file_finish(struct liveupdate_file_handler *fh)\nkernel/liveupdate/luo_flb.c-311-{\nkernel/liveupdate/luo_flb.c:312:\tstruct list_head *flb_list = \u0026ACCESS_PRIVATE(fh, flb_list);\nkernel/liveupdate/luo_flb.c-313-\tstruct luo_flb_link *iter;\n--\nkernel/liveupdate/luo_flb.c=320=static void luo_flb_unregister_one(struct liveupdate_file_handler *fh,\n\n"
}

63/3 2026/10/01 04:48 llm kmsan-evaluator
0m Model:
gemini-3.8-flash

Args:
null

Results:
null

Tokens:
							input: 48360
							output: 421
							thoughts: 1230
						

Thoughts:
**KMSAN Assessment: No Uninitialized Memory Risk**

Okay, here's my assessment of this patch. I've been digging into the `ACCESS_PRIVATE` and `__private` annotations in the context of the `net_bridge_dst` structure. The goal is to ensure that member access is controlled, which is good practice. The core question is: does this change introduce or expose risks of uninitialized memory usage, and therefore necessitate a KMSAN fuzzing session?

First, I examined whether the patch touches kernel structures sent to userspace. I scrutinized `fdb_fill_info` (netlink) and `br_fdb_fillbuf` (ioctl) and determined that no new fields or uninitialized memory are exposed to userspace. The changes simply refactor how the `dst` member of `fdb` is accessed, and this access is already safe.

Next, I looked at conditional logic and branching. I carefully traced all modified and added branches: `br_dst_equal`, `br_dev_xmit`, `br_handle_frame_finish`, and `br_should_learn`. I confirmed that all variables used in these branches are initialized before use, removing any potential issues related to uninitialized values.

I then investigated data structure allocation and initialization. I specifically looked at `fdb_create()`, scrutinizing the `kmem_cache_alloc` and the subsequent initialization steps. I confirmed that the `fdb` structure is fully initialized, including the `net_bridge_dst` and `br_fwd_dst` members. The existing code uses `memcpy` for the key, `br_fdb_dst_write` for the destination, `fdb->key.vlan_id` and flags, and the initialization of update/used. The `net_bridge_dst` structure, an `unsigned long`, is passed by value, and all associated structures are initialized. The `br_fwd_dst` is initialized by `br_dst_decode()`. No uninitialized fields are being read later in reachable code paths.

I also checked for any potential bounds check issues or logic flaws. I found none.

I did, however, consider potential bugs introduced by the patch. Specifically, I identified lifetime issues (Use-After-Free) related to `struct net_bridge_vlan *` and potential race conditions with RCU lookups and packet forwarding. These are primarily memory corruption issues (UAF or NULL pointer dereferences) that KASAN should catch, not KMSAN. I also considered locking or RCU synchronization bugs, which would be detected by KASAN/LOCKDEP/KCSAN.

Based on this analysis, I'm confident that the changes *do not* introduce or expose uninitialized memory risks. The potential issues are primarily use-after-free or concurrency-related, which are adequately addressed by existing bug detectors like KASAN, LOCKDEP, and KCSAN.

Given all of this, and by following the guidelines, I can definitively state that a dedicated KMSAN fuzzing session is not needed. `NeedsKMSAN=false` is the correct setting. I'm preparing to call the tool to set the results with this reasoning.



64/3 2026/10/01 04:48 tool set-results
0m Args:
{
  "KMSANReasoning": "The patch refactors bridge Forwarding Database (FDB) entries to support VLAN-aware destinations. It introduces a wrapper type `struct net_bridge_dst` containing a tagged pointer (`unsigned long value`) that references either a `struct net_bridge_port` or a `struct net_bridge_vlan`.\n\nKMSAN vs KASAN Applicability:\n- Uninitialized Memory Risks (KMSAN): None. `struct net_bridge_dst` consists of a single scalar field (`unsigned long value`) with no padding, and every instance created via `br_port_to_dst()`, `br_vlan_to_dst()`, or `br_dst_read()` is fully initialized before being read, copied, or stored. Local variables across callers (such as `struct br_fwd_dst`, `vid`, `vlan`, and `state`) are explicitly initialized (e.g., `br_should_learn()` sets `*vlan = NULL` at function entry; `br_allowed_ingress()` sets `*vlan` on success; `br_dst_decode()` unconditionally sets both output pointers). No kernel structures with uninitialized padding or uninitialized fields are exposed to userspace.\n- Lifetime and Concurrency Risks (KASAN/LOCKDEP): The main risks introduced by caching pointers to `struct net_bridge_vlan` inside FDB entries revolve around object lifetimes, RCU synchronization, and potential use-after-free (UAF) or race conditions during VLAN deletion (`nbp_vlan_delete`) or port unbinding (`del_nbp`). These issues fall strictly under the detection capabilities of KASAN (use-after-free) and LOCKDEP (locking/synchronization).\n\nBecause the changes do not introduce or expose uninitialized memory reads or information leaks, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

Results:
{
  "KMSANReasoning": "The patch refactors bridge Forwarding Database (FDB) entries to support VLAN-aware destinations. It introduces a wrapper type `struct net_bridge_dst` containing a tagged pointer (`unsigned long value`) that references either a `struct net_bridge_port` or a `struct net_bridge_vlan`.\n\nKMSAN vs KASAN Applicability:\n- Uninitialized Memory Risks (KMSAN): None. `struct net_bridge_dst` consists of a single scalar field (`unsigned long value`) with no padding, and every instance created via `br_port_to_dst()`, `br_vlan_to_dst()`, or `br_dst_read()` is fully initialized before being read, copied, or stored. Local variables across callers (such as `struct br_fwd_dst`, `vid`, `vlan`, and `state`) are explicitly initialized (e.g., `br_should_learn()` sets `*vlan = NULL` at function entry; `br_allowed_ingress()` sets `*vlan` on success; `br_dst_decode()` unconditionally sets both output pointers). No kernel structures with uninitialized padding or uninitialized fields are exposed to userspace.\n- Lifetime and Concurrency Risks (KASAN/LOCKDEP): The main risks introduced by caching pointers to `struct net_bridge_vlan` inside FDB entries revolve around object lifetimes, RCU synchronization, and potential use-after-free (UAF) or race conditions during VLAN deletion (`nbp_vlan_delete`) or port unbinding (`del_nbp`). These issues fall strictly under the detection capabilities of KASAN (use-after-free) and LOCKDEP (locking/synchronization).\n\nBecause the changes do not introduce or expose uninitialized memory reads or information leaks, a dedicated KMSAN fuzzing session is not warranted.",
  "NeedsKMSAN": false
}

LLM Calls Summary:
Total Calls Total Tokens Avg Tokens Total Duration (Seconds) Avg Duration (Seconds)
Tool Calls Summary:
Total Calls Total Duration (Seconds) Avg Duration (Seconds)