]> git.itanic.dy.fi Git - linux-stable/commitdiff
selftests: forwarding: lib: add netns support for tc rule handle stats get
authorHangbin Liu <liuhangbin@gmail.com>
Tue, 9 May 2023 03:11:59 +0000 (11:11 +0800)
committerDavid S. Miller <davem@davemloft.net>
Wed, 10 May 2023 08:27:20 +0000 (09:27 +0100)
When run the test in netns, it's not easy to get the tc stats via
tc_rule_handle_stats_get(). With the new netns parameter, we can get
stats from specific netns like

  num=$(tc_rule_handle_stats_get "dev eth0 ingress" 101 ".packets" "-n ns")

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
tools/testing/selftests/net/forwarding/lib.sh

index 057c3d0ad62054f767bb2785232bbb25d8f1cf24..9ddb68dd6a089a42239554e4bd670000290f5b49 100755 (executable)
@@ -791,8 +791,9 @@ tc_rule_handle_stats_get()
        local id=$1; shift
        local handle=$1; shift
        local selector=${1:-.packets}; shift
+       local netns=${1:-""}; shift
 
-       tc -j -s filter show $id \
+       tc $netns -j -s filter show $id \
            | jq ".[] | select(.options.handle == $handle) | \
                  .options.actions[0].stats$selector"
 }