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 <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Apr 24, 2024
1 parent 6af2fa0 commit 0890264
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,18 @@ struct mptcp_storage {
char ca_name[TCP_CA_NAME_MAX];
};

static void sig_int(int sig)
{
signal(sig, SIG_IGN);
SYS_NOFAIL("ip netns del %s", NS_TEST);
}

static struct nstoken *create_netns(void)
{
SYS(fail, "ip netns add %s", NS_TEST);
SYS(fail, "ip -net %s link set dev lo up", NS_TEST);

signal(SIGINT, sig_int);
return open_netns(NS_TEST);
fail:
return NULL;
Expand Down

0 comments on commit 0890264

Please sign in to comment.