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 --- 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