Skip to content

Commit

Permalink
selftests: forwarding: tc_common: Add hitting check
Browse files Browse the repository at this point in the history
Add an option to check that packets hit the tc filter without providing
the exact number of packets that should hit it.

It is useful while sending many packets in background and checking that
at least one of them hit the tc filter.

Signed-off-by: Amit Cohen <amitc@mellanox.com>
Acked-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Amit Cohen authored and David S. Miller committed Nov 8, 2019
1 parent 7ce4e76 commit f10caf0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tools/testing/selftests/net/forwarding/tc_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ tc_check_packets()
select(.options.actions[0].stats.packets == $count)" \
&> /dev/null
}

tc_check_packets_hitting()
{
local id=$1
local handle=$2

cmd_jq "tc -j -s filter show $id" \
".[] | select(.options.handle == $handle) | \
select(.options.actions[0].stats.packets > 0)" \
&> /dev/null
}

0 comments on commit f10caf0

Please sign in to comment.