]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
net: dsa: fix off-by-one in maximum bridge ID determination
authorVladimir Oltean <vladimir.oltean@nxp.com>
Tue, 20 Jan 2026 21:10:39 +0000 (23:10 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 22 Jan 2026 03:52:29 +0000 (19:52 -0800)
commitdfca045cd4d0ea07ff4198ba392be3e718acaddc
tree3020070f728bb8c238b331629caaf952c95f65b9
parentbbb11b8d758d17a4ce34b8ed0b49de150568265b
net: dsa: fix off-by-one in maximum bridge ID determination

Prior to the blamed commit, the bridge_num range was from
0 to ds->max_num_bridges - 1. After the commit, it is from
1 to ds->max_num_bridges.

So this check:
if (bridge_num >= max)
return 0;
must be updated to:
if (bridge_num > max)
return 0;

in order to allow the last bridge_num value (==max) to be used.

This is easiest visible when a driver sets ds->max_num_bridges=1.
The observed behaviour is that even the first created bridge triggers
the netlink extack "Range of offloadable bridges exceeded" warning, and
is handled in software rather than being offloaded.

Fixes: 3f9bb0301d50 ("net: dsa: make dp->bridge_num one-based")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20260120211039.3228999-1-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/dsa/dsa.c