From: Petr Machata Date: Mon, 2 Mar 2020 17:56:02 +0000 (+0200) Subject: selftests: forwarding: lib: Add tc_rule_handle_stats_get() X-Git-Tag: block-5.7-2020-04-09~9^2~258^2~3 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=84ea1f8541721c1852bc95f4d50a603c661eabc6;p=linux-block.git selftests: forwarding: lib: Add tc_rule_handle_stats_get() The function tc_rule_stats_get() fetches a given statistic of a TC rule given the rule preference. Another common way to reference a rule is using its handle. Introduce a dual to the aforementioned function that gets a statistic given rule handle. Signed-off-by: Petr Machata Reviewed-by: Amit Cohen Signed-off-by: David S. Miller --- diff --git a/tools/testing/selftests/net/forwarding/lib.sh b/tools/testing/selftests/net/forwarding/lib.sh index 83fd15e3e545..de57e8887a7c 100644 --- a/tools/testing/selftests/net/forwarding/lib.sh +++ b/tools/testing/selftests/net/forwarding/lib.sh @@ -626,6 +626,17 @@ tc_rule_stats_get() | jq ".[1].options.actions[].stats$selector" } +tc_rule_handle_stats_get() +{ + local id=$1; shift + local handle=$1; shift + local selector=${1:-.packets}; shift + + tc -j -s filter show $id \ + | jq ".[] | select(.options.handle == $handle) | \ + .options.actions[0].stats$selector" +} + ethtool_stats_get() { local dev=$1; shift