Skip to content

Commit

Permalink
selftests/bpf: Handle SIGINT when creating netns
Browse files Browse the repository at this point in the history
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 <tanggeliang@kylinos.cn>
Reviewed-by: Mat Martineau <martineau@kernel.org>
  • Loading branch information
Geliang Tang committed May 13, 2024
1 parent d9658a0 commit 819528b
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/testing/selftests/bpf/network_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -706,5 +712,6 @@ struct nstoken *add_netns(const char *name)
return NULL;
}

signal(SIGINT, sig_int);
return open_netns(name);
}

0 comments on commit 819528b

Please sign in to comment.