Skip to content

Commit be43224

Browse files
idoschdavem330
authored andcommitted
netdevsim: Ensure policer drop counter always increases
In case the policer drop counter is retrieved when the jiffies value is a multiple of 64, the counter will not be incremented. This randomly breaks a selftest [1] the reads the counter twice and checks that it was incremented: ``` TEST: Trap policer [FAIL] Policer drop counter was not incremented ``` Fix by always incrementing the counter by 1. [1] tools/testing/selftests/drivers/net/netdevsim/devlink_trap.sh Fixes: ad18845 ("netdevsim: Add devlink-trap policer support") Signed-off-by: Ido Schimmel <[email protected]> Reviewed-by: Jiri Pirko <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 4629ed2 commit be43224

File tree

1 file changed

+1
-2
lines changed
  • drivers/net/netdevsim

1 file changed

+1
-2
lines changed

drivers/net/netdevsim/dev.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -858,8 +858,7 @@ nsim_dev_devlink_trap_policer_counter_get(struct devlink *devlink,
858858
return -EINVAL;
859859

860860
cnt = &nsim_dev->trap_data->trap_policers_cnt_arr[policer->id - 1];
861-
*p_drops = *cnt;
862-
*cnt += jiffies % 64;
861+
*p_drops = (*cnt)++;
863862

864863
return 0;
865864
}

0 commit comments

Comments
 (0)