* [PATCH net-next v2 0/2] net: bridge: switchdev state of fdb entries made dynamic or roamed @ 2026-11-22 19:21 Julius Bairaktaris 2026-11-22 19:21 ` [PATCH net-next v2 1/2] net: bridge: withdraw the switchdev entry of an fdb entry made dynamic Julius Bairaktaris 2026-11-22 19:21 ` [PATCH net-next v2 2/2] net: bridge: clear the offloaded flag of an fdb entry that roams Julius Bairaktaris 0 siblings, 2 replies; 5+ messages in thread From: Julius Bairaktaris @ 2026-11-22 19:21 UTC (permalink / raw) To: Nikolay Aleksandrov, Ido Schimmel Cc: netdev, bridge, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Vladimir Oltean, Vladimir Oltean, Jesse Brandeburg When the user turns an fdb entry that switchdev was told about into one added as "master dynamic", the bridge reports neither that change nor the entry's later deletion, so drivers keep the entry after the bridge dropped it. When the bridge withdraws an entry from a port's driver and keeps it, which that change and a learned entry moving to another port both do, the entry keeps the offloaded flag, so "bridge fdb show" and "bridge fdb flush ... offloaded" treat it as offloaded while nothing holds it. Patch 1 reports the deletion of such an entry to switchdev before the entry becomes one that is not reported, and clears the offloaded flag with it. Patch 2 clears the offloaded flag when a learned entry roams, right after the deletion is reported to the old port. Both were found by an LLM review: patch 1 in a review of the series "net: dsa: fix host fdb refcount when an entry roams", patch 2 in one of __fdb_update() while patch 1 was reworked after its v1 review. Trigger: patch 1, a local user with CAP_NET_ADMIN runs "bridge fdb replace <addr> dev <port> master dynamic" (or "... master use") on an entry that a switchdev driver offloaded; patch 2, an address learned on one bridge port is seen on another, as when a host moves, and the old port's driver had offloaded the entry while the new port's does not (DSA with assisted learning on the CPU port, entries learned by a switch). Shown in QEMU with dsa_loop. Impact: patch 1, the switch keeps the entry for the old port after the bridge dropped it; patch 2, a wrong "offload" flag in the bridge's view. No crash or memory corruption. CVSS 3.1: patch 1 2.3 (AV:L/AC:L/PR:H/UI:N/S:U/C:N/I:L/A:N), patch 2 0.0. Until the fix: delete the entry and add it again instead of replacing it; the wrong flag of patch 2 goes when the entry ages out. In QEMU with KASAN, with dsa_loop given FDB operations and assisted learning on the CPU port, and a tc mirred redirect that delivers frames to a dsa_loop user port (test-only setup): a static entry on a user port replaced by "master dynamic", and an address learned on a veth port, which is a host address on the CPU port, replaced by "master dynamic" or "master use", are not deleted from the switch and are still shown as offloaded without the series, in 3 of 3 boots each. With it, each is deleted from the switch and no longer shown as offloaded, in 3 of 3 boots each. An address learned on the veth port and then on the user port is still shown as offloaded with patch 1 alone and not with both, in 3 of 3 boots each. I used Claude (Anthropic) to help write these patches. v2: - net-next instead of net, so without the Fixes: tag; the commit that introduced the filter is named in the first paragraph of patch 1 (Nikolay). - Patch 1 clears the offloaded flag with the withdrawal: a "master static" entry the driver had offloaded kept it after "replace ... master dynamic" deleted the entry from the hardware (Nikolay). br_fdb_offloaded_set() assigns the flag instead of toggling it, so the clear cannot be inverted by a concurrent report. - Call br_switchdev_fdb_notify() directly, no helper (Nikolay). - Drop the comments in __fdb_update() (Nikolay). - New patch 2. v1: https://lore.kernel.org/netdev/20261121191638.1724620-1-julius@bairaktaris.de/ Julius Bairaktaris (2): net: bridge: withdraw the switchdev entry of an fdb entry made dynamic net: bridge: clear the offloaded flag of an fdb entry that roams net/bridge/br_fdb.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) base-commit: eb6d6c80d35449c27471b1874f13066c09a8964d -- 2.53.0 ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next v2 1/2] net: bridge: withdraw the switchdev entry of an fdb entry made dynamic 2026-11-22 19:21 [PATCH net-next v2 0/2] net: bridge: switchdev state of fdb entries made dynamic or roamed Julius Bairaktaris @ 2026-11-22 19:21 ` Julius Bairaktaris 2026-11-23 19:23 ` netdev-bot+sashiko 2026-11-22 19:21 ` [PATCH net-next v2 2/2] net: bridge: clear the offloaded flag of an fdb entry that roams Julius Bairaktaris 1 sibling, 1 reply; 5+ messages in thread From: Julius Bairaktaris @ 2026-11-22 19:21 UTC (permalink / raw) To: Nikolay Aleksandrov, Ido Schimmel Cc: netdev, bridge, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Vladimir Oltean, Vladimir Oltean, Jesse Brandeburg Since commit 927cdea5d209 ("net: bridge: switchdev: don't notify FDB entries with "master dynamic""), br_switchdev_fdb_notify() reports neither the addition nor the deletion of an entry that the user added without NUD_PERMANENT or NUD_NOARP. The user can turn an entry that switchdev was told about, a learned one or a static one, into such an entry: fdb_add_entry() does it for "bridge fdb replace ... master dynamic", and __fdb_update() for "bridge fdb replace ... master use" (NTF_USE), which marks a learned entry as added by the user. The drivers then keep the entry they were given, and since its later deletion is not reported either, they keep it after the bridge has dropped it. Report the deletion of the old entry to switchdev before either path makes it one that is no longer reported, as br_fdb_update() does before an entry moves to another port; br_switchdev_fdb_notify() tests the old flags, so only an entry that was reported is withdrawn. Entries with the extern_learn flag stay reported and are left alone. The NTF_USE branch is only reached from netlink: the packet path passes no BR_FDB_ADDED_BY_USER to br_fdb_update(). Clear the offloaded flag of the entry with the withdrawal. Drivers set it once they have programmed an entry and do not clear it when they delete one, so the entry, which stays in the bridge, would otherwise still be shown as offloaded, and matched as such by "bridge fdb flush", after the hardware dropped it. br_fdb_offloaded_set() now assigns the flag instead of testing and toggling it, so a driver report that runs beside the clear in the NTF_USE path, which does not hold hash_lock, cannot invert it. Found by an LLM review of the series "net: dsa: fix host fdb refcount when an entry roams". In QEMU with KASAN and dsa_loop given FDB operations and assisted learning, a static entry on a dsa_loop port and an address learned on a veth port of the bridge, which is a host address on the CPU port, are offloaded. Without this change, "bridge fdb replace <addr> dev lan1 master dynamic" on the first, and "... dev vA master dynamic" or "... dev vA master use" on the second, delete nothing from the switch and the entries are still shown as offloaded, in 3 of 3 boots for each command. With it, each command deletes the address from the switch and the entry is no longer shown as offloaded, in 3 of 3 boots for each. Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de> --- v2: - net-next instead of net, so without the Fixes: tag; the commit that introduced the filter is named in the first paragraph (Nikolay). - Clear the offloaded flag with the withdrawal: a "master static" entry the driver had offloaded kept it after "replace ... master dynamic" deleted the entry from the hardware (Nikolay). br_fdb_offloaded_set() assigns the flag instead of toggling it, so the clear cannot be inverted by a concurrent report. - Call br_switchdev_fdb_notify() directly, no helper (Nikolay). - Drop the comments in __fdb_update() (Nikolay). v1: https://lore.kernel.org/netdev/20261121191638.1724620-1-julius@bairaktaris.de/ net/bridge/br_fdb.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index b601245ad923..4af091c19244 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -1005,6 +1005,7 @@ static void __fdb_update(struct net_bridge *br, struct net_bridge_port *old_port; struct net_bridge_dst old_dst; bool fdb_modified = false; + bool roamed = false; unsigned long now; /* attempt to update an entry for a local interface */ @@ -1032,6 +1033,7 @@ static void __fdb_update(struct net_bridge *br, br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); br_fdb_dst_write(fdb, dst); fdb_modified = true; + roamed = true; /* take over HW learned entry */ if (unlikely(test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags))) @@ -1049,6 +1051,12 @@ static void __fdb_update(struct net_bridge *br, } if (unlikely(test_bit(BR_FDB_ADDED_BY_USER, &flags))) { + if (!test_bit(BR_FDB_STATIC, &fdb->flags) && + !test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) { + if (!roamed) + br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); + clear_bit(BR_FDB_OFFLOADED, &fdb->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); @@ -1262,6 +1270,12 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst, if (flags & NLM_F_EXCL) return -EEXIST; + if (!(state & (NUD_PERMANENT | NUD_NOARP)) && + !test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) { + br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); + clear_bit(BR_FDB_OFFLOADED, &fdb->flags); + } + old_dst = br_fdb_dst_read(fdb); modified = fdb_update_dst(fdb, old_dst, dst); @@ -1706,8 +1720,8 @@ void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p, spin_lock_bh(&br->hash_lock); fdb = br_fdb_find(br, addr, vid); - if (fdb && offloaded != test_bit(BR_FDB_OFFLOADED, &fdb->flags)) - change_bit(BR_FDB_OFFLOADED, &fdb->flags); + if (fdb) + assign_bit(BR_FDB_OFFLOADED, &fdb->flags, offloaded); spin_unlock_bh(&br->hash_lock); } -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2 1/2] net: bridge: withdraw the switchdev entry of an fdb entry made dynamic 2026-11-22 19:21 ` [PATCH net-next v2 1/2] net: bridge: withdraw the switchdev entry of an fdb entry made dynamic Julius Bairaktaris @ 2026-11-23 19:23 ` netdev-bot+sashiko 0 siblings, 0 replies; 5+ messages in thread From: netdev-bot+sashiko @ 2026-11-23 19:23 UTC (permalink / raw) To: julius Cc: razor, idosch, netdev, bridge, davem, edumazet, kuba, pabeni, horms, olteanv, vladimir.oltean, jbrandeb Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 3 · Low: 0 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] A late driver offload report can set BR_FDB_OFFLOADED again after the new withdrawal has cleared it. - [Medium] The new withdrawal does its check and its action as separate steps, with nothing that excludes the lockless packet path. - [Medium] The patch treats br_switchdev_fdb_notify()'s filter as the definition of what is reported, and withdraws an entry… -- net: bridge: withdraw the switchdev entry of an fdb entry made dynamic Two paths turn an fdb entry into a user-added dynamic entry, which br_switchdev_fdb_notify() no longer reports. They are fdb_add_entry() ("replace ... master dynamic") and the NTF_USE branch of __fdb_update() ("replace ... master use"). Before either path does so, the patch now sends a switchdev deletion for the entry and clears BR_FDB_OFFLOADED, and br_fdb_offloaded_set() now assigns the offloaded flag instead of toggling it. > diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c > index b601245ad9239..4af091c192449 100644 > --- a/net/bridge/br_fdb.c > +++ b/net/bridge/br_fdb.c [ ... ] > @@ -1032,6 +1033,7 @@ static void __fdb_update(struct net_bridge *br, > br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); > br_fdb_dst_write(fdb, dst); > fdb_modified = true; > + roamed = true; > /* take over HW learned entry */ > if (unlikely(test_bit(BR_FDB_ADDED_BY_EXT_LEARN, > &fdb->flags))) > @@ -1049,6 +1051,12 @@ static void __fdb_update(struct net_bridge *br, > } > > if (unlikely(test_bit(BR_FDB_ADDED_BY_USER, &flags))) { > + if (!test_bit(BR_FDB_STATIC, &fdb->flags) && > + !test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) { > + if (!roamed) > + br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); > + clear_bit(BR_FDB_OFFLOADED, &fdb->flags); > + } > + set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags); [Severity: Medium] Can the packet path slip in between this withdrawal and the set_bit(BR_FDB_ADDED_BY_USER) below it? The NTF_USE branch gets here from __br_fdb_add() holding only local_bh_disable() and rcu_read_lock(). The packet path, br_fdb_update() -> fdb_find_rcu() -> __fdb_update(), takes no lock at all. Three things happen in separate steps: the check that the entry is still reported, the DEL, and the move to the never-reported state. Take M learned on port A, with a frame from M arriving on a non-sticky port B: CPU0 (bridge fdb replace M dev vA master use) __fdb_update() br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); /* DEL for A */ CPU1 (frame from M on port B) __fdb_update() if (source != old_port) { br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); /* DEL for A again */ br_fdb_dst_write(fdb, dst); ... fdb_notify(br, fdb, RTM_NEWNEIGH, true); /* ADD for B */ CPU0 clear_bit(BR_FDB_OFFLOADED, &fdb->flags); set_bit(BR_FDB_ADDED_BY_USER, &fdb->flags); CPU1's notifications get through the filter in br_switchdev_fdb_notify() because BR_FDB_ADDED_BY_USER is still clear. Once CPU0 sets the bit, the filter drops every later notification for the entry, including its final deletion. So the hardware entry for B is never withdrawn. For a host address on the DSA CPU port, the refcounted entry from dsa_port_do_fdb_add() stays installed after the bridge drops or moves the entry. The second DEL for A has no matching ADD. On the CPU port, dsa_port_do_fdb_del() returns -ENOENT. With fdb_isolation off, db.bridge.num is 0 and shared across bridges, so it can instead drop a reference that another bridge holds for the same addr/vid. fdb_add_entry() holds hash_lock, but the packet path doesn't take it. So the same window exists there, between the DEL and the later fdb_update_dst(), set_bit(BR_FDB_ADDED_BY_USER) and clearing of BR_FDB_STATIC. The following patch in the series only adds clear_bit(BR_FDB_OFFLOADED) on the roam path, so it doesn't close this window. > if (test_and_clear_bit(BR_FDB_DYNAMIC_LEARNED, &fdb->flags)) > atomic_dec(&br->fdb_n_learned); > @@ -1262,6 +1270,12 @@ static int fdb_add_entry(struct net_bridge *br, struct net_bridge_dst dst, > if (flags & NLM_F_EXCL) > return -EEXIST; > > + if (!(state & (NUD_PERMANENT | NUD_NOARP)) && > + !test_bit(BR_FDB_ADDED_BY_EXT_LEARN, &fdb->flags)) { > + br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); > + clear_bit(BR_FDB_OFFLOADED, &fdb->flags); > + } > + [Severity: Medium] How does this withdrawal interact with br_switchdev_fdb_replay()? The patch treats the br_switchdev_fdb_notify() filter as the definition of which entries are reported. Replay doesn't use that filter. It walks every entry, including user-added dynamic ones: net/bridge/br_switchdev.c:br_switchdev_fdb_replay() { ... hlist_for_each_entry_rcu(fdb, &br->fdb_list, fdb_node) { err = br_switchdev_fdb_replay_one(br, nb, fdb, action, ctx); ... } When a DSA port leaves the bridge, a converted entry gets a second DEL: dsa_port_pre_bridge_leave() switchdev_bridge_port_unoffload() br_switchdev_fdb_replay(adding=false) added_by_user is now set, so switchdev_fdb_is_dynamically_learned() in dsa_user_fdb_event() doesn't filter this DEL. It reaches dsa_port_bridge_host_fdb_del() or dsa_port_fdb_del(), and dsa_flush_workqueue() runs while dp->bridge is still valid. Before this patch, the replay DEL was the only DEL for a converted entry. Now it has no matching ADD: - On the CPU port, dsa_port_do_fdb_del() returns -ENOENT and the driver logs "port %d failed to delete %pM vid %d from fdb". - With fdb_isolation off, it can drop another bridge's reference for the same addr/vid. The other direction has a problem too. A port that joins after the conversion gets a replay ADD for the user-dynamic entry. Its later ageing or deletion is filtered by br_switchdev_fdb_notify(), so drivers can still keep the entry after the bridge has dropped it. That direction already affects every user-dynamic entry since commit 927cdea5d209. It doesn't match the commit message, though, which says br_switchdev_fdb_notify(): "reports neither the addition nor the deletion of an entry that the user added without NUD_PERMANENT or NUD_NOARP" Replay reports both. The following patch in the series doesn't touch replay either. > old_dst = br_fdb_dst_read(fdb); > modified = fdb_update_dst(fdb, old_dst, dst); > > @@ -1706,8 +1720,8 @@ void br_fdb_offloaded_set(struct net_bridge *br, struct net_bridge_port *p, > spin_lock_bh(&br->hash_lock); > > fdb = br_fdb_find(br, addr, vid); > - if (fdb && offloaded != test_bit(BR_FDB_OFFLOADED, &fdb->flags)) > - change_bit(BR_FDB_OFFLOADED, &fdb->flags); > + if (fdb) > + assign_bit(BR_FDB_OFFLOADED, &fdb->flags, offloaded); [Severity: Medium] Can a late offload report from the driver set BR_FDB_OFFLOADED again after the new withdrawal in fdb_add_entry() or __fdb_update() has cleared it? DSA programs FDB entries from an ordered workqueue: dsa_user_fdb_event() calls dsa_schedule_work(), which queues on dsa_owq. When an ADD work item finishes, it calls dsa_fdb_offload_notify() with offloaded=true. That goes through br_switchdev_event() to br_fdb_offloaded_set(). A DEL work item never reports offloaded=false. For example: bridge fdb add A dev lan1 master static queues ADD work bridge fdb replace A dev lan1 master dynamic fdb_add_entry() queues DEL work and clears BR_FDB_OFFLOADED, which isn't set yet ADD work runs programs the hardware and reports offloaded=true br_fdb_offloaded_set() -> assign_bit(..., true) DEL work runs removes A from the hardware The entry is now ADDED_BY_USER, !STATIC and !EXT_LEARN, so br_switchdev_fdb_notify() filters every later notification and nothing corrects the flag. fdb_fill_info() keeps reporting NTF_OFFLOADED, and "bridge fdb flush ... offloaded" keeps matching the entry. The NTF_USE path in __fdb_update() does the same when a learned or host entry still has ADD work pending. The commit message says the clear is there so the entry is not: "still be shown as offloaded, and matched as such by "bridge fdb flush", after the hardware dropped it" Moving to assign_bit() stops a concurrent report from inverting the flag, but it doesn't stop a late report from setting it. Could br_fdb_offloaded_set() ignore entries that br_switchdev_fdb_notify() no longer reports? The following patch in the series, "net: bridge: clear the offloaded flag of an fdb entry that roams", doesn't touch br_fdb_offloaded_set(), so this window is still there at the end of the series. > > spin_unlock_bh(&br->hash_lock); > } -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122192118.1204290-1-julius%40bairaktaris.de ^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net-next v2 2/2] net: bridge: clear the offloaded flag of an fdb entry that roams 2026-11-22 19:21 [PATCH net-next v2 0/2] net: bridge: switchdev state of fdb entries made dynamic or roamed Julius Bairaktaris 2026-11-22 19:21 ` [PATCH net-next v2 1/2] net: bridge: withdraw the switchdev entry of an fdb entry made dynamic Julius Bairaktaris @ 2026-11-22 19:21 ` Julius Bairaktaris 2026-11-23 19:23 ` netdev-bot+sashiko 1 sibling, 1 reply; 5+ messages in thread From: Julius Bairaktaris @ 2026-11-22 19:21 UTC (permalink / raw) To: Nikolay Aleksandrov, Ido Schimmel Cc: netdev, bridge, David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni, Simon Horman, Vladimir Oltean, Vladimir Oltean, Jesse Brandeburg When __fdb_update() moves an entry to another port, it tells switchdev to delete the entry from the old port and keeps BR_FDB_OFFLOADED. The entry is then reported for the new port, where a learned entry is often not offloaded: DSA does not install an address learned on one of its own user ports, a port without switchdev has no driver, and drivers that program only entries added by the user ignore it. Most drivers that report the flag report only additions, so the entry is still shown as offloaded, and matched as such by "bridge fdb flush ... offloaded", while nothing holds it. Clear the flag with the deletion, as fdb_add_entry() and the NTF_USE branch of __fdb_update() do when they withdraw an entry that the bridge keeps. The deletion that is reported still carries the old flag, and a driver that offloads the entry on the new port reports it after the clear, since the entry is only reported for that port at the end of __fdb_update(). clear_bit() is atomic and no lock is taken. A roam that races a driver reporting the address as learned on another port can still leave the flag wrong, as the learning path does not order the two against each other. Found by an LLM review of __fdb_update() while patch 1 was reworked after the review of its v1. In QEMU with KASAN, with dsa_loop given FDB operations and assisted learning on the CPU port, and a tc mirred redirect that delivers frames to a dsa_loop user port (test-only setup), an address learned on a veth port of the bridge is a host address on the CPU port and is offloaded. When the address is then learned on the user port, DSA deletes it from the CPU port and does not install it on the user port. Without this change the entry is still shown as offloaded, in 3 of 3 boots; with it, it is not, in 3 of 3 boots. Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de> --- v2: new patch. net/bridge/br_fdb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c index 4af091c19244..8bb40645bd6b 100644 --- a/net/bridge/br_fdb.c +++ b/net/bridge/br_fdb.c @@ -1031,6 +1031,7 @@ static void __fdb_update(struct net_bridge *br, !test_bit(BR_FDB_STICKY, &fdb->flags)))) { if (source != old_port) { br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); + clear_bit(BR_FDB_OFFLOADED, &fdb->flags); br_fdb_dst_write(fdb, dst); fdb_modified = true; roamed = true; -- 2.53.0 ^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net-next v2 2/2] net: bridge: clear the offloaded flag of an fdb entry that roams 2026-11-22 19:21 ` [PATCH net-next v2 2/2] net: bridge: clear the offloaded flag of an fdb entry that roams Julius Bairaktaris @ 2026-11-23 19:23 ` netdev-bot+sashiko 0 siblings, 0 replies; 5+ messages in thread From: netdev-bot+sashiko @ 2026-11-23 19:23 UTC (permalink / raw) To: julius Cc: razor, idosch, netdev, bridge, davem, edumazet, kuba, pabeni, horms, olteanv, vladimir.oltean, jbrandeb Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 0 · Medium: 1 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [Medium] The new clear_bit() in __fdb_update() (net/bridge/br_fdb.c:1034) is not ordered against offload reports from… - [Low] The patch fixes a user-visible defect: after a roam in __fdb_update(), the entry is shown with NTF_OFFLOADED and matched by… - [Low] The commit message body, above the `---` line, says: "Found by an LLM review of __fdb_update() while patch 1 was reworked after the… -- net: bridge: clear the offloaded flag of an fdb entry that roams When an entry roams to another port, this patch clears BR_FDB_OFFLOADED in __fdb_update() right after the switchdev deletion for the old port is sent. The goal is that the entry is no longer shown as offloaded, or matched by "bridge fdb flush ... offloaded", when the new port does not hold it. [ ... ] > Found by an LLM review of __fdb_update() while patch 1 was > reworked after the review of its v1. [Severity: Low] This isn't a bug, but "patch 1" and "v1" won't mean anything once this is in git history. Could the dependency be named by its subject instead? That would be "net: bridge: withdraw the switchdev entry of an fdb entry made dynamic", which provides the roamed variable used in this hunk. Version history could go below the --- line or in the cover letter. [ ... ] > Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de> [Severity: Low] Should this have a Fixes: tag? The roam-time withdrawal that left BR_FDB_OFFLOADED set seems to come from: commit 90dc8fd36078 ("net: bridge: notify switchdev of disappearance of old FDB entry upon migration") Commit 6eb38bf8eb90 only added the br argument to that br_switchdev_fdb_notify() call, so it doesn't look like the right target. The message also doesn't say whether this is meant for net or net-next. The hunk depends on the roamed variable from "net: bridge: withdraw the switchdev entry of an fdb entry made dynamic". Could that dependency be recorded for backports? > diff --git a/net/bridge/br_fdb.c b/net/bridge/br_fdb.c > index 4af091c192449..8bb40645bd6b3 100644 > --- a/net/bridge/br_fdb.c > +++ b/net/bridge/br_fdb.c > @@ -1031,6 +1031,7 @@ static void __fdb_update(struct net_bridge *br, > !test_bit(BR_FDB_STICKY, &fdb->flags)))) { > if (source != old_port) { > br_switchdev_fdb_notify(br, fdb, RTM_DELNEIGH); > + clear_bit(BR_FDB_OFFLOADED, &fdb->flags); [Severity: Medium] Can a late offload report from the old port set the flag again after this clear? DSA programs FDB entries from its workqueue. After the hardware add, it reports the offload using the orig_dev that was saved when the work was queued: net/dsa/user.c:dsa_fdb_offload_notify() { ... info.offloaded = true; call_switchdev_notifiers(SWITCHDEV_FDB_OFFLOADED, switchdev_work->orig_dev, &info.info, NULL); } br_switchdev_event() gets the port p from orig_dev and passes it to br_fdb_offloaded_set(). That function looks up the entry by {addr, vid} only and never checks p against the entry's current dst port: net/bridge/br_fdb.c:br_fdb_offloaded_set() { ... fdb = br_fdb_find(br, addr, vid); if (fdb) assign_bit(BR_FDB_OFFLOADED, &fdb->flags, offloaded); ... } With the setup from the commit message, this sequence looks possible: 1. The address is learned on veth. fdb_notify() sends SWITCHDEV_FDB_ADD_TO_DEVICE. DSA treats it as a host address and queues the work. The bit is still clear. 2. Before the work runs, a frame with the same source address arrives on the DSA user port. __fdb_update() sends RTM_DELNEIGH, which is queued behind the ADD. This clear_bit() does nothing because the bit is not set yet, and dst becomes the user port. DSA ignores the NEWNEIGH for its own user port. 3. The worker runs the ADD and calls dsa_fdb_offload_notify() with orig_dev = veth. br_fdb_offloaded_set() then sets BR_FDB_OFFLOADED on the entry, which now points at the user port. 4. The worker runs the DEL. DSA doesn't report offloaded=false on delete, so the flag stays set until the entry ages out or changes. The entry is then shown as offloaded and matched by "bridge fdb flush ... offloaded" while nothing holds it in hardware. That is the state this patch is meant to remove. With MAC flapping between two ports, each roam queues another ADD/DEL pair. The commit message says: A roam that races a driver reporting the address as learned on another port can still leave the flag wrong This case is different: it is a deferred SWITCHDEV_FDB_OFFLOADED report from the old port, not a learned report. Does br_fdb_offloaded_set() also need to ignore reports whose p no longer matches the entry's dst port? > br_fdb_dst_write(fdb, dst); > fdb_modified = true; > roamed = true; -- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261122192118.1204290-1-julius%40bairaktaris.de ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-11-23 19:23 UTC | newest] Thread overview: 5+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-11-22 19:21 [PATCH net-next v2 0/2] net: bridge: switchdev state of fdb entries made dynamic or roamed Julius Bairaktaris 2026-11-22 19:21 ` [PATCH net-next v2 1/2] net: bridge: withdraw the switchdev entry of an fdb entry made dynamic Julius Bairaktaris 2026-11-23 19:23 ` netdev-bot+sashiko 2026-11-22 19:21 ` [PATCH net-next v2 2/2] net: bridge: clear the offloaded flag of an fdb entry that roams Julius Bairaktaris 2026-11-23 19:23 ` netdev-bot+sashiko
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox