From: Julius Bairaktaris <julius@bairaktaris.de>
To: Andrew Lunn <andrew@lunn.ch>, Vladimir Oltean <olteanv@gmail.com>,
netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@kernel.org>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Willem de Bruijn" <willemb@google.com>,
"Simon Horman" <horms@kernel.org>,
"Alvin Šipraga" <alvin.sipraga@analog.com>,
"Linus Walleij" <linusw@kernel.org>,
"Florian Fainelli" <florian.fainelli@broadcom.com>,
"Pawel Dembicki" <paweldembicki@gmail.com>,
"Tobias Waldekranz" <tobias@waldekranz.com>,
"Daniel Golle" <daniel@makrotopia.org>,
"Russell King" <linux@armlinux.org.uk>,
linux-kernel@vger.kernel.org
Subject: [PATCH net 6/6] net: dsa: keep a bridge number while another tree uses it
Date: Sat, 28 Nov 2026 17:52:05 +0100 [thread overview]
Message-ID: <20261128165206.3248835-7-julius@bairaktaris.de> (raw)
In-Reply-To: <20261128165206.3248835-1-julius@bairaktaris.de>
Bridge numbers are unique across all DSA trees, and a bridge spanning
ports of two trees gets one number, which both trees use.
dsa_port_bridge_destroy() puts the number when the last port of its
own tree leaves the bridge, and dsa_bridge_num_put() clears the bit
unconditionally, so the number is free while the other tree still
offloads the bridge under it. The next bridge that gets a number then
gets the same one: on a tag_8021q switch both bridges share a VLAN, on
mv88e6xxx a cross-chip PVT row, and frames of one reach the ports of
the other.
Clear the bit only when no tree offloads the bridge any more.
Found by an LLM review (Claude), and reproduced in QEMU with dsa_loop.
Fixes: f5e165e72b29 ("net: dsa: track unique bridge numbers across all DSA switch trees")
Signed-off-by: Julius Bairaktaris <julius@bairaktaris.de>
---
net/dsa/dsa.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 67b5d2c42fb..bcb398615fc 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -177,10 +177,13 @@ unsigned int dsa_bridge_num_get(const struct net_device *bridge_dev, int max)
void dsa_bridge_num_put(const struct net_device *bridge_dev,
unsigned int bridge_num)
{
- /* Since we refcount bridges, we know that when we call this function
- * it is no longer in use, so we can just go ahead and remove it from
- * the bit mask.
+ /* The bridge is no longer offloaded by the tree that calls this, but
+ * the number is global: another tree may still offload the bridge
+ * under it.
*/
+ if (dsa_bridge_num_find(bridge_dev) == bridge_num)
+ return;
+
clear_bit(bridge_num, &dsa_fwd_offloading_bridges);
}
--
2.53.0
next prev parent reply other threads:[~2026-11-28 16:52 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-28 16:51 [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches Julius Bairaktaris
2026-11-28 16:52 ` [PATCH net 1/6] net: dsa: free struct dsa_bridge after an RCU grace period Julius Bairaktaris
2026-11-28 16:52 ` [PATCH net 2/6] net: dsa: tag_sja1105, tag_vsc73xx_8021q: read the bridge once in xmit Julius Bairaktaris
2026-12-06 3:54 ` willemb
2026-11-28 16:52 ` [PATCH net 3/6] net: dsa: tag_dsa: send a marked frame of an unbridged port from the CPU Julius Bairaktaris
2026-12-06 3:55 ` willemb
2026-11-28 16:52 ` [PATCH net 4/6] net: dsa: do not hand a switch a bridge number above its limit Julius Bairaktaris
2026-12-06 3:55 ` willemb
2026-11-28 16:52 ` [PATCH net 5/6] net: dsa: do not take a bridge number past the end of the bitmap Julius Bairaktaris
2026-11-28 16:52 ` Julius Bairaktaris [this message]
2026-12-06 3:57 ` [PATCH net 6/6] net: dsa: keep a bridge number while another tree uses it willemb
2026-12-06 3:54 ` [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches willemb
2026-12-06 10:06 ` Julius Bairaktaris
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=20261128165206.3248835-7-julius@bairaktaris.de \
--to=julius@bairaktaris.de \
--cc=alvin.sipraga@analog.com \
--cc=andrew@lunn.ch \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=florian.fainelli@broadcom.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=paweldembicki@gmail.com \
--cc=tobias@waldekranz.com \
--cc=willemb@google.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
all inboxes | Powered by JetHome®