From 819528b430e85afe01b48b69f104f39939d5de5c Mon Sep 17 00:00:00 2001 From: Geliang Tang Date: Mon, 13 May 2024 17:44:25 +0800 Subject: [PATCH] selftests/bpf: Handle SIGINT when creating netns It's necessary to delete netns during the MPTCP bpf tests interrupt, otherwise the next tests run will fail due to unable to create netns. This patch adds a new SIGINT handle sig_int, and deletes NS_TEST in it. Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau --- tools/testing/selftests/bpf/network_helpers.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/selftests/bpf/network_helpers.c index e7b136f22d1e..cd6d77c722c8 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -693,6 +693,12 @@ void del_netns(struct nstoken *token, const char *name) log_err("del netns %s failed", name); } +static void sig_int(int sig) +{ + signal(sig, SIG_IGN); +// del_netns(token, name); +} + struct nstoken *add_netns(const char *name) { if (SYS_NOFAIL("ip netns add %s", name)) { @@ -706,5 +712,6 @@ struct nstoken *add_netns(const char *name) return NULL; } + signal(SIGINT, sig_int); return open_netns(name); }