public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] net: dsa: fix off-by-one in maximum bridge ID determination
@ 2026-01-20 21:10 Vladimir Oltean
  2026-01-22  4:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Vladimir Oltean @ 2026-01-20 21:10 UTC (permalink / raw)
  To: netdev
  Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Simon Horman, Alvin Šipraga

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>
---
 net/dsa/dsa.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 99ede37698ac..35ce3941fae3 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -158,7 +158,7 @@ unsigned int dsa_bridge_num_get(const struct net_device *bridge_dev, int max)
 		bridge_num = find_next_zero_bit(&dsa_fwd_offloading_bridges,
 						DSA_MAX_NUM_OFFLOADING_BRIDGES,
 						1);
-		if (bridge_num >= max)
+		if (bridge_num > max)
 			return 0;
 
 		set_bit(bridge_num, &dsa_fwd_offloading_bridges);
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net: dsa: fix off-by-one in maximum bridge ID determination
  2026-01-20 21:10 [PATCH net] net: dsa: fix off-by-one in maximum bridge ID determination Vladimir Oltean
@ 2026-01-22  4:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-01-22  4:00 UTC (permalink / raw)
  To: Vladimir Oltean
  Cc: netdev, andrew, davem, edumazet, kuba, pabeni, horms, alsi

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 20 Jan 2026 23:10:39 +0200 you wrote:
> 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;
> 
> [...]

Here is the summary with links:
  - [net] net: dsa: fix off-by-one in maximum bridge ID determination
    https://git.kernel.org/netdev/net/c/dfca045cd4d0

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-01-22  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-20 21:10 [PATCH net] net: dsa: fix off-by-one in maximum bridge ID determination Vladimir Oltean
2026-01-22  4:00 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox