From patchwork Tue May 7 10:53:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 795374 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 8D3A81514E7; Tue, 7 May 2024 10:53:45 +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=1715079226; cv=none; b=bpdRsZmIc04ui9MAb7El6dpM4GL0KBDYG7eF8PL5JQwJ65UBIx3gAGxjll111FbWs9eh3Nh+kaZ9h1Z5k0mUmm7eGcIURTgixtZ9QzUbOl/nSHB36UO8aAJ5V7+gm/KMEomLvg+a0ZK9XreQbDrqVeXYsWAMaNjRzOwlZMTC2fw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715079226; c=relaxed/simple; bh=hPNoNz/g0I0oQPt/EFnqKp4bIa85B5bemCYHctr92U4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=r4OOLGVmJZXufsyknJuihbb6jWVBlWs6EXgECum/uJbB0lF+fg+J16u8Af1h4U5IUZyCw6FL3rA8bhA65EKTDzO+0zl8Bp7nhbE/fAi3XOBbgFGcbzc3i8pq1KeW+G9VDmTFE1a+P+h/5gvDQ5bC1olNrYNhuXI+NrXb3YCzV8s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sQwAI7pF; 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="sQwAI7pF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD63DC4AF63; Tue, 7 May 2024 10:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715079225; bh=hPNoNz/g0I0oQPt/EFnqKp4bIa85B5bemCYHctr92U4=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=sQwAI7pFMlEkTyzClB0iQYDUxEIFMwCadJADJv0UuKF0stcPVmE5iBuWrr/zPQ0ae MZ7KvqUUGh+lVYytmm4fcPpa33ZITC8J+OUQYEf0ZbbrBRKTMcmUV5gdA4D8JzMyge 1my0Lw3XCTXlp/4x6846+5eXf3h+9Pf4lHu9uNy3pnEfjEO9MzgWRqAmNqTy8wsa2R pmn2ZBI/E3J+fg43+67CqOaG6FdzKBaogCv5uGV3V88AvJcXiyx4B/Xuxrdx3qFRmC CI6pAtwfOJRX95Y9M5o6Q609MDUL1Hb5whrhO0AKdL4vA1gmFcNHaTXFdE6l8lfCop mm1bEgBwLyg+g== From: "Matthieu Baerts (NGI0)" Date: Tue, 07 May 2024 12:53:31 +0200 Subject: [PATCH bpf-next 1/4] selftests/bpf: Handle SIGINT when creating netns Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-1-e2bcbdf49857@kernel.org> References: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-0-e2bcbdf49857@kernel.org> In-Reply-To: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-0-e2bcbdf49857@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1187; i=matttbe@kernel.org; h=from:subject:message-id; bh=lyRBoz5Xmhw6UZgyarafKgSfWpCH32S9g/wdv08HRjU=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmOggukIkwZj6TYCL8FxTM3oKEpmnsX+s2yWfBf zv+Q+kmt6CJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZjoILgAKCRD2t4JPQmmg c584EACgL5qCGLUyywbDhu1TIO6ySqs4kpRCfDV1gmNFeugITDERHvC0Y/t0MApQDciodwUanek eFYdwF2cKkHp3T1K5lC1e5vrh6dFOAObk9WuyDeXCuuEJgTF8qm8eLHOw9WpdT3RZw+2pVdP9fE B5A1qF7U+qjWWD031Kx4CPo/+v6QlUruVwiFJSA0yOHWA4l5HfXFhd8jF8uH93p/OyXwmzy+BnV 8RuK+k/uFudn85WUF1x6+aygt0bDGZntYCDslsPw//HBw9Z/HpqnFpv2T0+9AF2HahVYfliNOGJ amboL9mxYBEKMDQ+dIb9ll/fglr0Ma2oyxvjDLBcmdEMNDIjsaRsgUSjUGxTOPavuvZ3sMg71VJ KBBlaPczPTVU89XKZxLE4XKCN27BmTEG1cwvFDSU/LS3bW4K03vDouwCMWxYVlB+L1q2O8ZGMBH cZfIE0ZdWXKx9OS6IVVsEiI3bRG4tckilcigatWcnuGf1nHmhBSnieGl1SPfD2GkORLC3y4bTxU zQtN6aNyLp35sQ+S0ngqwNYj8AJEpou7PUFVV7o4qERDo2peInoBFfwqVGjMjwDT0aWeEMoW1/K xuE1SwbX1WmAmrM1sXwTpC3/qpMzgFiis+XhmF9iKogYatOzDClThq8a+RW6uK4GbSqDz6ONVUx UYAiYLtzEO62bXg== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang It's necessary to delete netns during the MPTCP bpf tests interrupt, otherwise the next tests run will fail due to unable to create netns. This patch adds a new SIGINT handle sig_int, and deletes NS_TEST in it. Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 274d2e033e39..baf976a7a1dd 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -64,11 +64,18 @@ struct mptcp_storage { char ca_name[TCP_CA_NAME_MAX]; }; +static void sig_int(int sig) +{ + signal(sig, SIG_IGN); + SYS_NOFAIL("ip netns del %s", NS_TEST); +} + 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); + signal(SIGINT, sig_int); return open_netns(NS_TEST); fail: return NULL; From patchwork Tue May 7 10:53:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 795944 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 8EF8D1509A6; Tue, 7 May 2024 10:53:51 +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=1715079231; cv=none; b=BN9OsIrvxaWFQlt5shvaDTd73Qox6sT/LgZkmZT82mIqGj/ppTjIADlR36rT7cg0hGXqZlC8HWG8utSX97Qxa+SdGdpSgMvwt+FGkHoioG/XBn/gHQaNfGkOajHk7J7h6NCxAW278fQNvOpwRKUYFlBvjYjW3RLOiQnMdux1aJ8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715079231; c=relaxed/simple; bh=jSQSA9ObspLWriDSbY7LXBjGeEeVNlgc2rqqlfC5LXU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UJl9WwmlhUdb0i9dDGXAfvoMNkt/UpFAkIfraT+IIM1axtzqu1s+IA8L1FUaTDO18w3YO8gnw/z81TUd/qi41Mw3XwrQHR2FMwM9LMb2/pJzMMgdjbw/Mq/Ka51UiHZqVT4HjMhyZM7oJQ8biv3m/GxtywnRfa09lqNWWJ8/QGE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LobBtDgD; 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="LobBtDgD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B638C4AF66; Tue, 7 May 2024 10:53:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715079231; bh=jSQSA9ObspLWriDSbY7LXBjGeEeVNlgc2rqqlfC5LXU=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=LobBtDgDRS54ocaslIxQbAv+VeYjboKklIHMunyTIrincm9+v7wH435pZEWgRs0Wl 2aq2NE483s/Kuqj0WtFj+U8s0etMSOUqEVFfNvO2wLG8Xi4bXQcpAwVIOg70lAidvq npOvLfGb/CVmTWmM10gmJj9wVkVH8SyGf0RUvY0KX3dX1F533Xk53NjAuqa7lNbjgr sQQIxiXTFXrP+gqDIESebSpQXacB7Pzy534Lkqe0+RUGXOQmKljCxIYzafQQRfgDx7 Nxhw09AXz17pQ/dVHPKyweSYX/VjBiwbehepyGU2MC6MWRLmAhTFqZo61bpfksEo0w tsRV7PYWMzFoQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 07 May 2024 12:53:32 +0200 Subject: [PATCH bpf-next 2/4] selftests/bpf: Add RUN_MPTCP_TEST macro Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-2-e2bcbdf49857@kernel.org> References: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-0-e2bcbdf49857@kernel.org> In-Reply-To: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-0-e2bcbdf49857@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1144; i=matttbe@kernel.org; h=from:subject:message-id; bh=mhApJwAHgeitNpAaQBRyxjO18rRunoBqRBu7knt84w4=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmOgguX+CwaeAGlpJyISVH1t/JF4AqZulYA5ymv Fyb2Vd5VvWJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZjoILgAKCRD2t4JPQmmg c4b+EADGbAtlxozE2Q30WzhbII+rfSFL0kbpgbwvR9eTSPvFy+cAFy2K3c/8xpHIkU4UHy5hB8v IYVECxBKSlhefM8JcrC3C/oClRAyQBMNTqiZCKVBmWn7GrJib3c7gowTjpL/A9I0L5ziqEx8Yji jZLm/T8cqCtekuwfEG4xVUmCcFmTzEOtrk07s1n7Dze05BAlF+ulpSlaRMzS/jWBeURdAkwkUrg M4jX0gDMF7duHWP/R7Fut6X5GTyhOZlP0OEIV+532yrQyt1IcR/0MpwDfAzK2mMJjCJTlUhV5NB 2RXMtMxaUMFW3TbXF8TTi23FcMgAiHnpDae82ouXyZXIoHTW7TBD4zIpk2ZRVctePKdSfwQqLAw IZcBuMZfBE0kK5U8H/XHgSyWXbVK59x0e0zadorZ6dvxCYZl4IJV+gRzXNg03ENiVor9Is3Evkj PTNH27cGsmU1UmI5UNmFJ7q43mS60swX4YRE4vQOP3sWoMG0vq8Fgz41oex9dkZQVUdnsul/zG1 1ZKPz2GhHWHhc14V7nqjRkx6Nun6bPDaJO7LzhGa530NftYMEMub8QQBRu6vV7jF0NgCZTWEoi9 qU3kdInCSU6nePpofvQW3yavuF1rRTL1TMqdtKA2ahkpvlK0cNGnV7sYPjdkhaUUGG1lCfH2cHQ t2uMsXvVJAUkE3g== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang Each MPTCP subtest tests test__start_subtest(suffix), then invokes test_suffix(). It makes sense to add a new macro RUN_MPTCP_TEST to simpolify the code. Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index baf976a7a1dd..9d1b255bb654 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -347,10 +347,14 @@ static void test_mptcpify(void) close(cgroup_fd); } +#define RUN_MPTCP_TEST(suffix) \ +do { \ + if (test__start_subtest(#suffix)) \ + test_##suffix(); \ +} while (0) + void test_mptcp(void) { - if (test__start_subtest("base")) - test_base(); - if (test__start_subtest("mptcpify")) - test_mptcpify(); + RUN_MPTCP_TEST(base); + RUN_MPTCP_TEST(mptcpify); } From patchwork Tue May 7 10:53:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 795373 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 331B11509B4; Tue, 7 May 2024 10:53:57 +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=1715079237; cv=none; b=RBxshMcBtUTq46AgiFbVe9H5u3eSNBDcAHRr7ecGL+UC3KBWSt2vymv5EGDgUcLUILTOkMGZ2wG63g7gqpF+gyrFQWEmolcpnN4rAxLieXRQyfLqgImRA9PGHo2y53HxWvLvRBKySDTfz8+//sLgzN4AYiZUhi09toyfgEJ2qZE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715079237; c=relaxed/simple; bh=VFKyTxMNnjtTnAGapwEqo0y+Wl3eNywA8QPOjetFwbY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NAZUF2zaoh3SdhMtjkVOM2vPF3uZDymqUbGzoWBIm9b9v56Y8KiPlyp9WEGYD7l6qHFzGKTFmhP4pEAPzq73qMbgHPw7k15wQ6C7u11/JldZCmr5QJ1XJYo4RvF6+OoU7dR/A8oBp1qGY1aahBW9Bp6Ypxi3TYDA98kng80s+84= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QfuF2Tdn; 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="QfuF2Tdn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A5F2DC3277B; Tue, 7 May 2024 10:53:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715079237; bh=VFKyTxMNnjtTnAGapwEqo0y+Wl3eNywA8QPOjetFwbY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=QfuF2TdnxdGRGi4LcpbRaW7FyT2AqrnNLOss5JrPM2uZJhXox8R38GANJZUNA9Zfx PWufTSqrVKm3gmXIyHT8pbymWFOck4emf9Bz4IljrXF8VJRH+w6hSedyZONnClK+iE WWFXhsnvZk4Lall5KUOBmJULg+9e0FJSMwdgaQSgU9pNtnAQDE0fDc2T5T7/VZKF1R VHzlMNggpKHsJWg14DydAkfYySztncyyCzHTSvXC4INxRcjYcouRYwvJIEnjNOtmxm 9DZg++mNJZp7UyHiMVgdtHsETG0o30UqhpzdCsIWFECgS95u0QAzZ2nmmUrcmUhLG6 FqLmV29QA7A1w== From: "Matthieu Baerts (NGI0)" Date: Tue, 07 May 2024 12:53:33 +0200 Subject: [PATCH bpf-next 3/4] selftests/bpf: Add mptcp subflow example Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-3-e2bcbdf49857@kernel.org> References: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-0-e2bcbdf49857@kernel.org> In-Reply-To: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-0-e2bcbdf49857@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , Nicolas Rybowski , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3387; i=matttbe@kernel.org; h=from:subject:message-id; bh=9yBRlvcB78kseSfkWuFKFSLv7Nh7bJtbBJ9j/JCwOfc=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmOggueCE7DHl2/0U2kOTU6h1W2xplY9qsqP5kw sph3IgS5NCJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZjoILgAKCRD2t4JPQmmg c1awEACUa0bjOdrYDibYKxuW27ayQDefRp0gFGZROprmFgXaqrVf5FzjrsIk7gdgOe7bkPA4i9x pB6swZyvDFXILuFgix661/g1+P0MNAiYnch3YuMcCFvXpsQBQlmzGGLl4bqL5+P/knnRca9K7Zl BCSwKzNRv23u6sERo0mjMGfZrPVpiEuaYf7a1y4Gl3IfOmjL/ZbiPlU2pDCiyWdMkXaFnYhysOC g1LQ44vg947h9v3cJeDLWr9kgRYLU/Lx24RbctunZQp69GWvsI0OVcK344gWpj8hLXANyxNm/h/ rHUEK470BgzDG2NsaEA69DM8CFKskTidPYV3L/Q3TKnbpf8LufMYPT3g5td77xFu1wvD/urN6P4 Ts6k7NS0xcYuFho3XUrxoHbIcqkBOxGBoR4gvh4wq+z2s0eB2gGjs9J+MuPi2UeIjHR8ahRZY5l vLxyP9/nwH7Nw0OPnK1BK6yU2725UvgRbHSEbDBUSgU6aNAKPSIFNO+UAMGyy8J2EWxblslaqyp 6ZS34aVk2EpluwlE8zZ38oUqxGGDchR+HKOPOKARo7goYKPhHahhdmU1xK8TQi8gYYqdFkNcvcV qoKnrOhoP4jjG9ib3JX/xFmsGlbIRJAG9ExtywZnt4Lfx9DxEQD522vx2bRfUPtxkydfvAadu0x ivB4sffwHEeSlUQ== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Nicolas Rybowski Move Nicolas's patch into bpf selftests directory. This example added a test that was adding a different mark (SO_MARK) on each subflow, and changing the TCP CC only on the first subflow. This example shows how it is possible to: Identify the parent msk of an MPTCP subflow. Put different sockopt for each subflow of a same MPTCP connection. Here especially, we implemented two different behaviours: A socket mark (SOL_SOCKET SO_MARK) is put on each subflow of a same MPTCP connection. The order of creation of the current subflow defines its mark. The TCP CC algorithm of the very first subflow of an MPTCP connection is set to "reno". The code comes from commit 4d120186e4d6 ("bpf:examples: update mptcp_set_mark_kern.c") in MPTCP repo https://github.com/multipath-tcp/mptcp_net-next (the "scripts" branch). Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/76 Co-developed-by: Geliang Tang Signed-off-by: Geliang Tang Signed-off-by: Nicolas Rybowski Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/bpf/progs/mptcp_subflow.c | 70 +++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/tools/testing/selftests/bpf/progs/mptcp_subflow.c b/tools/testing/selftests/bpf/progs/mptcp_subflow.c new file mode 100644 index 000000000000..de9dbba37133 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/mptcp_subflow.c @@ -0,0 +1,70 @@ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) 2020, Tessares SA. */ +/* Copyright (c) 2024, Kylin Software */ + +#include // SOL_SOCKET, SO_MARK, ... +#include // TCP_CONGESTION +#include +#include +#include "bpf_tcp_helpers.h" + +char _license[] SEC("license") = "GPL"; + +#ifndef SOL_TCP +#define SOL_TCP 6 +#endif + +#ifndef TCP_CA_NAME_MAX +#define TCP_CA_NAME_MAX 16 +#endif + +char cc[TCP_CA_NAME_MAX] = "reno"; + +/* Associate a subflow counter to each token */ +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __uint(key_size, sizeof(__u32)); + __uint(value_size, sizeof(__u32)); + __uint(max_entries, 100); +} mptcp_sf SEC(".maps"); + +SEC("sockops") +int mptcp_subflow(struct bpf_sock_ops *skops) +{ + __u32 init = 1, key, mark, *cnt; + struct mptcp_sock *msk; + struct bpf_sock *sk; + int err; + + if (skops->op != BPF_SOCK_OPS_TCP_CONNECT_CB) + return 1; + + sk = skops->sk; + if (!sk) + return 1; + + msk = bpf_skc_to_mptcp_sock(sk); + if (!msk) + return 1; + + key = msk->token; + cnt = bpf_map_lookup_elem(&mptcp_sf, &key); + if (cnt) { + /* A new subflow is added to an existing MPTCP connection */ + __sync_fetch_and_add(cnt, 1); + mark = *cnt; + } else { + /* A new MPTCP connection is just initiated and this is its primary subflow */ + bpf_map_update_elem(&mptcp_sf, &key, &init, BPF_ANY); + mark = init; + } + + /* Set the mark of the subflow's socket based on appearance order */ + err = bpf_setsockopt(skops, SOL_SOCKET, SO_MARK, &mark, sizeof(mark)); + if (err < 0) + return 1; + if (mark == 1) + err = bpf_setsockopt(skops, SOL_TCP, TCP_CONGESTION, cc, TCP_CA_NAME_MAX); + + return 1; +} From patchwork Tue May 7 10:53:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthieu Baerts \(NGI0\)" X-Patchwork-Id: 795943 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 090DA14EC4D; Tue, 7 May 2024 10:54:02 +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=1715079243; cv=none; b=obrmUqT8vg3aoEaXoqceKhG2FjdH+1Sp1w5XLBb3XWew4MNGfZZqpJtGGD25/9jgmh7yWYHxwr7ontDL0dZozsiA2BIZK0cO0gWjOG1Cygh7TIXX96PyHRwOoj56SVxwNZ/U/4GxyYb9czqGJW5uRvrd6RH7bIGEsT/YGTaR0sY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715079243; c=relaxed/simple; bh=fyRycR9/L+qh3CJ6pIxN0skKoQZC9oBAv+ztBt5UGzg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=AiW+5xrgiPEHC9Wox+iDMGqj9+rBnMQRVGoESyB1Cen3x5bvOvGIuwn6slSu71LF+5fy2W3rqps709CwS7xudDxpnDeiT1kOxlgrMrtnRBIQSGwgSKCqgXOHFeAldfI6v6agoMGlmRO2lGlkNBGXE+nTq0cq8bIi6w8tOntJQTY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YVqsxteN; 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="YVqsxteN" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9716AC4DDF0; Tue, 7 May 2024 10:53:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1715079242; bh=fyRycR9/L+qh3CJ6pIxN0skKoQZC9oBAv+ztBt5UGzg=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=YVqsxteNtzE4S8exHApU/2njm3ygd9CpTi1TDM5H0/OP24rlJh8uvz38v+hVWmxze A9do2IjGGYXPPMb6WjGy7HZpfqJhz4A81LwfflTnp6RsjOXEqVdIbvDwJhZiur/e98 dXkNvHxGROHR6LL8d9iNUyH75RuqJHlvHsTSN0FmfCEqoxgu09LHXtn0RDR4f+6XJV qamYMh+A1PcuBs7s68dvaCNqSEuUa/1TB+1k8ffynFBWWafZDRumSz7CxI1xV8TBHA PPyCXtfYoYCIheVjQx9F1Jo4+YnAbRqhlqQhzOtOr/tbbRjMbTGlMdiwFR9g4OIb0Q SjWqMq8UsipKg== From: "Matthieu Baerts (NGI0)" Date: Tue, 07 May 2024 12:53:34 +0200 Subject: [PATCH bpf-next 4/4] selftests/bpf: Add mptcp subflow subtest Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-4-e2bcbdf49857@kernel.org> References: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-0-e2bcbdf49857@kernel.org> In-Reply-To: <20240507-upstream-bpf-next-20240506-mptcp-subflow-test-v1-0-e2bcbdf49857@kernel.org> To: mptcp@lists.linux.dev, Mat Martineau , Geliang Tang , Andrii Nakryiko , Eduard Zingerman , Mykola Lysenko , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: linux-kernel@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, "Matthieu Baerts (NGI0)" , Geliang Tang X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=4474; i=matttbe@kernel.org; h=from:subject:message-id; bh=QeuP1pMc/k96+AiijABtrDomlFWQNDkZyAl1mjsJHSA=; b=owEBbQKS/ZANAwAIAfa3gk9CaaBzAcsmYgBmOgguuQJyqIBiUOXpxcvyUyTh/u9QRs36zlLNG kJj1KXPxsaJAjMEAAEIAB0WIQToy4X3aHcFem4n93r2t4JPQmmgcwUCZjoILgAKCRD2t4JPQmmg c/mYD/9W/Xm0YcLRjcCEdydksviMvjwjFXItUHpjmNxvluDyfxbakZfpDYsxJjS3rIdNzjfYK03 en4bT/fZh8xRQiKg1UVCPwh+MlxIenzovEMNZdAtRTPoW9pWNG3HR6bqGqtZ//3084bTpg/b4eE 8JO3ifXOQiyp3f5902sEq+jTLaUzp2pW3k2c7IboooXf3bnYqT9cH/R5J4d/UMErsf0A1L8OCV9 kcxHe1PizEQ0blKkpBKxBmX9/FcQbl8T9f9+TxDs1oDO4Xy+a2ZaMse1IrVRIAxfo3ILmyb4reo mGPP7ZSq5n3poQSndzN/UNJlPZtYHlazS+06JZn0J3Ft7UuO1Mh8j6Feo5gQ1u70r1LTsGd7yVu hON+J+xMscJuoFlTx2aOBE1nNxFFeVyQ30fSJy4whxp0Mx7HrCavBoHa9QGeNJ4k/qivxl3TMh9 6WNxaI4QajQVGpeXeMTBD7sUETWJt7WvM6mb3lVlNvWtlyRbdyPypW87u1XVb8CZO9JNTF0j/oO LZ9ctbjCOn7GEOkS+nT38Pjxw+sC3To92UYYUjbOuEECOFGZksr79JuS9iRkGUpyGQUeuQ642XS y6pj7xWa15Dx9yYvW14CgSJ5g+nesidxrWW/5rM4M9d+WThDBRP2ddSwyviNxBgJphuCdTeOQkT GE36SAyPy7nVIug== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Geliang Tang This patch adds a subtest named test_subflow to load and verify the newly added mptcp subflow example in test_mptcp. Add a helper endpoint_init() to add a new subflow endpoint. Add another helper ss_search() to verify the fwmark and congestion values set by mptcp_subflow prog using setsockopts. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/76 Signed-off-by: Geliang Tang Reviewed-by: Mat Martineau Signed-off-by: Matthieu Baerts (NGI0) --- tools/testing/selftests/bpf/prog_tests/mptcp.c | 108 +++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 9d1b255bb654..b1f4b74efd2b 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -9,8 +9,12 @@ #include "network_helpers.h" #include "mptcp_sock.skel.h" #include "mptcpify.skel.h" +#include "mptcp_subflow.skel.h" #define NS_TEST "mptcp_ns" +#define ADDR_1 "10.0.1.1" +#define ADDR_2 "10.0.1.2" +#define PORT_1 10001 #ifndef IPPROTO_MPTCP #define IPPROTO_MPTCP 262 @@ -347,6 +351,109 @@ static void test_mptcpify(void) close(cgroup_fd); } +static int endpoint_init(char *flags) +{ + 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); + SYS(fail, "ip -net %s mptcp endpoint add %s %s", NS_TEST, ADDR_2, flags); + + return 0; +fail: + return -1; +} + +static int _ss_search(char *src, char *dst, char *port, char *keyword) +{ + char cmd[128]; + int n; + + n = snprintf(cmd, sizeof(cmd), + "ip netns exec %s ss -Menita src %s dst %s %s %d | grep -q '%s'", + NS_TEST, src, dst, port, PORT_1, keyword); + if (n < 0 || n >= sizeof(cmd)) + return -1; + + return system(cmd); +} + +static int ss_search(char *src, char *keyword) +{ + return _ss_search(src, ADDR_1, "dport", keyword); +} + +static void run_subflow(char *new) +{ + int server_fd, client_fd, err; + char cc[TCP_CA_NAME_MAX]; + socklen_t len = sizeof(cc); + + server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); + if (!ASSERT_GE(server_fd, 0, "start_mptcp_server")) + return; + + client_fd = connect_to_fd(server_fd, 0); + if (!ASSERT_GE(client_fd, 0, "connect to fd")) + goto fail; + + err = getsockopt(server_fd, SOL_TCP, TCP_CONGESTION, cc, &len); + if (!ASSERT_OK(err, "getsockopt(srv_fd, TCP_CONGESTION)")) + goto fail; + + send_byte(client_fd); + + ASSERT_OK(ss_search(ADDR_1, "fwmark:0x1"), "ss_search fwmark:0x1"); + ASSERT_OK(ss_search(ADDR_2, "fwmark:0x2"), "ss_search fwmark:0x2"); + ASSERT_OK(ss_search(ADDR_1, new), "ss_search new cc"); + ASSERT_OK(ss_search(ADDR_2, cc), "ss_search default cc"); + + close(client_fd); +fail: + close(server_fd); +} + +static void test_subflow(void) +{ + int cgroup_fd, prog_fd, err; + struct mptcp_subflow *skel; + struct nstoken *nstoken; + + cgroup_fd = test__join_cgroup("/mptcp_subflow"); + if (!ASSERT_GE(cgroup_fd, 0, "join_cgroup: mptcp_subflow")) + return; + + skel = mptcp_subflow__open_and_load(); + if (!ASSERT_OK_PTR(skel, "skel_open_load: mptcp_subflow")) + goto close_cgroup; + + err = mptcp_subflow__attach(skel); + if (!ASSERT_OK(err, "skel_attach: mptcp_subflow")) + goto skel_destroy; + + prog_fd = bpf_program__fd(skel->progs.mptcp_subflow); + err = bpf_prog_attach(prog_fd, cgroup_fd, BPF_CGROUP_SOCK_OPS, 0); + if (!ASSERT_OK(err, "prog_attach")) + goto skel_destroy; + + nstoken = create_netns(); + if (!ASSERT_OK_PTR(nstoken, "create_netns: mptcp_subflow")) + goto skel_destroy; + + if (!ASSERT_OK(endpoint_init("subflow"), "endpoint_init")) + goto close_netns; + + run_subflow(skel->data->cc); + +close_netns: + cleanup_netns(nstoken); +skel_destroy: + mptcp_subflow__destroy(skel); +close_cgroup: + close(cgroup_fd); +} + #define RUN_MPTCP_TEST(suffix) \ do { \ if (test__start_subtest(#suffix)) \ @@ -357,4 +464,5 @@ void test_mptcp(void) { RUN_MPTCP_TEST(base); RUN_MPTCP_TEST(mptcpify); + RUN_MPTCP_TEST(subflow); }