[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <99e57c7470ac338da18f02ef3af5936c8b21f5a7.1729757268.git.tanggeliang@kylinos.cn>
Date: Thu, 24 Oct 2024 16:11:20 +0800
From: Geliang Tang <geliang@...nel.org>
To: Andrii Nakryiko <andrii@...nel.org>,
Eduard Zingerman <eddyz87@...il.com>,
Mykola Lysenko <mykolal@...com>,
Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Song Liu <song@...nel.org>,
Yonghong Song <yonghong.song@...ux.dev>,
John Fastabend <john.fastabend@...il.com>,
KP Singh <kpsingh@...nel.org>,
Stanislav Fomichev <sdf@...ichev.me>,
Hao Luo <haoluo@...gle.com>,
Jiri Olsa <jolsa@...nel.org>,
Shuah Khan <shuah@...nel.org>
Cc: Geliang Tang <tanggeliang@...inos.cn>,
netdev@...r.kernel.org,
mptcp@...ts.linux.dev,
bpf@...r.kernel.org,
linux-kselftest@...r.kernel.org,
Matthieu Baerts <matttbe@...nel.org>
Subject: [PATCH bpf-next] selftests/bpf: Use make/remove netns helpers in mptcp
From: Geliang Tang <tanggeliang@...inos.cn>
New netns selftest helpers make_netns() and remove_netns() has been added
in network_helpers.c, let's use them in mptcp selftests too.
Signed-off-by: Geliang Tang <tanggeliang@...inos.cn>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@...nel.org>
---
tools/testing/selftests/bpf/prog_tests/mptcp.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index d2ca32fa3b21..8276398f7d6a 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -66,12 +66,18 @@ struct mptcp_storage {
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);
+ struct nstoken *nstoken;
- return open_netns(NS_TEST);
-fail:
- return NULL;
+ if (make_netns(NS_TEST) < 0)
+ return NULL;
+
+ nstoken = open_netns(NS_TEST);
+ if (!nstoken) {
+ log_err("open netns %s failed", NS_TEST);
+ remove_netns(NS_TEST);
+ }
+
+ return nstoken;
}
static void cleanup_netns(struct nstoken *nstoken)
@@ -79,7 +85,7 @@ static void cleanup_netns(struct nstoken *nstoken)
if (nstoken)
close_netns(nstoken);
- SYS_NOFAIL("ip netns del %s", NS_TEST);
+ remove_netns(NS_TEST);
}
static int start_mptcp_server(int family, const char *addr_str, __u16 port,
--
2.45.2
Powered by blists - more mailing lists