From: Martin KaFai Lau <martin.lau@linux.dev>
To: "Alexis Lothoré (eBPF Foundation)" <alexis.lothore@bootlin.com>
Cc: Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
John Fastabend <john.fastabend@gmail.com>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
ebpf@linuxfoundation.org,
Bastien Curutchet <bastien.curutchet@bootlin.com>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: use start_server_str rather than start_reuseport_server in tc_tunnel
Date: Thu, 6 Nov 2025 15:29:31 -0800 [thread overview]
Message-ID: <f7ef09d8-d48a-4df7-99b7-c5f3c422cfa3@linux.dev> (raw)
In-Reply-To: <20251105-start-server-soreuseaddr-v1-2-1bbd9c1f8d65@bootlin.com>
On 11/5/25 12:22 AM, Alexis Lothoré (eBPF Foundation) wrote:
> Now that start_server_str enforces SO_REUSEADDR, there's no need to keep
> using start_reusport_server in tc_tunnel, especially since it only uses
> one server at a time.
>
> Replace start_reuseport_server with start_server_str in tc_tunnel test.
>
> Signed-off-by: Alexis Lothoré (eBPF Foundation) <alexis.lothore@bootlin.com>
> ---
> .../selftests/bpf/prog_tests/test_tc_tunnel.c | 27 ++++++++++++----------
> 1 file changed, 15 insertions(+), 12 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/test_tc_tunnel.c b/tools/testing/selftests/bpf/prog_tests/test_tc_tunnel.c
> index deea90aaefad..4d29256d8714 100644
> --- a/tools/testing/selftests/bpf/prog_tests/test_tc_tunnel.c
> +++ b/tools/testing/selftests/bpf/prog_tests/test_tc_tunnel.c
> @@ -69,7 +69,7 @@ struct subtest_cfg {
> int client_egress_prog_fd;
> int server_ingress_prog_fd;
> char extra_decap_mod_args[TUNNEL_ARGS_MAX_LEN];
> - int *server_fd;
> + int server_fd;
> };
>
> struct connection {
> @@ -135,16 +135,18 @@ static int run_server(struct subtest_cfg *cfg)
> {
> int family = cfg->ipproto == 6 ? AF_INET6 : AF_INET;
> struct nstoken *nstoken;
> + struct network_helper_opts opts = {
> + .timeout_ms = TIMEOUT_MS
> + };
>
> nstoken = open_netns(SERVER_NS);
> if (!ASSERT_OK_PTR(nstoken, "open server ns"))
> return -1;
>
> - cfg->server_fd = start_reuseport_server(family, SOCK_STREAM,
> - cfg->server_addr, TEST_PORT,
> - TIMEOUT_MS, 1);
> + cfg->server_fd = start_server_str(family, SOCK_STREAM, cfg->server_addr,
> + TEST_PORT, &opts);
> close_netns(nstoken);
> - if (!ASSERT_OK_PTR(cfg->server_fd, "start server"))
> + if (!ASSERT_OK_FD(cfg->server_fd, "start server"))
> return -1;
>
> return 0;
> @@ -152,7 +154,7 @@ static int run_server(struct subtest_cfg *cfg)
>
> static void stop_server(struct subtest_cfg *cfg)
> {
> - free_fds(cfg->server_fd, 1);
> + close(cfg->server_fd);
> }
>
> static int check_server_rx_data(struct subtest_cfg *cfg,
> @@ -188,7 +190,7 @@ static struct connection *connect_client_to_server(struct subtest_cfg *cfg)
> return NULL;
> }
>
> - server_fd = accept(*cfg->server_fd, NULL, NULL);
> + server_fd = accept(cfg->server_fd, NULL, NULL);
> if (server_fd < 0) {
> close(client_fd);
> free(conn);
> @@ -394,29 +396,30 @@ static void run_test(struct subtest_cfg *cfg)
>
> /* Basic communication must work */
> if (!ASSERT_OK(send_and_test_data(cfg, true), "connect without any encap"))
> - goto fail;
> + goto fail_close_server;
>
> /* Attach encapsulation program to client */
> if (!ASSERT_OK(configure_encapsulation(cfg), "configure encapsulation"))
> - goto fail;
> + goto fail_close_server;
>
> /* If supported, insert kernel decap module, connection must succeed */
> if (!cfg->expect_kern_decap_failure) {
> if (!ASSERT_OK(configure_kernel_decapsulation(cfg),
> "configure kernel decapsulation"))
> - goto fail;
> + goto fail_close_server;
> if (!ASSERT_OK(send_and_test_data(cfg, true),
> "connect with encap prog and kern decap"))
> - goto fail;
> + goto fail_close_server;
> }
>
> /* Replace kernel decapsulation with BPF decapsulation, test must pass */
> if (!ASSERT_OK(configure_ebpf_decapsulation(cfg), "configure ebpf decapsulation"))
> - goto fail;
> + goto fail_close_server;
> ASSERT_OK(send_and_test_data(cfg, true), "connect with encap and decap progs");
>
> fail:
> stop_server(cfg);
> +fail_close_server:
The "fail" and "fail_close_server" ordering is incorrect. I took this
chance to simplify it by doing run_server() before open_netns().
Applied. Thanks.
> close_netns(nstoken);
> }
>
>
next prev parent reply other threads:[~2025-11-06 23:29 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-05 8:22 [PATCH bpf-next 0/2] selftests/bpf: enfoce SO_REUSEADDR in basic test servers Alexis Lothoré (eBPF Foundation)
2025-11-05 8:22 ` [PATCH bpf-next 1/2] selftests/bpf: systematically add SO_REUSEADDR in start_server_addr Alexis Lothoré (eBPF Foundation)
2025-11-05 8:22 ` [PATCH bpf-next 2/2] selftests/bpf: use start_server_str rather than start_reuseport_server in tc_tunnel Alexis Lothoré (eBPF Foundation)
2025-11-06 23:29 ` Martin KaFai Lau [this message]
2025-11-06 23:30 ` [PATCH bpf-next 0/2] selftests/bpf: enfoce SO_REUSEADDR in basic test servers patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f7ef09d8-d48a-4df7-99b7-c5f3c422cfa3@linux.dev \
--to=martin.lau@linux.dev \
--cc=alexis.lothore@bootlin.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bastien.curutchet@bootlin.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=ebpf@linuxfoundation.org \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=thomas.petazzoni@bootlin.com \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox