2018-02-28 12:25:16 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
2018-03-01 13:49:30 -08:00
|
|
|
CHECK_TC="yes"
|
|
|
|
|
|
2019-11-28 13:38:57 +01:00
|
|
|
# Can be overridden by the configuration file. See lib.sh
|
|
|
|
|
TC_HIT_TIMEOUT=${TC_HIT_TIMEOUT:=1000} # ms
|
|
|
|
|
|
2018-02-28 12:25:16 +02:00
|
|
|
tc_check_packets()
|
|
|
|
|
{
|
|
|
|
|
local id=$1
|
|
|
|
|
local handle=$2
|
|
|
|
|
local count=$3
|
|
|
|
|
|
2020-03-02 19:56:04 +02:00
|
|
|
busywait "$TC_HIT_TIMEOUT" until_counter_is "== $count" \
|
|
|
|
|
tc_rule_handle_stats_get "$id" "$handle" > /dev/null
|
2018-02-28 12:25:16 +02:00
|
|
|
}
|
2019-11-07 18:42:19 +02:00
|
|
|
|
2021-10-08 16:12:35 +03:00
|
|
|
tc_check_at_least_x_packets()
|
|
|
|
|
{
|
|
|
|
|
local id=$1
|
|
|
|
|
local handle=$2
|
|
|
|
|
local count=$3
|
|
|
|
|
|
|
|
|
|
busywait "$TC_HIT_TIMEOUT" until_counter_is ">= $count" \
|
|
|
|
|
tc_rule_handle_stats_get "$id" "$handle" > /dev/null
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-07 18:42:19 +02:00
|
|
|
tc_check_packets_hitting()
|
|
|
|
|
{
|
|
|
|
|
local id=$1
|
|
|
|
|
local handle=$2
|
|
|
|
|
|
2020-03-02 19:56:04 +02:00
|
|
|
busywait "$TC_HIT_TIMEOUT" until_counter_is "> 0" \
|
|
|
|
|
tc_rule_handle_stats_get "$id" "$handle" > /dev/null
|
2019-11-07 18:42:19 +02:00
|
|
|
}
|