summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMagnus Karlsson <magnus.karlsson@intel.com>2022-05-10 13:56:01 +0200
committerAlexei Starovoitov <ast@kernel.org>2022-05-11 08:03:16 -0700
commitd41cb6c47474484c647933702e9fa8fb5054cdf2 (patch)
tree62953b8fe60f8ad060d646a68bb64d346f868e15 /tools
parentdb1bd7a99454db5d9003ddcd64e771e265170f5b (diff)
downloadlinux-d41cb6c47474484c647933702e9fa8fb5054cdf2.tar.bz2
selftests: xsk: cleanup veth pair at ctrl-c
Remove the veth pair when the tests are aborted by pressing ctrl-c. Currently in this situation, the veth pair is left on the system polluting the netdev space. Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Link: https://lore.kernel.org/r/20220510115604.8717-7-magnus.karlsson@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/testing/selftests/bpf/test_xsk.sh7
1 files changed, 7 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/test_xsk.sh b/tools/testing/selftests/bpf/test_xsk.sh
index d06215ee843d..567500299231 100755
--- a/tools/testing/selftests/bpf/test_xsk.sh
+++ b/tools/testing/selftests/bpf/test_xsk.sh
@@ -97,6 +97,13 @@ NS0=root
NS1=af_xdp${VETH1_POSTFIX}
MTU=1500
+trap ctrl_c INT
+
+function ctrl_c() {
+ cleanup_exit ${VETH0} ${VETH1} ${NS1}
+ exit 1
+}
+
setup_vethPairs() {
if [[ $verbose -eq 1 ]]; then
echo "setting up ${VETH0}: namespace: ${NS0}"