Linux 4.19.133
[linux/fpc-iii.git] / tools / testing / selftests / net / forwarding / tc_common.sh
blob9d3b64a2a26427280ecb46b2c64a08f9752a06b2
1 #!/bin/bash
2 # SPDX-License-Identifier: GPL-2.0
4 CHECK_TC="yes"
6 tc_check_packets()
8 local id=$1
9 local handle=$2
10 local count=$3
11 local ret
13 output="$(tc -j -s filter show $id)"
14 # workaround the jq bug which causes jq to return 0 in case input is ""
15 ret=$?
16 if [[ $ret -ne 0 ]]; then
17 return $ret
19 echo $output | \
20 jq -e ".[] \
21 | select(.options.handle == $handle) \
22 | select(.options.actions[0].stats.packets == $count)" \
23 &> /dev/null
24 return $?