Skip to content

Commit d2099d9

Browse files
costad2kuba-moo
authored andcommitted
net/mlx5e: Fix validation logic in rate limiting
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: 43b27d1 ("net/mlx5e: Fix wraparound in rate limiting for values above 255 Gbps") Signed-off-by: Danielle Costantino <dcostantino@meta.com> Reviewed-by: Gal Pressman <gal@nvidia.com> Link: https://patch.msgid.link/20251124180043.2314428-1-dcostantino@meta.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 9780f53 commit d2099d9

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/net/ethernet/mellanox/mlx5/core/en_dcbnl.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ static int mlx5e_dcbnl_ieee_setmaxrate(struct net_device *netdev,
627627
MLX5E_100MB);
628628
max_bw_value[i] = max_bw_value[i] ? max_bw_value[i] : 1;
629629
max_bw_unit[i] = MLX5_100_MBPS_UNIT;
630-
} else if (max_bw_value[i] <= upper_limit_gbps) {
630+
} else if (maxrate->tc_maxrate[i] <= upper_limit_gbps) {
631631
max_bw_value[i] = div_u64(maxrate->tc_maxrate[i],
632632
MLX5E_1GB);
633633
max_bw_unit[i] = MLX5_GBPS_UNIT;

0 commit comments

Comments
 (0)