Skip to content

Commit c6751ef

Browse files
committed
pping: Add script for cleaing up leftover tc programs
In case ePPing is not shut down cleanly (ex. when killed with SIGKILL or OOM killer) it will not be able to detach its eBPF programs, may remain attached and waste resources. Add a script which can be used to clean up any remaining programs tc-eBPF programs. Note, this script should not be run while the any instace of pping is still running, as that will remove its tc programs and thus its ability to function properly. Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
1 parent 6582f67 commit c6751ef

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pping/scripts/cleanup-tc-progs.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/bin/bash
2+
3+
interface=$1
4+
5+
if [[ -z "$interface" ]]; then
6+
echo "Usage: $0 <interface>"
7+
exit 0
8+
fi
9+
10+
if [[ ! -e "/sys/class/net/$interface" ]]; then
11+
echo "$interface is not a valid interface" 1>&2
12+
exit 1
13+
fi
14+
15+
for trafdir in "ingress" "egress"; do
16+
prios=$(tc filter show dev "$interface" "$trafdir" | grep pping_tc | cut -f 5 -d ' ')
17+
18+
while IFS= read -r p || [[ -n "$p" ]]; do
19+
if [[ "$p" =~ ^[0-9]+ ]]; then
20+
tc filter del dev "$interface" "$trafdir" prio "$p"
21+
fi
22+
done <<< "$prios"
23+
24+
done

0 commit comments

Comments
 (0)