Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
fork
Configure Feed
Select the types of activity you want to include in your feed.
1#!/bin/bash
2# SPDX-License-Identifier: GPL-2.0
3
4CHECK_TC="yes"
5
6# Can be overridden by the configuration file. See lib.sh
7TC_HIT_TIMEOUT=${TC_HIT_TIMEOUT:=1000} # ms
8
9__tc_check_packets()
10{
11 local id=$1
12 local handle=$2
13 local count=$3
14 local operator=$4
15
16 start_time="$(date -u +%s%3N)"
17 while true
18 do
19 cmd_jq "tc -j -s filter show $id" \
20 ".[] | select(.options.handle == $handle) | \
21 select(.options.actions[0].stats.packets $operator $count)" \
22 &> /dev/null
23 ret=$?
24 if [[ $ret -eq 0 ]]; then
25 return $ret
26 fi
27 current_time="$(date -u +%s%3N)"
28 diff=$(expr $current_time - $start_time)
29 if [ "$diff" -gt "$TC_HIT_TIMEOUT" ]; then
30 return 1
31 fi
32 done
33}
34
35tc_check_packets()
36{
37 local id=$1
38 local handle=$2
39 local count=$3
40
41 __tc_check_packets "$id" "$handle" "$count" "=="
42}
43
44tc_check_packets_hitting()
45{
46 local id=$1
47 local handle=$2
48
49 __tc_check_packets "$id" "$handle" 0 ">"
50}