From: Geliang Tang <[email protected]>
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]>
Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
---
tools/testing/selftests/bpf/prog_tests/mptcp.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index 274d2e033e39..baf976a7a1dd 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -64,11 +64,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;
--
2.43.0
On Tue, May 7, 2024 at 3:53 AM Matthieu Baerts (NGI0)
<[email protected]> wrote:
>
> From: Geliang Tang <[email protected]>
>
> 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]>
> Reviewed-by: Mat Martineau <[email protected]>
> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
> ---
> tools/testing/selftests/bpf/prog_tests/mptcp.c | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
> index 274d2e033e39..baf976a7a1dd 100644
> --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
> +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
> @@ -64,11 +64,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);
That's a drop in the bucket.
ctrl-c of test_progs doesn't really work.
Such clean up needs to be generic as part of network_helpers.c
Hi Alexei,
Thank you for the review!
On 07/05/2024 16:43, Alexei Starovoitov wrote:
> On Tue, May 7, 2024 at 3:53 AM Matthieu Baerts (NGI0)
> <[email protected]> wrote:
>>
>> From: Geliang Tang <[email protected]>
>>
>> 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]>
>> Reviewed-by: Mat Martineau <[email protected]>
>> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]>
>> ---
>> tools/testing/selftests/bpf/prog_tests/mptcp.c | 7 +++++++
>> 1 file changed, 7 insertions(+)
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
>> index 274d2e033e39..baf976a7a1dd 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
>> @@ -64,11 +64,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);
>
> That's a drop in the bucket.
> ctrl-c of test_progs doesn't really work.
> Such clean up needs to be generic as part of network_helpers.c
It makes sense. I can drop this patch and ask Geliang to add a similar
'create_netns()' helper in network_helpers.c creating the netns, and
handling SIGINT. This helper will no longer be specific to MPTCP BPF
selftests then.
Cheers,
Matt
--
Sponsored by the NGI0 Core fund.