From nobody Sun Feb 8 12:58:30 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 5638528000F; Wed, 5 Nov 2025 08:23:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762330984; cv=none; b=jxk69lcKAXkqrquiwS8v67T4H0/r0FCaYEf6mI2o9KhUO4VKv60A7m/eZo6TvBLh9mW0PVZ6ZCs0vKDqPrVUNEZ+zz0dMBlLv6KKbptAHbKT8qF/6h5vApc+1AuQmgkqtMgSx3O7eGRA1C7a5b9blmqM/BgBuOF4qUa/3lhvlus= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762330984; c=relaxed/simple; bh=s9FOZHZQ0gEwjOw5MN7047kg7czzICVOZvrPjEPnDdY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=akYyRsZdyVMnfPNSILn3HYEULU9I2Kgysfiz7/g0XvLhKJPoP1Aaz6NZgv6yW/+QjkfRa3eDxBdPVSJ5OsV1cO9ge1JgJovGQ8Pn2L6/IXOwfFHabs+PdTsPAKq93pIAB2KjHuTGMgZL1uFNIFBpmJ/cnxGdbuSkHRw6T4/Z/9k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Ymsd+JrQ; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Ymsd+JrQ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id BA4204E4152D; Wed, 5 Nov 2025 08:23:00 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 90B9A60693; Wed, 5 Nov 2025 08:23:00 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 1B26F10B517EB; Wed, 5 Nov 2025 09:22:58 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1762330979; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=bfNLoThahEQND+oK8rEnCw7sjdDmfF2S825TIi1Qk88=; b=Ymsd+JrQHlSs+5ujzucb4JrT5xBrg7wF8dBe27+GO0Jakvn1dkByI+JaAfKjqYE+lHLCvJ V1pfXXXpjLVIuTL/XGale6u4Xzcfr7CL2jZneTY5L03NBcNewU3wFFQ/ZTzO2HFyl3/IdA Fr2HYhIvDbYZ47KkgzUJ/suYfs76Fz100WstjvDGdFjwJ2d9FUL3eTkmjwc5VQjAE9/DBY cMj/KCELlaMGSN6NwmSl0z6oPHu7txKk6ehN5Ec35RJ95jek/R6etyrSK2O4aNnYA1hkE7 OvD7P7uVmbQc5582mLXghChaBM2lq+xiJ0UqGCWCXOUq4D2N6/S9on8Npxj9+g== From: =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= Date: Wed, 05 Nov 2025 09:22:48 +0100 Subject: [PATCH bpf-next 1/2] selftests/bpf: systematically add SO_REUSEADDR in start_server_addr Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251105-start-server-soreuseaddr-v1-1-1bbd9c1f8d65@bootlin.com> References: <20251105-start-server-soreuseaddr-v1-0-1bbd9c1f8d65@bootlin.com> In-Reply-To: <20251105-start-server-soreuseaddr-v1-0-1bbd9c1f8d65@bootlin.com> To: Andrii Nakryiko , Eduard Zingerman , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: ebpf@linuxfoundation.org, Bastien Curutchet , Thomas Petazzoni , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 Some tests have to stop/start a server multiple time with the same listening address. Doing so without SO_REUSADDR leads to failures due to the socket still being in TIME_WAIT right after the first instance stop/before the second instance start. Instead of letting each test manually set SO_REUSEADDR on their servers, it can be done automatically by start_server_addr for all tests (and without any major downside). Enforce SO_REUSEADDR in start_server_addr for all tests. Signed-off-by: Alexis Lothor=C3=A9 (eBPF Foundation) --- tools/testing/selftests/bpf/network_helpers.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/network_helpers.c b/tools/testing/= selftests/bpf/network_helpers.c index 8bb09167399a..e99b9c5e66a3 100644 --- a/tools/testing/selftests/bpf/network_helpers.c +++ b/tools/testing/selftests/bpf/network_helpers.c @@ -97,7 +97,8 @@ int settimeo(int fd, int timeout_ms) int start_server_addr(int type, const struct sockaddr_storage *addr, sockl= en_t addrlen, const struct network_helper_opts *opts) { - int fd; + + int on =3D 1, fd; =20 if (!opts) opts =3D &default_opts; @@ -111,6 +112,12 @@ int start_server_addr(int type, const struct sockaddr_= storage *addr, socklen_t a if (settimeo(fd, opts->timeout_ms)) goto error_close; =20 + if (type =3D=3D SOCK_STREAM && + setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on))) { + log_err("Failed to enable SO_REUSEADDR"); + goto error_close; + } + if (opts->post_socket_cb && opts->post_socket_cb(fd, opts->cb_opts)) { log_err("Failed to call post_socket_cb"); --=20 2.51.2 From nobody Sun Feb 8 12:58:30 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (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 4B02128CF7C for ; Wed, 5 Nov 2025 08:23:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762330986; cv=none; b=P2NwBM1SUH5ZxIPpVycMqNT7khzAXecE8j2YJI0YldcnR6nhSK6C4q7W5MBdyqeBO6XlRZMPnU1WUnwcsR6V8MtWJ5vwE8m1S0hKB3onk5dqwHPJ5VuPu0jmTTe3Rz/IYGXdKFF+dtdXX3pP/2t+L0/Lw9gb08BzXk+hy53EbgE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762330986; c=relaxed/simple; bh=1UFFxHLngwWlfSIzQHo3B1yiskwv5UVLi/aHpHM5Dss=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=revDZSR0nQx8aKrbC7nWfkggdLSsd7Em0rL3J7qQ7zZ2LTlgPAs8s80QZHcO9JIl+USe1ouPygj/uYhCy/C9rre6uDBXVxhZFdsE/aSYWR7z63wYiCkbuTTT7bOWPgZql+H92lV54XEA0YQZLg7gK9EaDVz3QWtYsAr0LTRLYf8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=0rmCMxde; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="0rmCMxde" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 95F584E4152E; Wed, 5 Nov 2025 08:23:02 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 6AA9060693; Wed, 5 Nov 2025 08:23:02 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 0DCCA10B51983; Wed, 5 Nov 2025 09:22:59 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1762330981; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=74ihADtTOc2tE2Hs2544UzjSxwkF3iKFwI1Cs+oyQf8=; b=0rmCMxdeXj2jNn4Uo7ghVfAyZEat//FyRC+TGEL8oZLvuPgDGR0ALHKl38fc/K0zIhx0EH tLOWNi3/TVADbf6xirizl4HuD8leOPvmRykDN10vmy7cME9FKAgjbY2+QrTkqMneiHkAoP XaetKuZcGUKvvurCWOuS5oUHslIrMixuo2Q5/527u+PtxIk8WhSEC9EOIiUjEBPIWBvO68 oIsMQX2ZVHY+NPwYOsjVv/qbPCG1ZtoBhH3XLTssbainupZDEJwZQfA/BsRb8iMICgEmu9 cAE7buuf2kAXB7Al6tXojrExflx2Y9xK4jCEEpj1J7GgucXHbpsasLE8Th6dxw== From: =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= Date: Wed, 05 Nov 2025 09:22:49 +0100 Subject: [PATCH bpf-next 2/2] selftests/bpf: use start_server_str rather than start_reuseport_server in tc_tunnel Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20251105-start-server-soreuseaddr-v1-2-1bbd9c1f8d65@bootlin.com> References: <20251105-start-server-soreuseaddr-v1-0-1bbd9c1f8d65@bootlin.com> In-Reply-To: <20251105-start-server-soreuseaddr-v1-0-1bbd9c1f8d65@bootlin.com> To: Andrii Nakryiko , Eduard Zingerman , Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan Cc: ebpf@linuxfoundation.org, Bastien Curutchet , Thomas Petazzoni , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, =?utf-8?q?Alexis_Lothor=C3=A9_=28eBPF_Foundation=29?= X-Mailer: b4 0.14.3 X-Last-TLS-Session-Version: TLSv1.3 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=C3=A9 (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/tool= s/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; }; =20 struct connection { @@ -135,16 +135,18 @@ static int run_server(struct subtest_cfg *cfg) { int family =3D cfg->ipproto =3D=3D 6 ? AF_INET6 : AF_INET; struct nstoken *nstoken; + struct network_helper_opts opts =3D { + .timeout_ms =3D TIMEOUT_MS + }; =20 nstoken =3D open_netns(SERVER_NS); if (!ASSERT_OK_PTR(nstoken, "open server ns")) return -1; =20 - cfg->server_fd =3D start_reuseport_server(family, SOCK_STREAM, - cfg->server_addr, TEST_PORT, - TIMEOUT_MS, 1); + cfg->server_fd =3D 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; =20 return 0; @@ -152,7 +154,7 @@ static int run_server(struct subtest_cfg *cfg) =20 static void stop_server(struct subtest_cfg *cfg) { - free_fds(cfg->server_fd, 1); + close(cfg->server_fd); } =20 static int check_server_rx_data(struct subtest_cfg *cfg, @@ -188,7 +190,7 @@ static struct connection *connect_client_to_server(stru= ct subtest_cfg *cfg) return NULL; } =20 - server_fd =3D accept(*cfg->server_fd, NULL, NULL); + server_fd =3D 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) =20 /* Basic communication must work */ if (!ASSERT_OK(send_and_test_data(cfg, true), "connect without any encap"= )) - goto fail; + goto fail_close_server; =20 /* Attach encapsulation program to client */ if (!ASSERT_OK(configure_encapsulation(cfg), "configure encapsulation")) - goto fail; + goto fail_close_server; =20 /* 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; } =20 /* Replace kernel decapsulation with BPF decapsulation, test must pass */ if (!ASSERT_OK(configure_ebpf_decapsulation(cfg), "configure ebpf decapsu= lation")) - goto fail; + goto fail_close_server; ASSERT_OK(send_and_test_data(cfg, true), "connect with encap and decap pr= ogs"); =20 fail: stop_server(cfg); +fail_close_server: close_netns(nstoken); } =20 --=20 2.51.2