From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-174.mta0.migadu.com (out-174.mta0.migadu.com [91.218.175.174]) (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 E727434D3AE for ; Thu, 6 Nov 2025 23:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.174 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762471784; cv=none; b=OzycEqE8En+0jKJXVk+NCSwbGZ0h1r3oPkK5QIyyoWoB3UFeBvPRqoWvmb5mS04xKWpX28FDFaIhpWx+Etx92MZx+u7deuo3sw3ALaJFEvtjfxQ9saLDFXzUJOtn1bfN8boGXV60BaI63aCfBlmq3NEgmJbzG6bDFS/Qb+2/5K0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762471784; c=relaxed/simple; bh=IZsbsvD6VdbkSJeqICAb4/zYF9wEny5Gu/vznxODllw=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=D3YfKoqxe7pA7/0gMALlIoYTS5XnxtnIPxO3rdf/ZJdz0ZC4klvHljSvA3q4VjJD/R/DZDCNUJyvbaIp1UaNAYSG1ukIucQ9Jqo9du0AuPfMc/USmZsG3FiL0nIHBhtev0mp04iZn9B8vrYgan7TLXp4S0ebvc4TSq5sWUysfGE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=rL7RkmA6; arc=none smtp.client-ip=91.218.175.174 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="rL7RkmA6" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1762471778; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kUfRbFpMkZjHgLZGCIbIhg4jivnYxpp+H4gCu5s3EEI=; b=rL7RkmA6YseGsoWHt7KKIdbPnjxFzi5T/K7ev2MZ5hBT4rqgr8/C5HdsFMGyloV9LWpCxv 0b9+5l863s6QyQNvDIOSGpb+JgNmUTe1LuGMZ+Cv5z3CM2bhudToLb3ln4spVAzfOkgzVH aPlT/etK4/4z88zv11NSw85PGvRfyvw= Date: Thu, 6 Nov 2025 15:29:31 -0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next 2/2] selftests/bpf: use start_server_str rather than start_reuseport_server in tc_tunnel To: =?UTF-8?Q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= Cc: Andrii Nakryiko , Eduard Zingerman , Alexei Starovoitov , Daniel Borkmann , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , ebpf@linuxfoundation.org, Bastien Curutchet , Thomas Petazzoni , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org References: <20251105-start-server-soreuseaddr-v1-0-1bbd9c1f8d65@bootlin.com> <20251105-start-server-soreuseaddr-v1-2-1bbd9c1f8d65@bootlin.com> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Martin KaFai Lau In-Reply-To: <20251105-start-server-soreuseaddr-v1-2-1bbd9c1f8d65@bootlin.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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) > --- > .../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); > } > >