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	local ret
12
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
18	fi
19	echo $output | \
20		jq -e ".[] \
21		| select(.options.handle == $handle) \
22		| select(.options.actions[0].stats.packets == $count)" \
23		&> /dev/null
24	return $?
25}
26