mirror of
https://github.com/xdp-project/bpf-examples.git
synced 2024-05-06 15:54:53 +00:00
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>
25 lines
517 B
Bash
Executable File
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
|