diff options
author | Ido Schimmel <idosch@mellanox.com> | 2020-05-21 13:46:16 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-05-23 01:05:42 +0200 |
commit | be43224fc0e4697ad0d03107cbaf1ecf26e7ee72 (patch) | |
tree | 84a142dc5f23911f90d51d26d30717d46391aeae /drivers | |
parent | Merge tag 'rxrpc-fixes-20200520' of git://git.kernel.org/pub/scm/linux/kernel... (diff) | |
download | linux-be43224fc0e4697ad0d03107cbaf1ecf26e7ee72.tar.xz linux-be43224fc0e4697ad0d03107cbaf1ecf26e7ee72.zip |
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: ad188458d012 ("netdevsim: Add devlink-trap policer support")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Reviewed-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/netdevsim/dev.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/net/netdevsim/dev.c b/drivers/net/netdevsim/dev.c index 68668a22b9dd..dc3ff0e20944 100644 --- a/drivers/net/netdevsim/dev.c +++ b/drivers/net/netdevsim/dev.c @@ -858,8 +858,7 @@ nsim_dev_devlink_trap_policer_counter_get(struct devlink *devlink, return -EINVAL; cnt = &nsim_dev->trap_data->trap_policers_cnt_arr[policer->id - 1]; - *p_drops = *cnt; - *cnt += jiffies % 64; + *p_drops = (*cnt)++; return 0; } |