xref: /linux/tools/testing/selftests/net/forwarding/tc_common.sh (revision 4d66c56f7efe122d09d06cd3ebfa52a43d51a9cb)
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4CHECK_TC="yes"
5
6tc_check_packets()
7{
8	local id=$1
9	local handle=$2
10	local count=$3
11
12	cmd_jq "tc -j -s filter show $id" \
13	       ".[] | select(.options.handle == $handle) | \
14	              select(.options.actions[0].stats.packets == $count)" \
15	       &> /dev/null
16}
17
18tc_check_packets_hitting()
19{
20	local id=$1
21	local handle=$2
22
23	cmd_jq "tc -j -s filter show $id" \
24	       ".[] | select(.options.handle == $handle) | \
25		      select(.options.actions[0].stats.packets > 0)" \
26	       &> /dev/null
27}
28