Files
xdp-project-bpf-examples/pping/scripts/cleanup-tc-progs.sh
Simon Sundberg c6751effb0 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>
2023-07-08 16:17:24 +02:00

25 lines
517 B
Bash
Executable File

#!/bin/bash
interface=$1
if [[ -z "$interface" ]]; then
echo "Usage: $0 <interface>"
exit 0
fi
if [[ ! -e "/sys/class/net/$interface" ]]; then
echo "$interface is not a valid interface" 1>&2
exit 1
fi
for trafdir in "ingress" "egress"; do
prios=$(tc filter show dev "$interface" "$trafdir" | grep pping_tc | cut -f 5 -d ' ')
while IFS= read -r p || [[ -n "$p" ]]; do
if [[ "$p" =~ ^[0-9]+ ]]; then
tc filter del dev "$interface" "$trafdir" prio "$p"
fi
done <<< "$prios"
done