Skip to content

Commit

Permalink
testing: selftests: net: forwarding: add devlink-required functionali…
Browse files Browse the repository at this point in the history
…ty to test (hard) dropped stats field

Add devlink_trap_drop_packets_get function, as well as test that are
used to verify devlink (hard) dropped stats functionality works.

Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Oleksandr Mazur authored and David S. Miller committed Jun 14, 2021
1 parent ddee9db commit 53f1bd6
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tools/testing/selftests/net/forwarding/devlink_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,14 @@ devlink_trap_rx_bytes_get()
| jq '.[][][]["stats"]["rx"]["bytes"]'
}

devlink_trap_drop_packets_get()
{
local trap_name=$1; shift

devlink -js trap show $DEVLINK_DEV trap $trap_name \
| jq '.[][][]["stats"]["rx"]["dropped"]'
}

devlink_trap_stats_idle_test()
{
local trap_name=$1; shift
Expand All @@ -345,6 +353,24 @@ devlink_trap_stats_idle_test()
fi
}

devlink_trap_drop_stats_idle_test()
{
local trap_name=$1; shift
local t0_packets t0_bytes

t0_packets=$(devlink_trap_drop_packets_get $trap_name)

sleep 1

t1_packets=$(devlink_trap_drop_packets_get $trap_name)

if [[ $t0_packets -eq $t1_packets ]]; then
return 0
else
return 1
fi
}

devlink_traps_enable_all()
{
local trap_name
Expand Down

0 comments on commit 53f1bd6

Please sign in to comment.