netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: Matthieu Baerts <matthieu.baerts@tessares.net>
Cc: Martin KaFai Lau <martin.lau@linux.dev>,
	netdev@vger.kernel.org, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>,
	"David S . Miller" <davem@davemloft.net>,
	Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>,
	Felix Maurer <fmaurer@redhat.com>,
	Davide Caratti <dcaratti@redhat.com>
Subject: Re: [PATCH bpf] selftests/bpf: enable mptcp before testing
Date: Thu, 16 Feb 2023 16:13:53 +0800	[thread overview]
Message-ID: <Y+3lwZChsI0Trok8@Laptop-X1> (raw)
In-Reply-To: <a7331a33-fc1f-f74b-4df6-df9483c81125@tessares.net>

On Wed, Feb 15, 2023 at 10:58:20AM +0100, Matthieu Baerts wrote:
> Hi Hangbin, Martin,
>
> Thank you both for your replies!
> 
> Yes, that would be good to have this test running in a dedicated NS.
> 
> Then mptcp.enabled can be forced using write_sysctl() or SYS("sysctl (...)".
> 

Hi Matt, Martin,

I tried to set make mptcp test in netns, like decap_sanity.c does. But I got
error when delete the netns. e.g.

# ./test_progs -t mptcp
Cannot remove namespace file "/var/run/netns/mptcp_ns": Device or resource busy
#127/1   mptcp/base:OK
#127     mptcp:OK
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED

Do you have any idea why I can't remove the netns? Here is the draft patch:

diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index 59f08d6d1d53..5ad10a860994 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -7,6 +7,16 @@
 #include "network_helpers.h"
 #include "mptcp_sock.skel.h"
 
+#define SYS(fmt, ...)						\
+	({							\
+		char cmd[1024];					\
+		snprintf(cmd, sizeof(cmd), fmt, ##__VA_ARGS__);	\
+		if (!ASSERT_OK(system(cmd), cmd))		\
+			goto fail;				\
+	})
+
+#define NS_TEST "mptcp_ns"
+
 #ifndef TCP_CA_NAME_MAX
 #define TCP_CA_NAME_MAX	16
 #endif
@@ -169,6 +179,22 @@ static void test_base(void)
 
 void test_mptcp(void)
 {
+	struct nstoken *nstoken = NULL;
+
+	SYS("ip netns add %s", NS_TEST);
+	SYS("ip -net %s link set dev lo up", NS_TEST);
+
+	nstoken = open_netns(NS_TEST);
+	if (!ASSERT_OK_PTR(nstoken, "open_netns"))
+		goto fail;
+
 	if (test__start_subtest("base"))
 		test_base();
+
+fail:
+	if (nstoken)
+		close_netns(nstoken);
+
+	//system("ip netns del " NS_TEST " >& /dev/null");
+	system("ip netns del " NS_TEST);
 }

  reply	other threads:[~2023-02-16  8:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-10  9:32 [PATCH bpf] selftests/bpf: enable mptcp before testing Hangbin Liu
2023-02-10 16:22 ` Matthieu Baerts
2023-02-13  4:10   ` Hangbin Liu
2023-02-13 16:28     ` Matthieu Baerts
2023-02-14  3:11       ` Hangbin Liu
2023-02-14 19:22         ` Martin KaFai Lau
2023-02-15  3:43           ` Hangbin Liu
2023-02-15  9:58             ` Matthieu Baerts
2023-02-16  8:13               ` Hangbin Liu [this message]
2023-02-17  7:04                 ` Martin KaFai Lau
2023-02-17  7:35                   ` Hangbin Liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y+3lwZChsI0Trok8@Laptop-X1 \
    --to=liuhangbin@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=dcaratti@redhat.com \
    --cc=fmaurer@redhat.com \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=matthieu.baerts@tessares.net \
    --cc=mykolal@fb.com \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).