Netdev List
 help / color / mirror / Atom feed
From: Julius Bairaktaris <julius@bairaktaris.de>
To: Nikolay Aleksandrov <razor@blackwall.org>,
	Ido Schimmel <idosch@nvidia.com>
Cc: netdev@vger.kernel.org, bridge@lists.linux.dev,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Simon Horman <horms@kernel.org>,
	Vladimir Oltean <olteanv@gmail.com>,
	Vladimir Oltean <vladimir.oltean@nxp.com>,
	Jesse Brandeburg <jbrandeb@kernel.org>
Subject: [PATCH net-next v2 2/2] net: bridge: clear the offloaded flag of an fdb entry that roams
Date: Sun, 22 Nov 2026 20:21:18 +0100	[thread overview]
Message-ID: <20261122192118.1204290-3-julius@bairaktaris.de> (raw)
In-Reply-To: <20261122192118.1204290-1-julius@bairaktaris.de>

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


  parent reply	other threads:[~2026-11-22 19:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Julius Bairaktaris [this message]
2026-11-23 19:23   ` [PATCH net-next v2 2/2] net: bridge: clear the offloaded flag of an fdb entry that roams netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261122192118.1204290-3-julius@bairaktaris.de \
    --to=julius@bairaktaris.de \
    --cc=bridge@lists.linux.dev \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=idosch@nvidia.com \
    --cc=jbrandeb@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=vladimir.oltean@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox