Skip to content

Commit dc97520

Browse files
Amit Cohenkuba-moo
authored andcommitted
selftests: mlxsw: tc_police_scale: Make test more robust
The test adds tc filters and checks how many of them were offloaded by grepping for 'in_hw'. iproute2 commit f4cd4f127047 ("tc: add skip_hw and skip_sw to control action offload") added offload indication to tc actions, producing the following output: $ tc filter show dev swp2 ingress ... filter protocol ipv6 pref 1000 flower chain 0 handle 0x7c0 eth_type ipv6 dst_ip 2001:db8:1::7bf skip_sw in_hw in_hw_count 1 action order 1: police 0x7c0 rate 10Mbit burst 100Kb mtu 2Kb action drop overhead 0b ref 1 bind 1 not_in_hw used_hw_stats immediate The current grep expression matches on both 'in_hw' and 'not_in_hw', resulting in incorrect results. Fix that by using JSON output instead. Fixes: 5061e77 ("selftests: mlxsw: Add scale test for tc-police") Signed-off-by: Amit Cohen <amcohen@nvidia.com> Reviewed-by: Petr Machata <petrm@nvidia.com> Signed-off-by: Ido Schimmel <idosch@nvidia.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 10b6bb6 commit dc97520

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

tools/testing/selftests/drivers/net/mlxsw/tc_police_scale.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@ __tc_police_test()
6060

6161
tc_police_rules_create $count $should_fail
6262

63-
offload_count=$(tc filter show dev $swp1 ingress | grep in_hw | wc -l)
63+
offload_count=$(tc -j filter show dev $swp1 ingress |
64+
jq "[.[] | select(.options.in_hw == true)] | length")
6465
((offload_count == count))
6566
check_err_fail $should_fail $? "tc police offload count"
6667
}

0 commit comments

Comments
 (0)