From: Martin KaFai Lau <martin.lau@linux.dev>
To: "Alexis Lothoré (eBPF Foundation)" <alexis.lothore@bootlin.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>, 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,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Bastien Curutchet <bastien.curutchet@bootlin.com>,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH bpf-next v3 3/4] selftests/bpf: integrate test_tc_tunnel.sh tests into test_progs
Date: Wed, 29 Oct 2025 12:56:28 -0700 [thread overview]
Message-ID: <1ac9d14e-4250-480c-b863-410be78ac6c6@linux.dev> (raw)
In-Reply-To: <20251027-tc_tunnel-v3-3-505c12019f9d@bootlin.com>
On 10/27/25 7:51 AM, Alexis Lothoré (eBPF Foundation) wrote:
> +static int run_server(struct subtest_cfg *cfg)
> +{
> + struct nstoken *nstoken = open_netns(SERVER_NS);
It is unlikely but still better to check for open_netns failure. Just in
case that the network changes/traffic is accidentally done in the
original netns. There are a few netns switching in the test. Please
followup.
> + int family = cfg->ipproto == 6 ? AF_INET6 : AF_INET;
> +
> + cfg->server_fd = start_reuseport_server(family, SOCK_STREAM,
> + cfg->server_addr, TEST_PORT,
> + TIMEOUT_MS, 1);
Why reuseport is needed? Does it have issue in bind() to the same
ip/port in the later sub-test?
> + close_netns(nstoken);
> + if (!ASSERT_NEQ(cfg->server_fd, NULL, "start server"))
I changed the check to ASSERT_OK_PTR. Also two other similar
ASSERT_[N]EQ(..., NULL, ...) usages.
> + return -1;
> +
> + return 0;
> +}
> +
> +static void stop_server(struct subtest_cfg *cfg)
> +{
> + close(*cfg->server_fd);
NULL check on cfg->server_fd is needed during the error path of
run_test(). cfg->server_fd is leaked also. I changed it to
free_fds(cfg->server_fd, 1) instead.
> + cfg->server_fd = NULL;
I don't think cfg will be reused, so I skip this NULL assignment.
> +}
> +
> +static int check_server_rx_data(struct subtest_cfg *cfg,
> + struct connection *conn, int len)
> +{
> + int err;
> +
> + memset(rx_buffer, 0, BUFFER_LEN);
> + err = recv(conn->server_fd, rx_buffer, len, 0);
> + if (!ASSERT_EQ(err, len, "check rx data len"))
> + return 1;
> + if (!ASSERT_MEMEQ(tx_buffer, rx_buffer, len, "check received data"))
> + return 1;
> + return 0;
> +}
> +
> +static struct connection *connect_client_to_server(struct subtest_cfg *cfg)
> +{
> + struct network_helper_opts opts = {.timeout_ms = 500};
> + int family = cfg->ipproto == 6 ? AF_INET6 : AF_INET;
> + struct connection *conn = NULL;
> + int client_fd, server_fd;
> +
> + conn = malloc(sizeof(struct connection));
> + if (!conn)
> + return conn;
> +
> + client_fd = connect_to_addr_str(family, SOCK_STREAM, cfg->server_addr,
> + TEST_PORT, &opts);
> +
> + if (client_fd < 0) {
> + free(conn);
> + return NULL;
> + }
> +
> + server_fd = accept(*cfg->server_fd, NULL, NULL);
> + if (server_fd < 0) {
Fixed the client_fd leak.
Applied. Thanks.
next prev parent reply other threads:[~2025-10-29 19:56 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 14:51 [PATCH bpf-next v3 0/4] selftests/bpf: convert test_tc_tunnel.sh to test_progs Alexis Lothoré (eBPF Foundation)
2025-10-27 14:51 ` [PATCH bpf-next v3 1/4] selftests/bpf: add tc helpers Alexis Lothoré (eBPF Foundation)
2025-10-27 14:51 ` [PATCH bpf-next v3 2/4] selftests/bpf: make test_tc_tunnel.bpf.c compatible with big endian platforms Alexis Lothoré (eBPF Foundation)
2025-10-27 14:51 ` [PATCH bpf-next v3 3/4] selftests/bpf: integrate test_tc_tunnel.sh tests into test_progs Alexis Lothoré (eBPF Foundation)
2025-10-29 19:56 ` Martin KaFai Lau [this message]
2025-10-30 14:04 ` Alexis Lothoré
2025-10-30 16:21 ` Martin KaFai Lau
2025-10-30 16:27 ` Alexis Lothoré
2025-10-27 14:51 ` [PATCH bpf-next v3 4/4] selftests/bpf: remove test_tc_tunnel.sh Alexis Lothoré (eBPF Foundation)
2025-10-29 19:40 ` [PATCH bpf-next v3 0/4] selftests/bpf: convert test_tc_tunnel.sh to test_progs 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=1ac9d14e-4250-480c-b863-410be78ac6c6@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