From: willemb@google.com
To: Julius Bairaktaris <julius@bairaktaris.de>,
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: Re: [PATCH net 4/6] net: dsa: do not hand a switch a bridge number above its limit
Date: Sat, 05 Dec 2026 22:55:46 -0500 [thread overview]
Message-ID: <willemb.2503258e211d8@google.com> (raw)
In-Reply-To: <20261128165206.3248835-5-julius@bairaktaris.de>
Julius Bairaktaris wrote:
> Bridge numbers are unique across all DSA trees, and each switch tells
> dsa_bridge_num_get() the largest number it can use (max_num_bridges).
> The limit is checked only when the bridge gets its number. A switch
> that joins a bridge which another switch, with a larger limit, has
> numbered already gets that number unchecked. With an mv88e6xxx tree
> (limit up to 31) or an mxl862xx tree (48) beside a sja1105 or vsc73xx
> tree (DSA_TAG_8021Q_MAX_NUM_BRIDGES, 7) and eight or more offloaded
> bridges, the tag_8021q switch encodes number 9 in the three VBID bits of
> its bridge VLAN (dsa_tag_8021q_bridge_vid()), so bridge 9 gets the VLAN
> of bridge 1 and the two share a broadcast domain in the switch. An
> mxl862xx tree beside an mv88e6xxx one with 32 or more bridges overflows
> the device field of the DSA header in the same way.
> Return 0 for a number beyond the limit in that case too. Refuse the
> same in dsa_port_bridge_create() when the bridge is found in the tree,
> where another switch of the tree may have numbered it beyond this
> switch's limit, or not at all: an mv88e6xxx chip without a PVT has
> max_num_bridges 0 and leaves the bridge at number 0, which a chip with
> a PVT would take. The port is then bridged in software ("Range of
> offloadable bridges exceeded"), as a port that joins a new bridge
> beyond the limit already is.
> 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:130-143, 147, 167 (dsa_bridge_num_find /
dsa_bridge_num_get):
Patch 4/6 relies on dsa_bridge_num_find(bridge_dev) returning the existing
non-zero bridge_num before checking `else if (bridge_num > max)`. Because
dsa_bridge_num_find() returns bridge->num on the *first* tree in
dsa_tree_list
that contains bridge_dev — even if bridge->num == 0 — a system with
dsa_tree_list ordered [Tree 0 (max_num_bridges=0), Tree 1 (max=31), Tree 2
(max=7)] where Tree 0 joins br0 first causes Tree 2's
dsa_bridge_num_find(br0)
to return 0 instead of Tree 1's number, bypassing Patch 4/6's limit check
and
allocating a second distinct bridge number for br0. Fixing
dsa_bridge_num_find()
to check `if (bridge && bridge->num)` fixes both Patch 4/6 and Patch 6/6.
next prev parent reply other threads:[~2026-12-06 3:55 UTC|newest]
Thread overview: 12+ 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 [this message]
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 ` [PATCH net 6/6] net: dsa: keep a bridge number while another tree uses it Julius Bairaktaris
2026-12-06 3:57 ` willemb
2026-12-06 3:54 ` [PATCH net 0/6] net: dsa: offload_fwd_mark on unbridged ports, bridge numbers across switches willemb
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=willemb.2503258e211d8@google.com \
--to=willemb@google.com \
--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=julius@bairaktaris.de \
--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 \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.