* [PATCH net] net/mlx5e: Fix validation logic in rate limiting
@ 2025-11-24 18:00 Danielle Costantino
2025-11-24 18:37 ` Gal Pressman
2025-11-26 0:50 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Danielle Costantino @ 2025-11-24 18:00 UTC (permalink / raw)
To: netdev
Cc: kuba, gal, tariqt, pabeni, saeedm, linux-rdma, linux-kernel,
Danielle Costantino
The rate limiting validation condition currently checks the output
variable max_bw_value[i] instead of the input value
maxrate->tc_maxrate[i]. This causes the validation to compare an
uninitialized or stale value rather than the actual requested rate.
The condition should check the input rate to properly validate against
the upper limit:
} else if (maxrate->tc_maxrate[i] <= upper_limit_gbps) {
This aligns with the pattern used in the first branch, which correctly
checks maxrate->tc_maxrate[i] against upper_limit_mbps.
The current implementation can lead to unreliable validation behavior:
- For rates between 25.5 Gbps and 255 Gbps, if max_bw_value[i] is 0
from initialization, the GBPS path may be taken regardless of whether
the actual rate is within bounds
- When processing multiple TCs (i > 0), max_bw_value[i] contains the
value computed for the previous TC, affecting the validation logic
- The overflow check for rates exceeding 255 Gbps may not trigger
consistently depending on previous array values
This patch ensures the validation correctly examines the requested rate
value for proper bounds checking.
Fixes: 43b27d1bd88a ("net/mlx5e: Fix wraparound in rate limiting for values above 255 Gbps")
Signed-off-by: Danielle Costantino <dcostantino@meta.com>
---
drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
index d88a48210fdc..08b7ca5c3b5e 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c
@@ -614,7 +614,7 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
MLX5E_100MB);
max_bw_value[i] = max_bw_value[i] ? max_bw_value[i] : 1;
max_bw_unit[i] = MLX5_100_MBPS_UNIT;
- } else if (max_bw_value[i] <= upper_limit_gbps) {
+ } else if (maxrate->tc_maxrate[i] <= upper_limit_gbps) {
max_bw_value[i] = div_u64(maxrate->tc_maxrate[i],
MLX5E_1GB);
max_bw_unit[i] = MLX5_GBPS_UNIT;
--
2.47.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net/mlx5e: Fix validation logic in rate limiting
2025-11-24 18:00 [PATCH net] net/mlx5e: Fix validation logic in rate limiting Danielle Costantino
@ 2025-11-24 18:37 ` Gal Pressman
2025-11-26 0:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Gal Pressman @ 2025-11-24 18:37 UTC (permalink / raw)
To: Danielle Costantino, netdev
Cc: kuba, tariqt, pabeni, saeedm, linux-rdma, linux-kernel
On 24/11/2025 20:00, Danielle Costantino wrote:
> The rate limiting validation condition currently checks the output
> variable max_bw_value[i] instead of the input value
> maxrate->tc_maxrate[i]. This causes the validation to compare an
> uninitialized or stale value rather than the actual requested rate.
>
> The condition should check the input rate to properly validate against
> the upper limit:
>
> } else if (maxrate->tc_maxrate[i] <= upper_limit_gbps) {
>
> This aligns with the pattern used in the first branch, which correctly
> checks maxrate->tc_maxrate[i] against upper_limit_mbps.
>
> The current implementation can lead to unreliable validation behavior:
>
> - For rates between 25.5 Gbps and 255 Gbps, if max_bw_value[i] is 0
> from initialization, the GBPS path may be taken regardless of whether
> the actual rate is within bounds
>
> - When processing multiple TCs (i > 0), max_bw_value[i] contains the
> value computed for the previous TC, affecting the validation logic
>
> - The overflow check for rates exceeding 255 Gbps may not trigger
> consistently depending on previous array values
>
> This patch ensures the validation correctly examines the requested rate
> value for proper bounds checking.
>
> Fixes: 43b27d1bd88a ("net/mlx5e: Fix wraparound in rate limiting for values above 255 Gbps")
> Signed-off-by: Danielle Costantino <dcostantino@meta.com>
Thanks Danielle!
Reviewed-by: Gal Pressman <gal@nvidia.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net/mlx5e: Fix validation logic in rate limiting
2025-11-24 18:00 [PATCH net] net/mlx5e: Fix validation logic in rate limiting Danielle Costantino
2025-11-24 18:37 ` Gal Pressman
@ 2025-11-26 0:50 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-26 0:50 UTC (permalink / raw)
To: Danielle Costantino
Cc: netdev, kuba, gal, tariqt, pabeni, saeedm, linux-rdma,
linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Mon, 24 Nov 2025 10:00:43 -0800 you wrote:
> The rate limiting validation condition currently checks the output
> variable max_bw_value[i] instead of the input value
> maxrate->tc_maxrate[i]. This causes the validation to compare an
> uninitialized or stale value rather than the actual requested rate.
>
> The condition should check the input rate to properly validate against
> the upper limit:
>
> [...]
Here is the summary with links:
- [net] net/mlx5e: Fix validation logic in rate limiting
https://git.kernel.org/netdev/net/c/d2099d9f16db
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] 3+ messages in thread
end of thread, other threads:[~2025-11-26 0:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-24 18:00 [PATCH net] net/mlx5e: Fix validation logic in rate limiting Danielle Costantino
2025-11-24 18:37 ` Gal Pressman
2025-11-26 0:50 ` 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