From patchwork Wed Apr 10 02:05:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13623462 X-Patchwork-Delegate: mat@martineau.name 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 E54A810F1 for ; Wed, 10 Apr 2024 02:05:35 +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=1712714736; cv=none; b=X4gBVszorKiG9eMJc78OAYEMc2J6QTDkbGauIdrDt90dNQMy1ch2ccUPR5jqEvauznk3QfHmrG5WV2qS1hN/IZa/pGTGIF7jYEWZTwvHw+V307USHnD9bGwFzrzsl7wWHAWp0XfU5lSsuQm03L/IjV3Bq8iMpyMKDfV/jbieH+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712714736; c=relaxed/simple; bh=/Pc3wOJ+00tHqo8MDJm/cNhGbriSzwm6ucNRtr1wM7Y=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=raW/Zzqittjc3jO7uLL+XOCR6N6DGU/lZcWOWKWn0sTaUF9FitgheIykKQJVkV9GVu4dPgWl53BNKhagx2r0fy1c74ZaUFJIV0V+rciU9qOoImPuaJV6/OLaYEOR42ZfmD4lCvdBwYJN36no1OutHr+puovsTxlXbPCXyPD39rU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UjRfhmNX; 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="UjRfhmNX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E3D5DC433C7; Wed, 10 Apr 2024 02:05:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712714735; bh=/Pc3wOJ+00tHqo8MDJm/cNhGbriSzwm6ucNRtr1wM7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UjRfhmNXM7HowFIOU7iFP0tAyPJiQmwkqt4o0sVCWCeAsOnIdD4U6WQIy3UrlWH03 vwzgBqA1SmWU0WwFMOa5G+JVUcHmMupoBg15mNUL/IXzAJvqdqsghqaHMxyes2yNQD BwbHToGroluXJ10P0A0QOoU/hl07BMJL1GvOcz5liHCSEM4sDGCITdbrxyR86yYkYn muleY6GNGkMX5GUIdsmy3zJ55v1/DgcDKlv6xXRTFG5TFVnL8F9dXcNiwJnRE6wRO+ TDkeMAykY6X8e8+1G0r2j0IhEuS5liRWT7gRShk6+aHpCP7y6vjxYglmTLOvsjfY24 YeIpWNYIX8Ipw== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v8 1/9] selftests/bpf: Add RUN_MPTCP_TEST macro Date: Wed, 10 Apr 2024 10:05:16 +0800 Message-Id: <1b62f171064b5735f49c7fc0d953763ec0434832.1712714407.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 --- 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 cbdb15922949..c29c81239603 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -653,12 +653,16 @@ static void test_burst(void) mptcp_bpf_burst__destroy(burst_skel); } +#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); if (test__start_subtest("default")) test_default(); if (test__start_subtest("first")) From patchwork Wed Apr 10 02:05:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13623463 X-Patchwork-Delegate: mat@martineau.name 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 616501FB4 for ; Wed, 10 Apr 2024 02:05:37 +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=1712714737; cv=none; b=h31ScQGCRNvdaR0eLnN/D2HP2rXH7W9yPkNAvjnyzxU25+Ky8ORgMqtsVBbbu3d7Wgz8gcFN9FQANeowKAWU7DyHC2hUe7qkq/CDpLvpcCY1SfB/Wu7TPx2KAbgjOO5ONM1UxhIkxP/Cdm13bV/3be6sA/DMthr0HrmQ/BTecLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712714737; c=relaxed/simple; bh=8xvLLtxv5HI3brq/W5uAXfifezPKodIkWD6ZhyEO5b4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PD/PiiXeEkYBmA8XRM/9kQin0udNphy+Ni3t3VO+r2zs060diIuDTxzKaZ0tjDLLE8hc0zn8dZpdzxB22zplG3gRTQx5GpkDKbfermHyTDO9RYJ5Ipew0pFM5v/8hXrRcMkadZCwzqWLBKQk5mHV6ZsSoJPz+PdyUv7hvput5pY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=pVZm2tOM; 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="pVZm2tOM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 140A4C433C7; Wed, 10 Apr 2024 02:05:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712714737; bh=8xvLLtxv5HI3brq/W5uAXfifezPKodIkWD6ZhyEO5b4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pVZm2tOMlChsBaCprjESxVBwTGHr+QOwcRzr+PdFc91fDLUPYzk2uv2e69/xcaaC7 uPb2ddaeti0YEIwWK5Gh38J2WZt+PIii+AdeBZpBvbCcwaHgEmTWNDEqGbjWj3Hns+ XoEJmdp8GdYbqbFlcrmAkIikz91OfQNYTVIWAWfy2Cagqtz55b2Fq/4aVJXuDy+nTQ HKpOeaxe8iTmPwhzcJUvu6DIlNVPmweKQHCYRWxi+6RySaU7je3TBcD1f/kZGbnF0V UxBcXtDoQ1GRLlEXDqMch0HiZnQg24ei8DnB9vsj6e6UUOIumN0SXn43rGlvtObN2m H9XzqCYfUFtaA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v8 2/9] Squash to "selftests/bpf: Add bpf scheduler test" 1 verify Date: Wed, 10 Apr 2024 10:05:17 +0800 Message-Id: <5c389066c7970455fb69b3ed24db06a3bccda031.1712714407.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Add send_data_and_verify helper to avoid duplicated code. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 42 ++++++++++++++----- 1 file changed, 32 insertions(+), 10 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index c29c81239603..2e1ba03f0398 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -17,6 +17,8 @@ #include "mptcp_bpf_burst.skel.h" #define NS_TEST "mptcp_ns" +#define WITH_DATA true +#define WITHOUT_DATA false #ifndef IPPROTO_MPTCP #define IPPROTO_MPTCP 262 @@ -457,23 +459,44 @@ static int has_bytes_sent(char *addr) return system(cmd); } -static void test_default(void) +static void send_data_and_verify(char *sched, bool addr1, bool addr2) { int server_fd, client_fd; - struct nstoken *nstoken; - nstoken = sched_init("subflow", "default"); - if (!ASSERT_OK_PTR(nstoken, "sched_init:default")) - goto fail; server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); + if (CHECK(server_fd < 0, sched, "start_mptcp_server: %d\n", errno)) + return; + client_fd = connect_to_fd(server_fd, 0); + if (CHECK(client_fd < 0, sched, "connect_to_fd: %d\n", errno)) + goto close_server; - send_data(server_fd, client_fd, "default"); - ASSERT_OK(has_bytes_sent(ADDR_1), "has_bytes_sent addr_1"); - ASSERT_OK(has_bytes_sent(ADDR_2), "has_bytes_sent addr_2"); + send_data(server_fd, client_fd, sched); + + if (addr1) + CHECK(has_bytes_sent(ADDR_1), sched, "should have bytes_sent on addr1\n"); + else + CHECK(!has_bytes_sent(ADDR_1), sched, "shouldn't have bytes_sent on addr1\n"); + if (addr2) + CHECK(has_bytes_sent(ADDR_2), sched, "should have bytes_sent on addr2\n"); + else + CHECK(!has_bytes_sent(ADDR_2), sched, "shouldn't have bytes_sent on addr2\n"); close(client_fd); +close_server: close(server_fd); +} + +static void test_default(void) +{ + struct nstoken *nstoken; + + nstoken = sched_init("subflow", "default"); + if (!ASSERT_OK_PTR(nstoken, "sched_init:default")) + goto fail; + + send_data_and_verify("default", WITH_DATA, WITH_DATA); + fail: cleanup_netns(nstoken); } @@ -663,8 +686,7 @@ void test_mptcp(void) { RUN_MPTCP_TEST(base); RUN_MPTCP_TEST(mptcpify); - if (test__start_subtest("default")) - test_default(); + RUN_MPTCP_TEST(default); if (test__start_subtest("first")) test_first(); if (test__start_subtest("bkup")) From patchwork Wed Apr 10 02:05:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13623464 X-Patchwork-Delegate: mat@martineau.name 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 0C3E44C94 for ; Wed, 10 Apr 2024 02:05:39 +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=1712714740; cv=none; b=InhAGwoj8dB6TJnjfRd14jxoCzWaKTfmgmj9hCKMmYOjbVVRQAFR/UdcZu+vHSlpRG6uIDRtbb4+JCZ2NBrUSxADFN2dIaMq7knUU6Z10CuU2eQ77Si6ldTdQYjn0VV4OPrlueSKn0R5nRL++g4vSfY94qQ7J1Xbh2ZSKkg+yqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712714740; c=relaxed/simple; bh=kIFFB+2J6GKTcwgvvfZCjVkLDnUOCIbpueaLx5Hj8Fw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NYyFUWnff5ykmR3J1B4S0xWLyU6oMbcJlXqqqx1l2OTxNJlkwymjvNiY381Hda6izVkfVAacVsfGQTW7in6DfHjBxVYOV9h0eVA8F2/FZfn4fh+RsyCHpj5O2HckiM6IoO3tyd5QsIrTpDSszbK1szhEr+LlR6DzCK60/sd1v44= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=n53LmHYK; 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="n53LmHYK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A82FC433C7; Wed, 10 Apr 2024 02:05:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712714739; bh=kIFFB+2J6GKTcwgvvfZCjVkLDnUOCIbpueaLx5Hj8Fw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n53LmHYKM18CEB5NqeBp58QycJAFPaD/+1wiu0IYK1IrJHQ/Kgj4SKq0chKOJfHm4 PUeiHCSlwJYEuSv8zhrG66O1KI/29/ZR6EOMnCUzSce5VakgrSuOYFCZBrK8irVbsh fwu531AJxKpGaQ8I6AWv9mCLj0BhHgrQ7DC1+p91FaXO5G+dSyyiyS80B+pGtOMbIQ 7DNF65NRAKcQR4uNGNTOEQvqvhzRKziaJUGQMoNLL/GVlvTnIpv5tjTIu8G+BZOGBv vjH44kOjI/kh8rp8Tyw3JcX1bWT8xAtxbMmG/PlmuMN4Ub5zSeZaqsM6zubByErgI+ Q52xsU2FRauaA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v8 3/9] Squash to "selftests/bpf: Add bpf scheduler test" 2 time Date: Wed, 10 Apr 2024 10:05:18 +0800 Message-Id: <836c5ca6464344de45743fe439facad5ecf83d65.1712714407.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Move time related code from send_data into send_data_and_verify. Then send_data can be exported into network_helpers.h as a public function, reused by mptcp.c and bpf_tcp_ca.c. Drop duplicate '#include ', it's included in test_progs.h already. Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 2e1ba03f0398..e8df18c28961 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -5,7 +5,6 @@ #include #include #include -#include #include "cgroup_helpers.h" #include "network_helpers.h" #include "mptcp_sock.skel.h" @@ -382,16 +381,12 @@ static void *server(void *arg) static void send_data(int lfd, int fd, char *msg) { ssize_t nr_recv = 0, bytes = 0; - struct timespec start, end; - unsigned int delta_ms; pthread_t srv_thread; void *thread_ret; char batch[1500]; int err; WRITE_ONCE(stop, 0); - if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) - return; err = pthread_create(&srv_thread, NULL, server, (void *)(long)lfd); if (CHECK(err != 0, "pthread_create", "err:%d errno:%d\n", err, errno)) @@ -408,16 +403,9 @@ static void send_data(int lfd, int fd, char *msg) bytes += nr_recv; } - if (clock_gettime(CLOCK_MONOTONIC, &end) < 0) - return; - - delta_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000; - CHECK(bytes != total_bytes, "recv", "%zd != %u nr_recv:%zd errno:%d\n", bytes, total_bytes, nr_recv, errno); - printf("%s: %u ms\n", msg, delta_ms); - WRITE_ONCE(stop, 1); pthread_join(srv_thread, &thread_ret); @@ -461,7 +449,9 @@ static int has_bytes_sent(char *addr) static void send_data_and_verify(char *sched, bool addr1, bool addr2) { + struct timespec start, end; int server_fd, client_fd; + unsigned int delta_ms; server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); if (CHECK(server_fd < 0, sched, "start_mptcp_server: %d\n", errno)) @@ -471,8 +461,17 @@ static void send_data_and_verify(char *sched, bool addr1, bool addr2) if (CHECK(client_fd < 0, sched, "connect_to_fd: %d\n", errno)) goto close_server; + if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) + goto close_server; + send_data(server_fd, client_fd, sched); + if (clock_gettime(CLOCK_MONOTONIC, &end) < 0) + goto close_server; + + delta_ms = (end.tv_sec - start.tv_sec) * 1000 + (end.tv_nsec - start.tv_nsec) / 1000000; + printf("%s: %u ms\n", sched, delta_ms); + if (addr1) CHECK(has_bytes_sent(ADDR_1), sched, "should have bytes_sent on addr1\n"); else From patchwork Wed Apr 10 02:05:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13623465 X-Patchwork-Delegate: mat@martineau.name 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 9BEA4A5F for ; Wed, 10 Apr 2024 02:05:41 +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=1712714741; cv=none; b=Y5moivqQRnOZ02XEDjnYYP2zMSJjPqiyXwK3k42C6Fvo5LF/F8G610SocNJGEUnVT0cqp7Ud+U8LZLA2Ze4pOpw47jzdc1ZlJeB881ck/zDy6KZpQNNPE92gGBnMGNJ6qxniXQpcHq+VCEK8MLJLoQN0r1+s7N0HEqOOz1mpHM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712714741; c=relaxed/simple; bh=CljGcGmyOWVga8WPbxOA+yv/kSTijkdZF/RdammhdVQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LBhoA6KCPyjCHE4L3901Q4/ws22yaNyf2Dn9FSswL6jLvhQpURMzvIYRoykWeC0bF0XtKvJNyW9E9r8R7Bs0l6xUCOQAXfFKeKalRSJ4afi+fIvOoc3cC/6OhrnBe3fEqw0oavVshHMQXm1rXc19U8o+p6xcz6e1BQ5+VDpBmPw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YcahqXtn; 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="YcahqXtn" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45090C433F1; Wed, 10 Apr 2024 02:05:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712714741; bh=CljGcGmyOWVga8WPbxOA+yv/kSTijkdZF/RdammhdVQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YcahqXtnqwbrDgB9yvtqiyruj8sK/e/hMri0zSofrAI9No37JCam9G6F/CJF8Nbz2 BtfOOjX/WByzaf1xKVji7Aw8JQM4v5ZzDbAsIpmMw0kmJiK54NTARoPd0N4KkzwMSV Ocl0Up/yMKfWeKWJW4ZzJgrJ3UDq0J3RIjdQNjVsZIgVHWyCgb7OWVAtViVIk1MS2p PMzW8By0wi4cZhaBvrcJXKOWW3SWbZ4veLHl7mpe1K7PsRXUrBf9cwmMhGu97ccMzS BPYAXjQATDmc3Iiu0tobhDk/ZuTSwqBE1+UnDjrSbjdGx40X2wC6bTaFpbjE3J71it xJCO+uTwlK1ZQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v8 4/9] Squash to "selftests/bpf: Add bpf scheduler test" 3 MPTCP_SCHED_TEST Date: Wed, 10 Apr 2024 10:05:19 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang Please append this into commit log: ''' This patch defines MPTCP_SCHED_TEST macro, a template for all scheduler tests. Every scheduler is identified by argument name, and use sysctl to set net.mptcp.scheduler as "bpf_name" to use this sched. Add two veth net devices to simulate the multiple addresses case. Use 'ip mptcp endpoint' command to add the new endpoint ADDR2 to PM netlink. Arguments addr1/add2 means whether the data has been sent on the first/second subflow or not. Send data and check bytes_sent of 'ss' output after it using send_data_and_verify(). ''' Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index e8df18c28961..0144db1425ed 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -500,6 +500,36 @@ static void test_default(void) cleanup_netns(nstoken); } +#define MPTCP_SCHED_TEST(sched, addr1, addr2) \ +static void test_##sched(void) \ +{ \ + struct mptcp_bpf_##sched *skel; \ + struct nstoken *nstoken; \ + struct bpf_link *link; \ + struct bpf_map *map; \ + \ + skel = mptcp_bpf_##sched##__open_and_load(); \ + if (!ASSERT_OK_PTR(skel, "open_and_load:" #sched)) \ + return; \ + \ + map = bpf_object__find_map_by_name(skel->obj, #sched); \ + link = bpf_map__attach_struct_ops(map); \ + if (!ASSERT_OK_PTR(link, "attach_struct_ops:" #sched)) \ + goto skel_destroy; \ + \ + nstoken = sched_init("subflow", "bpf_" #sched); \ + if (!ASSERT_OK_PTR(nstoken, "sched_init:" #sched)) \ + goto link_destroy; \ + \ + send_data_and_verify(#sched, addr1, addr2); \ + \ + cleanup_netns(nstoken); \ +link_destroy: \ + bpf_link__destroy(link); \ +skel_destroy: \ + mptcp_bpf_##sched##__destroy(skel); \ +} + static void test_first(void) { struct mptcp_bpf_first *first_skel; From patchwork Wed Apr 10 02:05:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13623466 X-Patchwork-Delegate: mat@martineau.name 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 C0BBD1C2E for ; Wed, 10 Apr 2024 02:05:43 +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=1712714743; cv=none; b=LL3Nyx4PTn+yFn1NqJxPi97ZUki2yw0zIynU0fJLkGkki+ub4gai3u7KW3lwVmJ60eqfz/CXTcB22MrBQNMspZInQsdu/P/34EBN+8wrnoVPuSfkxiskovQrlhvO9AlKCIVCjDaobzFjEUsS4SjlB1UrxtxqWw1E/D81/kfgQh0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712714743; c=relaxed/simple; bh=R1k/TjZiktuMyom0BF8buj0Cl2SOpIQ+FATTdK0V4xU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PSo4ycSnxUjkeAi8nt/prFt8Km4iSKhwNiZLAbN/L4rzPSUs6Q9nvc9qEn+Nf4b1eFmFW/Uu4QOuPYf7ZFpbfcc8ewwTzXsrgg9lOEpUvOGbASp8TTcwq6SgsGf4a2IppMNwhfizWQ5bukVnoNADpTeVRmDH4GWSSVgFhOC6eDI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=D/ZM3Few; 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="D/ZM3Few" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 04BFBC433C7; Wed, 10 Apr 2024 02:05:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712714743; bh=R1k/TjZiktuMyom0BF8buj0Cl2SOpIQ+FATTdK0V4xU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=D/ZM3FewbGSIGvZX5lmzITmStJAQ2q9ORB0GV3FeGMT9eAJ7Es/DPDI9xbzudUD0t HFOraE3haSVEOWWh9OcnE5t2X0qMiuIJx8m1eZ9V1MOrNtoOj6mM0dMhYDmti7oiNE U7CRyLQZHjv/0lzdYsTziZNzZw0SGMDVBPdsr1U32luHMiTQtShR4gYMIsVmSGizkz QiB6Bar7L0NmmdvmRn40z/XlMQdvSC5d+KQTBIpavbCVFWJaz130tfdksBAgxDXrgI GiA7S6s+iHU1WKeLFkiTDnjo/fcHa/0odtyF1BYsSLq2x4N6jd7flW5iKC/m4vb/Pw yBC2ZFf2wnoqg== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v8 5/9] Squash to "selftests/bpf: Add bpf_first scheduler & test" Date: Wed, 10 Apr 2024 10:05:20 +0800 Message-Id: <3a8e8688d120d18525004dec7d214a901ce8f30c.1712714407.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang After squashing into this change, the patch "selftests/bpf: Add bpf_first test" can be merged into the patch "selftests/bpf: Add bpf_first scheduler" appending the following lines into commit log: ''' Using MPTCP_SCHED_TEST macro to add a new test for this bpf_first scheduler, the arguments "1 0" means data has been only sent on the first subflow ADDR1. Run this test by RUN_MPTCP_TEST macro. ''' And update the subject to "selftests/bpf: Add bpf_first scheduler & test". Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 38 +------------------ .../selftests/bpf/progs/mptcp_bpf_first.c | 1 + 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 0144db1425ed..d56a5aa0cf85 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -530,40 +530,7 @@ skel_destroy: \ mptcp_bpf_##sched##__destroy(skel); \ } -static void test_first(void) -{ - struct mptcp_bpf_first *first_skel; - int server_fd, client_fd; - struct nstoken *nstoken; - struct bpf_link *link; - - first_skel = mptcp_bpf_first__open_and_load(); - if (!ASSERT_OK_PTR(first_skel, "bpf_first__open_and_load")) - return; - - link = bpf_map__attach_struct_ops(first_skel->maps.first); - if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) { - mptcp_bpf_first__destroy(first_skel); - return; - } - - nstoken = sched_init("subflow", "bpf_first"); - if (!ASSERT_OK_PTR(nstoken, "sched_init:bpf_first")) - goto fail; - server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); - client_fd = connect_to_fd(server_fd, 0); - - send_data(server_fd, client_fd, "bpf_first"); - ASSERT_OK(has_bytes_sent(ADDR_1), "has_bytes_sent addr_1"); - ASSERT_GT(has_bytes_sent(ADDR_2), 0, "has_bytes_sent addr_2"); - - close(client_fd); - close(server_fd); -fail: - cleanup_netns(nstoken); - bpf_link__destroy(link); - mptcp_bpf_first__destroy(first_skel); -} +MPTCP_SCHED_TEST(first, WITH_DATA, WITHOUT_DATA); static void test_bkup(void) { @@ -716,8 +683,7 @@ void test_mptcp(void) RUN_MPTCP_TEST(base); RUN_MPTCP_TEST(mptcpify); RUN_MPTCP_TEST(default); - if (test__start_subtest("first")) - test_first(); + RUN_MPTCP_TEST(first); if (test__start_subtest("bkup")) test_bkup(); if (test__start_subtest("rr")) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c index 23a3e8e69e8f..2d067b25d60b 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_first.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2022, SUSE. */ +/* Copyright (c) 2024, Kylin Software */ #include #include "bpf_tcp_helpers.h" From patchwork Wed Apr 10 02:05:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13623467 X-Patchwork-Delegate: mat@martineau.name 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 5E0CF10F1 for ; Wed, 10 Apr 2024 02:05: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=1712714745; cv=none; b=j/TcpP0CM7Sehafm5/OLNsbeE19Fkx+k62E1bgyA2wWIbNpAlIi1TQC3QXGsKwET3IY6SuUsKEuudYp1o/uhn/xWy1TNpotSIuFRgAko1Wc+eNcDi6KdrRXk5V4aPIU3Yp/HHX91rgUzYAc6tu+UZ2PylasPq0CHnalBANZIEvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712714745; c=relaxed/simple; bh=ZAIQk6iCtS74XJ29TO4jMkah6vOQVaJHSd1WdaeN47w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QFq5p7msWWts6CwF0MOA5MPzpAEIl6R6H+SI+i5u+rv7QdOGg5dReDMxsQ719nXaBAcARBTjzobbd5IM9N8fJUX33RaFnST1h1RGqgfwZ27+GAgsvqhucww1yfn/ofLbNtxseca/aMceU4hkXn4KwP+6XEhambe3o4f8Mj58TP0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=qK7Jrer7; 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="qK7Jrer7" Received: by smtp.kernel.org (Postfix) with ESMTPSA id EDA30C43390; Wed, 10 Apr 2024 02:05:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712714744; bh=ZAIQk6iCtS74XJ29TO4jMkah6vOQVaJHSd1WdaeN47w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qK7Jrer750Zu8kGrNNanrqWBH/ZSIcQG6hHVXBBW14ltoOYX6lSOlVFVNbocZkqoq fJdKiPyLDw5MaDku0PpAjQpI4gS/SE4FyHn+OT7Zeqox/xsjYBCXwC195CQkoPMgaP v5OThWz9nRImQC8l7+qXTLjzulrvnnTGMyQDKFak6VczljivlxqqXxZDUYGKa13boX h0ZrnMMXwGU0WoIvNX5nwpPZCJMcbFiUDH7gMB5srnjzx8nc0s3qg2fsAiSSWBalBu vGZOUjhIaebEOvG44Hkoj079ALLbmnH6hk81TlS0o869GO1byYdnk9YTJq5SekceeV 7XR+GmNqMXlmQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v8 6/9] Squash to "selftests/bpf: Add bpf_bkup scheduler & test" Date: Wed, 10 Apr 2024 10:05:21 +0800 Message-Id: <7fd46d7a097794ae76fdad8d70ffa94a25d17501.1712714407.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang After squashing into this change, the patch "selftests/bpf: Add bpf_bkup test" can be merged into the patch "selftests/bpf: Add bpf_bkup scheduler" appending the following lines into commit log: ''' Using MPTCP_SCHED_TEST macro to add a new test for this bpf_bkup scheduler, the arguments "1 0" means data has been only sent on the first subflow ADDR1. Run this test by RUN_MPTCP_TEST macro. ''' And update the subject to "selftests/bpf: Add bpf_bkup scheduler & test". Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 39 +------------------ .../selftests/bpf/progs/mptcp_bpf_bkup.c | 1 + 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index d56a5aa0cf85..045b32cf8b22 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -531,41 +531,7 @@ skel_destroy: \ } MPTCP_SCHED_TEST(first, WITH_DATA, WITHOUT_DATA); - -static void test_bkup(void) -{ - struct mptcp_bpf_bkup *bkup_skel; - int server_fd, client_fd; - struct nstoken *nstoken; - struct bpf_link *link; - - bkup_skel = mptcp_bpf_bkup__open_and_load(); - if (!ASSERT_OK_PTR(bkup_skel, "bpf_bkup__open_and_load")) - return; - - link = bpf_map__attach_struct_ops(bkup_skel->maps.bkup); - if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) { - mptcp_bpf_bkup__destroy(bkup_skel); - return; - } - - nstoken = sched_init("subflow backup", "bpf_bkup"); - if (!ASSERT_OK_PTR(nstoken, "sched_init:bpf_bkup")) - goto fail; - server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); - client_fd = connect_to_fd(server_fd, 0); - - send_data(server_fd, client_fd, "bpf_bkup"); - ASSERT_OK(has_bytes_sent(ADDR_1), "has_bytes_sent addr_1"); - ASSERT_GT(has_bytes_sent(ADDR_2), 0, "has_bytes_sent addr_2"); - - close(client_fd); - close(server_fd); -fail: - cleanup_netns(nstoken); - bpf_link__destroy(link); - mptcp_bpf_bkup__destroy(bkup_skel); -} +MPTCP_SCHED_TEST(bkup, WITH_DATA, WITHOUT_DATA); static void test_rr(void) { @@ -684,8 +650,7 @@ void test_mptcp(void) RUN_MPTCP_TEST(mptcpify); RUN_MPTCP_TEST(default); RUN_MPTCP_TEST(first); - if (test__start_subtest("bkup")) - test_bkup(); + RUN_MPTCP_TEST(bkup); if (test__start_subtest("rr")) test_rr(); if (test__start_subtest("red")) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c index bfd4644dd592..486407a135c9 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_bkup.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2022, SUSE. */ +/* Copyright (c) 2024, Kylin Software */ #include #include "bpf_tcp_helpers.h" From patchwork Wed Apr 10 02:05:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13623468 X-Patchwork-Delegate: mat@martineau.name 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 6847F1C2E for ; Wed, 10 Apr 2024 02:05:47 +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=1712714747; cv=none; b=Aj1xTMVznyV2RfEenAz68DkfKIU7wcvbBfbXsgGEp+66qbQ9vUsyUUmXcPvYEHONaPZ1qvMthE64TjrevexJe4De/fEnBarAK0sI0VvfmEVr701fQ2ni3KGh4soleMVysCTxCdJZAVfrIBAOGcmbPYP6ExQOA7hCzl2xN5IRltU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712714747; c=relaxed/simple; bh=rSPuxWshjk6KM3Zz244DIla3FEyuZckCwH3lN5b2Q0w=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=D4Ciwwgk2DeWHHGPKYetYdTf+5qDmVE1MPZsZ89Y0tR5K+3qOpxDzNldsx/sr3Usg1fgLdz8n+bKWjuo+XrEPA9Bp2ZuuJr1S6JLjjIfPRPXq9Q9601aw5/lLnYIx0cAiTA66bPdQCM3z1pIfndYB1tqZYNqDQ1PgBH1RGyHlgA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Zs+TUnT1; 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="Zs+TUnT1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1EB50C433F1; Wed, 10 Apr 2024 02:05:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712714747; bh=rSPuxWshjk6KM3Zz244DIla3FEyuZckCwH3lN5b2Q0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zs+TUnT1tsb+9rwWNxw9b7vwP//ZKDg7KOBv/5UcztbNWg/M2eMmuzF5tMYJzpD9s qcf2eB850blz/suifLL0eXkQMMlXGpLzoMiyYuShKSU15tVP4H28025q11tJi+MvBE qdj7Vqo4gjYbRvbQz37uHQ7JgcoN8kd41V/ulLvJ5TrYS+gCO+FcoZGyAIAe7gQD9L v2kBwrcfwzXj/3xISonGxmwX766RlDfslIqx3nbDdrgBu3pg8FgtktypQD+yDtMyyj pAdFcm6tXz4eRcmqw7ncXZhhWP7POmEzP5dP16kErq5CzEMllsEVgc6w3lS+qJiOIl EDYaGIzC4irng== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v8 7/9] Squash to "selftests/bpf: Add bpf_rr scheduler & test" Date: Wed, 10 Apr 2024 10:05:22 +0800 Message-Id: <47fc82bd02706cb835e0cb3843b5f6665f329feb.1712714407.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang After squashing into this change, the patch "selftests/bpf: Add bpf_rr test" can be merged into the patch "selftests/bpf: Add bpf_rr scheduler" appending the following lines into commit log: ''' Using MPTCP_SCHED_TEST macro to add a new test for this bpf_rr scheduler, the arguments "1 1" means data has been sent on both net devices. Run this test by RUN_MPTCP_TEST macro. ''' And update the subject to "selftests/bpf: Add bpf_rr scheduler & test". Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 39 +------------------ .../selftests/bpf/progs/mptcp_bpf_rr.c | 1 + 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 045b32cf8b22..492a8b5de64f 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -532,41 +532,7 @@ skel_destroy: \ MPTCP_SCHED_TEST(first, WITH_DATA, WITHOUT_DATA); MPTCP_SCHED_TEST(bkup, WITH_DATA, WITHOUT_DATA); - -static void test_rr(void) -{ - struct mptcp_bpf_rr *rr_skel; - int server_fd, client_fd; - struct nstoken *nstoken; - struct bpf_link *link; - - rr_skel = mptcp_bpf_rr__open_and_load(); - if (!ASSERT_OK_PTR(rr_skel, "bpf_rr__open_and_load")) - return; - - link = bpf_map__attach_struct_ops(rr_skel->maps.rr); - if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) { - mptcp_bpf_rr__destroy(rr_skel); - return; - } - - nstoken = sched_init("subflow", "bpf_rr"); - if (!ASSERT_OK_PTR(nstoken, "sched_init:bpf_rr")) - goto fail; - server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); - client_fd = connect_to_fd(server_fd, 0); - - send_data(server_fd, client_fd, "bpf_rr"); - ASSERT_OK(has_bytes_sent(ADDR_1), "has_bytes_sent addr 1"); - ASSERT_OK(has_bytes_sent(ADDR_2), "has_bytes_sent addr 2"); - - close(client_fd); - close(server_fd); -fail: - cleanup_netns(nstoken); - bpf_link__destroy(link); - mptcp_bpf_rr__destroy(rr_skel); -} +MPTCP_SCHED_TEST(rr, WITH_DATA, WITH_DATA); static void test_red(void) { @@ -651,8 +617,7 @@ void test_mptcp(void) RUN_MPTCP_TEST(default); RUN_MPTCP_TEST(first); RUN_MPTCP_TEST(bkup); - if (test__start_subtest("rr")) - test_rr(); + RUN_MPTCP_TEST(rr); if (test__start_subtest("red")) test_red(); if (test__start_subtest("burst")) diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c index 39b7e1cfbbd5..05621467fe48 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_rr.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2022, SUSE. */ +/* Copyright (c) 2024, Kylin Software */ #include #include "bpf_tcp_helpers.h" From patchwork Wed Apr 10 02:05:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13623469 X-Patchwork-Delegate: mat@martineau.name 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 197564C6B for ; Wed, 10 Apr 2024 02:05:49 +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=1712714750; cv=none; b=YWIG8jfKcQBbL6piUDQc5kJf7onljZU1gELcqJg4cLZ+WEf2exEv6ND0YpuZkSOjwe+QRj/gtYZqA48E9vMAf1X4P7Sai7b/VA0LTgngnq/tGpKwMvuCREwHYJxxOPopR4NBB+xadAG8IiONij6qtEPPw+2IRhQrnZe58pV8Mq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712714750; c=relaxed/simple; bh=6u6LHhLf/DsufPB4FzzW4G7YdKLjRhLAay+RuDj1NII=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PSgpodqb/7WOX82Ng/tvaO6RJ5MPiKALWIa3y6zYA7S2Nyyt/U93dUHpEGrHlBZp4KvW/tO1tQMnNI351Di0kT73v3ZNzuQ2bgkZcDYiG30qd81NMTiyifq2BoN2KsNgobPZw07ChJemLMh5lQBeoCxw0k+T+TjgfSfvNUYzsIg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SOi8s4bl; 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="SOi8s4bl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E9A6FC433F1; Wed, 10 Apr 2024 02:05:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712714749; bh=6u6LHhLf/DsufPB4FzzW4G7YdKLjRhLAay+RuDj1NII=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SOi8s4blJF9fkSCVnRgqN4bnzXelLKWpapQiIQxAdpDGFLOy1P57WP4LHnFd82EGM 5Vv1n87hda3rZ8nvzD5WKOAu0jRy4Hc12AW/sbJnVeA5LLIzcPDixnzHqdh85B7MFG cqwrRrfHCdbp0MmTUGuJd5GjNz93Z/Llei//ouAygP5gBMX6LFliWLJm8fhZFHNI6a 1jBHFf7vjfywpDZr1hkmcGnC237kkT7yHOnNALqbohkLJemEGSbxiEcQxGXhNsh9Oj Rb8r7mbt0yBrcHuHf8085oDQVpY96y98K95UjKoGQUoYQxYoFzcOmIb4Rjzcp4RzOE my46GGYc7SPFQ== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v8 8/9] Squash to "selftests/bpf: Add bpf_red scheduler & test" Date: Wed, 10 Apr 2024 10:05:23 +0800 Message-Id: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang After squashing into this change, the patch "selftests/bpf: Add bpf_red test" can be merged into the patch "selftests/bpf: Add bpf_red scheduler" appending the following lines into commit log: ''' Using MPTCP_SCHED_TEST macro to add a new test for this bpf_red scheduler, the arguments "1 1" means data has been sent on both net devices. Run this test by RUN_MPTCP_TEST macro. ''' And update the subject to "selftests/bpf: Add bpf_red scheduler & test". Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 39 +------------------ .../selftests/bpf/progs/mptcp_bpf_red.c | 1 + 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 492a8b5de64f..527cccd96ba5 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -533,41 +533,7 @@ skel_destroy: \ MPTCP_SCHED_TEST(first, WITH_DATA, WITHOUT_DATA); MPTCP_SCHED_TEST(bkup, WITH_DATA, WITHOUT_DATA); MPTCP_SCHED_TEST(rr, WITH_DATA, WITH_DATA); - -static void test_red(void) -{ - struct mptcp_bpf_red *red_skel; - int server_fd, client_fd; - struct nstoken *nstoken; - struct bpf_link *link; - - red_skel = mptcp_bpf_red__open_and_load(); - if (!ASSERT_OK_PTR(red_skel, "bpf_red__open_and_load")) - return; - - link = bpf_map__attach_struct_ops(red_skel->maps.red); - if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) { - mptcp_bpf_red__destroy(red_skel); - return; - } - - nstoken = sched_init("subflow", "bpf_red"); - if (!ASSERT_OK_PTR(nstoken, "sched_init:bpf_red")) - goto fail; - server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); - client_fd = connect_to_fd(server_fd, 0); - - send_data(server_fd, client_fd, "bpf_red"); - ASSERT_OK(has_bytes_sent(ADDR_1), "has_bytes_sent addr 1"); - ASSERT_OK(has_bytes_sent(ADDR_2), "has_bytes_sent addr 2"); - - close(client_fd); - close(server_fd); -fail: - cleanup_netns(nstoken); - bpf_link__destroy(link); - mptcp_bpf_red__destroy(red_skel); -} +MPTCP_SCHED_TEST(red, WITH_DATA, WITH_DATA); static void test_burst(void) { @@ -618,8 +584,7 @@ void test_mptcp(void) RUN_MPTCP_TEST(first); RUN_MPTCP_TEST(bkup); RUN_MPTCP_TEST(rr); - if (test__start_subtest("red")) - test_red(); + RUN_MPTCP_TEST(red); if (test__start_subtest("burst")) test_burst(); } diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c index a3f3e5ca5278..62cba8f2d936 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_red.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2022, SUSE. */ +/* Copyright (c) 2024, Kylin Software */ #include #include "bpf_tcp_helpers.h" From patchwork Wed Apr 10 02:05:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 13623470 X-Patchwork-Delegate: mat@martineau.name 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 88FAEA5F for ; Wed, 10 Apr 2024 02:05: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=1712714751; cv=none; b=IBImtP2HZczYNRg7r6/UoNssqccI7wGjHn66k/Z4/00jz4ziYLBFzxX3exFLBruW464H2+IHQanm02dcdd4R4tgW7Wj7GRbg9BfV2r2t3CSY489JSKou774hPdp2PqRc6GE44mPnncaq5Jzs9G3YUg9+sYdc7/JoVpJFQGwHEK8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712714751; c=relaxed/simple; bh=Uq3xW360H0tQgchd/clWWQ/Ovam8EMp2/3sBv/y3A6U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cA2iKfgn7f0heUlsDyZt6+x5KR46swgPDTXWJCHSHB1xCHMWHa6E8oSDPlFCA0WMccGpuzNYiN2Rr7aCoDpv3d7oSlTnHVYaBe5TluRS0gyRkkOv3B1KQuTuiAIrfsaT50Lzguegt1/aGQTSSxiiDjOEbQS2Ym1m1E0tkdohdWk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tazWV6pF; 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="tazWV6pF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E6E1C433C7; Wed, 10 Apr 2024 02:05:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712714751; bh=Uq3xW360H0tQgchd/clWWQ/Ovam8EMp2/3sBv/y3A6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tazWV6pFr9fWZobR3TiBw7H2Wz5V/S4AUFrkapRM6AT6SoJm9D3d7APagJe2ob9jT 80WOXcFg0WHUW/93u5Lw6BoGPJ7uOe2/dRg8j0yAcJfXvENzj69gNJ5p2cSBui75a+ knRqxvSZqgfbuxui5rwLzWRxOSfMjgFyrSlCCicQQTVoSgEKbXCp0xMEIe+MFZlwKr Ics3K6/PLDzAiMJMHTAlrEWBlABc7RW2FRo60YRfudIfH3HXkRiYfaCE9P8GreLZn9 hjM6quG4OXV0hdjsdl0W0JBq3YI2ATw3jgeaW5GQ8S3Fa8YcB6/34u+YEqSvSE7ZNd 6I7m13ZAgRhfA== From: Geliang Tang To: mptcp@lists.linux.dev Cc: Geliang Tang Subject: [PATCH mptcp-next v8 9/9] Squash to "selftests/bpf: Add bpf_burst scheduler & test" Date: Wed, 10 Apr 2024 10:05:24 +0800 Message-Id: <52afc901ea14abd60805b3686cde1ce01a093b5b.1712714407.git.tanggeliang@kylinos.cn> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Geliang Tang After squashing into this change, the patch "selftests/bpf: Add bpf_burst test" can be merged into the patch "selftests/bpf: Add bpf_burst scheduler" appending the following lines into commit log: ''' Using MPTCP_SCHED_TEST macro to add a new test for this bpf_burst scheduler, the arguments "1 1" means data has been sent on both net devices. Run this test by RUN_MPTCP_TEST macro. ''' And update the subject to "selftests/bpf: Add bpf_burst scheduler & test". Signed-off-by: Geliang Tang --- .../testing/selftests/bpf/prog_tests/mptcp.c | 39 +------------------ .../selftests/bpf/progs/mptcp_bpf_burst.c | 1 + 2 files changed, 3 insertions(+), 37 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 527cccd96ba5..9a9964e41cba 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -534,41 +534,7 @@ MPTCP_SCHED_TEST(first, WITH_DATA, WITHOUT_DATA); MPTCP_SCHED_TEST(bkup, WITH_DATA, WITHOUT_DATA); MPTCP_SCHED_TEST(rr, WITH_DATA, WITH_DATA); MPTCP_SCHED_TEST(red, WITH_DATA, WITH_DATA); - -static void test_burst(void) -{ - struct mptcp_bpf_burst *burst_skel; - int server_fd, client_fd; - struct nstoken *nstoken; - struct bpf_link *link; - - burst_skel = mptcp_bpf_burst__open_and_load(); - if (!ASSERT_OK_PTR(burst_skel, "bpf_burst__open_and_load")) - return; - - link = bpf_map__attach_struct_ops(burst_skel->maps.burst); - if (!ASSERT_OK_PTR(link, "bpf_map__attach_struct_ops")) { - mptcp_bpf_burst__destroy(burst_skel); - return; - } - - nstoken = sched_init("subflow", "bpf_burst"); - if (!ASSERT_OK_PTR(nstoken, "sched_init:bpf_burst")) - goto fail; - server_fd = start_mptcp_server(AF_INET, ADDR_1, PORT_1, 0); - client_fd = connect_to_fd(server_fd, 0); - - send_data(server_fd, client_fd, "bpf_burst"); - ASSERT_OK(has_bytes_sent(ADDR_1), "has_bytes_sent addr 1"); - ASSERT_OK(has_bytes_sent(ADDR_2), "has_bytes_sent addr 2"); - - close(client_fd); - close(server_fd); -fail: - cleanup_netns(nstoken); - bpf_link__destroy(link); - mptcp_bpf_burst__destroy(burst_skel); -} +MPTCP_SCHED_TEST(burst, WITH_DATA, WITH_DATA); #define RUN_MPTCP_TEST(suffix) \ do { \ @@ -585,6 +551,5 @@ void test_mptcp(void) RUN_MPTCP_TEST(bkup); RUN_MPTCP_TEST(rr); RUN_MPTCP_TEST(red); - if (test__start_subtest("burst")) - test_burst(); + RUN_MPTCP_TEST(burst); } diff --git a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c index b3c811564866..6b79267562f1 100644 --- a/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c +++ b/tools/testing/selftests/bpf/progs/mptcp_bpf_burst.c @@ -1,5 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright (c) 2023, SUSE. */ +/* Copyright (c) 2024, Kylin Software */ #include #include