[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241108-bpf-next-net-mptcp-bpf_iter-subflows-v1-4-cf16953035c1@kernel.org>
Date: Fri, 08 Nov 2024 16:52:33 +0100
From: "Matthieu Baerts (NGI0)" <matttbe@...nel.org>
To: mptcp@...ts.linux.dev, Mat Martineau <martineau@...nel.org>,
Geliang Tang <geliang@...nel.org>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Simon Horman <horms@...nel.org>,
Alexei Starovoitov <ast@...nel.org>, Daniel Borkmann <daniel@...earbox.net>,
Andrii Nakryiko <andrii@...nel.org>,
Martin KaFai Lau <martin.lau@...ux.dev>,
Eduard Zingerman <eddyz87@...il.com>, 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>, Mykola Lysenko <mykolal@...com>,
Shuah Khan <shuah@...nel.org>
Cc: netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
"Matthieu Baerts (NGI0)" <matttbe@...nel.org>,
Geliang Tang <geliang@...nel.org>
Subject: [PATCH bpf-next/net 4/5] selftests/bpf: More endpoints for
endpoint_init
From: Geliang Tang <tanggeliang@...inos.cn>
This patch changes ADDR_2 from "10.0.1.2" to "10.0.2.1", and adds two more
IPv4 test addresses ADDR_3 - ADDR_4, four IPv6 addresses ADDR6_1 - ADDR6_4.
Add a new helper address_init() to initialize all these addresses.
Add a new parameter "endpoints" for endpoint_init() to control how many
endpoints are used for the tests. This makes it more flexible. Update the
parameters of endpoint_init() in test_subflow().
Signed-off-by: Geliang Tang <tanggeliang@...inos.cn>
Reviewed-by: Mat Martineau <martineau@...nel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@...nel.org>
---
tools/testing/selftests/bpf/prog_tests/mptcp.c | 56 +++++++++++++++++++++++---
1 file changed, 50 insertions(+), 6 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index f8eb7f9d4fd20bbb7ee018728f7ae0f0a09d4d30..85f3d4119802a85c86cde7b74a0b857252bad8b8 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -14,7 +14,13 @@
#define NS_TEST "mptcp_ns"
#define ADDR_1 "10.0.1.1"
-#define ADDR_2 "10.0.1.2"
+#define ADDR_2 "10.0.2.1"
+#define ADDR_3 "10.0.3.1"
+#define ADDR_4 "10.0.4.1"
+#define ADDR6_1 "dead:beef:1::1"
+#define ADDR6_2 "dead:beef:2::1"
+#define ADDR6_3 "dead:beef:3::1"
+#define ADDR6_4 "dead:beef:4::1"
#define PORT_1 10001
#ifndef IPPROTO_MPTCP
@@ -322,22 +328,60 @@ static void test_mptcpify(void)
close(cgroup_fd);
}
-static int endpoint_init(char *flags)
+static int address_init(void)
{
SYS(fail, "ip -net %s link add veth1 type veth peer name veth2", NS_TEST);
SYS(fail, "ip -net %s addr add %s/24 dev veth1", NS_TEST, ADDR_1);
+ SYS(fail, "ip -net %s addr add %s/64 dev veth1 nodad", NS_TEST, ADDR6_1);
SYS(fail, "ip -net %s link set dev veth1 up", NS_TEST);
SYS(fail, "ip -net %s addr add %s/24 dev veth2", NS_TEST, ADDR_2);
+ SYS(fail, "ip -net %s addr add %s/64 dev veth2 nodad", NS_TEST, ADDR6_2);
SYS(fail, "ip -net %s link set dev veth2 up", NS_TEST);
- if (SYS_NOFAIL("ip -net %s mptcp endpoint add %s %s", NS_TEST, ADDR_2, flags)) {
+
+ SYS(fail, "ip -net %s link add veth3 type veth peer name veth4", NS_TEST);
+ SYS(fail, "ip -net %s addr add %s/24 dev veth3", NS_TEST, ADDR_3);
+ SYS(fail, "ip -net %s addr add %s/64 dev veth3 nodad", NS_TEST, ADDR6_3);
+ SYS(fail, "ip -net %s link set dev veth3 up", NS_TEST);
+ SYS(fail, "ip -net %s addr add %s/24 dev veth4", NS_TEST, ADDR_4);
+ SYS(fail, "ip -net %s addr add %s/64 dev veth4 nodad", NS_TEST, ADDR6_4);
+ SYS(fail, "ip -net %s link set dev veth4 up", NS_TEST);
+
+ return 0;
+fail:
+ return -1;
+}
+
+static int endpoint_add(char *addr, char *flags)
+{
+ return SYS_NOFAIL("ip -net %s mptcp endpoint add %s %s", NS_TEST, addr, flags);
+}
+
+static int endpoint_init(char *flags, u8 endpoints)
+{
+ int ret = -1;
+
+ if (!endpoints || endpoints > 4)
+ goto fail;
+
+ if (address_init())
+ goto fail;
+
+ if (SYS_NOFAIL("ip -net %s mptcp limits set add_addr_accepted 4 subflows 4",
+ NS_TEST)) {
printf("'ip mptcp' not supported, skip this test.\n");
test__skip();
goto fail;
}
- return 0;
+ if (endpoints > 1)
+ ret = endpoint_add(ADDR_2, flags);
+ if (endpoints > 2)
+ ret = ret ?: endpoint_add(ADDR_3, flags);
+ if (endpoints > 3)
+ ret = ret ?: endpoint_add(ADDR_4, flags);
+
fail:
- return -1;
+ return ret;
}
static void wait_for_new_subflows(int fd)
@@ -423,7 +467,7 @@ static void test_subflow(void)
if (!ASSERT_OK_PTR(netns, "netns_new: mptcp_subflow"))
goto skel_destroy;
- if (endpoint_init("subflow") < 0)
+ if (endpoint_init("subflow", 2) < 0)
goto close_netns;
run_subflow();
--
2.45.2
Powered by blists - more mailing lists