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); }