From nobody Sun Dec 22 01:45:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 796B81917CB for ; Sun, 22 Sep 2024 01:00:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726966833; cv=none; b=SWt1nfl6f45slRTq4Zz4S+oFAi/pq+aqTgf4VjuGqrW+AAp2JyqcRvL0uypkti7oikmDFoLpGtTw4H8ZRLw6JYQ+QQyGfinMKmA5XcfXCuzOZcMSI3/XkMO2qEljpcBmOPdgoMvZwFGcPpLDe02wCZRaZJtnTc7t9eljKxnPttI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726966833; c=relaxed/simple; bh=JrjP+cxxwQctHpBi6PyjZFtDkVVFpWStd9Gbslehly0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c31bK5W8FfyiBPU8dIhnP0A0GpK6pKxyVDWEGPR8l1cQRyuN+erscsir97FjuPX+JdljlRN0W6aXaelFqqcrcPor00ZdicQmBiFtTJ3Dx9jxuG5X1M7fY3pi/xgmIqEpIIlvtz4C86jKe6XMb12usXwfvw9uAKYo5Q7x9Ta0D6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Fw+yn29N; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Fw+yn29N" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16E3CC4CEC6; Sun, 22 Sep 2024 01:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726966833; bh=JrjP+cxxwQctHpBi6PyjZFtDkVVFpWStd9Gbslehly0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Fw+yn29NqbG6ChUtcYwCKeFRwmY9x+2qDYq8+J7L4WVoIrWL2WnDAxfasC89onOmY PYFzS6PrEPpCe7YTfES45MSufzFUOadEH2WWUniZCQhIeVdaujaJChQPopCgqGRAUQ 11d+H7fr96ElQVf7fPa0BDbiUY+oJWe8UpbzfCq2tr62ubTFCXYcY84uyon7Q/87Xt P9yNaYy0iFsFy9LBqMz7WQ4nWde2GxkoF8f+x9oe0k2DmYCrwPybhd4o2zrney50fA dWdyRCEVkrOyA572g4sosE4Jbe29G89z/4hoxulW474nxeUg/7EmGOQXiiuV0mcosS b8iMKQuCSJH9w== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 1/3] Squash to "selftests/bpf: Add getsockopt to inspect mptcp subflow" Date: Sun, 22 Sep 2024 09:00:24 +0800 Message-ID: <351e163948d4d7fb1608585074561f56730d18f3.1726966638.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Use can_loop instead of cond_break as Martin suggested. Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/progs/mptcp_bpf.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf.h b/tools/testing/= selftests/bpf/progs/mptcp_bpf.h index 928a1e5ad8db..c3800f986ae1 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf.h +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf.h @@ -26,10 +26,10 @@ static inline int list_is_head(const struct list_head *= list, #define list_entry_is_head(pos, head, member) \ list_is_head(&pos->member, (head)) =20 -/* small difference: 'cond_break' has been added in the conditions */ +/* small difference: 'can_loop' has been added in the conditions */ #define list_for_each_entry(pos, head, member) \ for (pos =3D list_first_entry(head, typeof(*pos), member); \ - cond_break, !list_entry_is_head(pos, head, member); \ + !list_entry_is_head(pos, head, member) && can_loop; \ pos =3D list_next_entry(pos, member)) =20 /* mptcp helpers from protocol.h */ --=20 2.43.0 From nobody Sun Dec 22 01:45:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 06B581917C2 for ; Sun, 22 Sep 2024 01:00:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726966835; cv=none; b=iqVbol5NU8gXlaFTZJhZNkWtcDq3EzV52JgnVSaLCv2Nwyx528mwd+Z9SmHjgYpGOGKuc2f/5cgN1vqQiedjl4Lb9H30gH8R0EhqcNJHzNDbccjywVJu/bN6vkwy58uSQwaMtHkCXuFv8asa54mC63Hx2O29VfFFVsPxk4vtLmk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726966835; c=relaxed/simple; bh=/MQGSpgqw0c9AYsABsR9NU/ONy1mjNkY/DivCQWUUuc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Oza64VqIQQPB8kqXNWhHj1HnVhb31k23aWTE/Mh/zHHIoi51Crt9FEYjtI4bIA1JiBWzeGzlfsmZ8FYr5TjcFsbpxY2U/Dm9qsMa4T6fdwWTfQ+n/zPA2xKNtoaTBW6RvitykCRfyfUWD5Tb7QqK5rDKzhtOAF0A/0FhK03TnvE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nJi+NTny; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nJi+NTny" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 96610C4CEC2; Sun, 22 Sep 2024 01:00:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726966834; bh=/MQGSpgqw0c9AYsABsR9NU/ONy1mjNkY/DivCQWUUuc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nJi+NTny6ZmbRrQ0WiW5XhK+NntZCFmrFef83/1rOuN5bZvFhr61jUxsEdmkdRR3r AWgNbEtn9VRDsIOl68NjMAmw2TLN4TqOn3avWCncudtLneGwFDD0g7m2XG1/eGxV1c 19VuV4mggAqNNQoqJqsD2NvLWXT5DK/MaM/F2EKn7Ntr6lusIClNtm8AmV0uouo5+p yq6h8+gCPRF3fiQUuE6DFCctf90nP50KLhOBNspcOWfvT5J87e6M5FOX5pwu5UQsqv 0fyhXvtapIiLPBSlm33PDIwntcN2pEHCY4ENJYrzhHWFdA+K9qfdITUTaNUwIeAnsy +CD+5e80AXXrQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 2/3] Squash to "selftests/bpf: Add mptcp subflow subtest" Date: Sun, 22 Sep 2024 09:00:25 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Address Martin's comments: Drop mptcp_subflow__attach. Use bpf_program__attach_cgroup instead of bpf_prog_attach. Use the skel->links.{mptcp_subflow, _getsockopt_subflow}, instead of declar= ing a local "link". More subflows for endpoint_init: Add two more test addresses ADDR_3 and ADDR_4, and adds a new parameter "subflows" for endpoint_init() to control how many subflows are used for the tests. This makes it more flexible. Update the parameters of endpoint_init() in test_subflow(). Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 56 +++++++++++++------ 1 file changed, 38 insertions(+), 18 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index a3e68bc6afa3..167fd9b190ee 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -20,6 +20,8 @@ #define NS_TEST "mptcp_ns" #define ADDR_1 "10.0.1.1" #define ADDR_2 "10.0.1.2" +#define ADDR_3 "10.0.1.3" +#define ADDR_4 "10.0.1.4" #define PORT_1 10001 #define WITH_DATA true #define WITHOUT_DATA false @@ -351,22 +353,46 @@ static void test_mptcpify(void) close(cgroup_fd); } =20 -static int endpoint_init(char *flags) +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 subflows) +{ + int ret =3D -1; + + if (!subflows || subflows > 4) + goto fail; + 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 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 link set dev veth2 up", NS_TEST); - if (SYS_NOFAIL("ip -net %s mptcp endpoint add %s %s", NS_TEST, ADDR_2, fl= ags)) { + + 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 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 link set dev veth4 up", NS_TEST); + + if (SYS_NOFAIL("ip -net %s mptcp limits set subflows 4", NS_TEST)) { printf("'ip mptcp' not supported, skip this test.\n"); test__skip(); goto fail; } =20 - return 0; + if (subflows > 1) + ret =3D endpoint_add(ADDR_2, flags); + if (subflows > 2) + ret =3D ret ?: endpoint_add(ADDR_3, flags); + if (subflows > 3) + ret =3D ret ?: endpoint_add(ADDR_4, flags); + fail: - return -1; + return ret; } =20 static void wait_for_new_subflows(int fd) @@ -424,10 +450,9 @@ static void run_subflow(void) =20 static void test_subflow(void) { - int cgroup_fd, prog_fd, err; struct mptcp_subflow *skel; struct nstoken *nstoken; - struct bpf_link *link; + int cgroup_fd; =20 cgroup_fd =3D test__join_cgroup("/mptcp_subflow"); if (!ASSERT_OK_FD(cgroup_fd, "join_cgroup: mptcp_subflow")) @@ -439,30 +464,25 @@ static void test_subflow(void) =20 skel->bss->pid =3D getpid(); =20 - err =3D mptcp_subflow__attach(skel); - if (!ASSERT_OK(err, "skel_attach: mptcp_subflow")) + skel->links.mptcp_subflow =3D + bpf_program__attach_cgroup(skel->progs.mptcp_subflow, cgroup_fd); + if (!ASSERT_OK_PTR(skel->links.mptcp_subflow, "attach mptcp_subflow")) goto skel_destroy; =20 - prog_fd =3D bpf_program__fd(skel->progs.mptcp_subflow); - err =3D bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_SOCK_OPS, 0); - if (!ASSERT_OK(err, "prog_attach")) + skel->links._getsockopt_subflow =3D + bpf_program__attach_cgroup(skel->progs._getsockopt_subflow, cgroup_fd); + if (!ASSERT_OK_PTR(skel->links._getsockopt_subflow, "attach _getsockopt_s= ubflow")) goto skel_destroy; =20 nstoken =3D create_netns(); if (!ASSERT_OK_PTR(nstoken, "create_netns: mptcp_subflow")) goto skel_destroy; =20 - if (endpoint_init("subflow") < 0) - goto close_netns; - - link =3D bpf_program__attach_cgroup(skel->progs._getsockopt_subflow, - cgroup_fd); - if (!ASSERT_OK_PTR(link, "getsockopt prog")) + if (endpoint_init("subflow", 2) < 0) goto close_netns; =20 run_subflow(); =20 - bpf_link__destroy(link); close_netns: cleanup_netns(nstoken); skel_destroy: --=20 2.43.0 From nobody Sun Dec 22 01:45:02 2024 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 88D04190698 for ; Sun, 22 Sep 2024 01:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726966836; cv=none; b=ufxZ5Y7RX0y/zuEXpXXpX+6vd2g+HyDw2qy+S2Y7Mf6TIuXZzJhBi2pRnm8ftASQBVJ46hFrOMPU/IIHwe13ue5+fH8H4GAd7KagCxZ3KRsvYDJFu26/WbxuB/HeAfLAMjrqF6I3+4V1XZyVa9s+rKknlEXjwpCc5mmr/HiJIA0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726966836; c=relaxed/simple; bh=VQkYMAg6fPp0mqgu9jr2BbIZlBVoYwxDaG6eJp/GiQM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mK/XNw2hFE6ifG2D0F2W3iQYGwzwPyyb0JCdUaRKhCCxOTtf3mTNp3HT4itCdtgXf0MkmdqrhmdwSXPk6HEMnExpcPcq6u6+xTtLOsBZnY2xbg292olPiQSSk7zjldMVemL/akb/jnzU75w+XILfSVlu+jegdFDFgKne3Uvl//8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WpEAQ/1z; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WpEAQ/1z" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0FC82C4CECD; Sun, 22 Sep 2024 01:00:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726966836; bh=VQkYMAg6fPp0mqgu9jr2BbIZlBVoYwxDaG6eJp/GiQM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WpEAQ/1zNyP9dhobLsXdHSjipJTY5h2dcZOSadRsvi6rvCVKHu5K3zXi9Ma30+V10 HkHsfUDKQR0SaH/qz2nv1h1lbaAxjK8hYwakGPFX7vTmfCO5LPner72XjXxj7p0Jmr ZrIBVfwK482fnqq7Jm5HOIJFvVyWmA0vrYKdfAXNfMJ/I+JFv6IeC58ZjTXmacmLxe LCkWkCM3mrq01pGqsw7aJ7NrtjwL1LQ2EAPuPVhq6Ha1e0CdWD4Y6JKqlekRauAWCX kwyTsTaM9VSCwILgHERJT//rtn7S6dqS1xH1XAxCaRfzughef32+mI/3L2nMcYNnh8 8+WoEPC8mvq0Q== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v3 3/3] Squash to "selftests/bpf: Add bpf scheduler test" Date: Sun, 22 Sep 2024 09:00:26 +0800 Message-ID: X-Mailer: git-send-email 2.43.0 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Geliang Tang Update endpoint_init() in sched_init(). Signed-off-by: Geliang Tang --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing= /selftests/bpf/prog_tests/mptcp.c index 167fd9b190ee..ce18da1a6330 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -499,7 +499,7 @@ static struct nstoken *sched_init(char *flags, char *sc= hed) if (!ASSERT_OK_PTR(nstoken, "create_netns")) return NULL; =20 - if (endpoint_init("subflow") < 0) + if (endpoint_init("subflow", 2) < 0) goto fail; =20 SYS(fail, "ip netns exec %s sysctl -qw net.mptcp.scheduler=3D%s", NS_TEST= , sched); --=20 2.43.0