From: Martin KaFai Lau <martin.lau@linux.dev>
To: "Bastien Curutchet (eBPF Foundation)" <bastien.curutchet@bootlin.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
"David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
Jesper Dangaard Brouer <hawk@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>, Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
KP Singh <kpsingh@kernel.org>,
Stanislav Fomichev <sdf@fomichev.me>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Mykola Lysenko <mykolal@fb.com>,
Shuah Khan <shuah@kernel.org>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Alexis Lothore <alexis.lothore@bootlin.com>,
netdev@vger.kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] selftests/bpf: Migrate test_xdp_redirect.sh to xdp_do_redirect.c
Date: Tue, 7 Jan 2025 11:48:36 -0800 [thread overview]
Message-ID: <01084af1-4f39-46f8-a278-9cfa7f242a11@linux.dev> (raw)
In-Reply-To: <20250103-xdp_redirect-v1-2-e93099f59069@bootlin.com>
On 1/3/25 2:10 AM, Bastien Curutchet (eBPF Foundation) wrote:
> +static int ping_setup(struct test_data *data)
> +{
> + struct nstoken *nstoken = NULL;
> + int i;
> +
> + data->ns[0] = netns_new(NS0, false);
> + if (!ASSERT_OK_PTR(data->ns[0], "create ns"))
> + return -1;
> +
> + for (i = 1; i < NS_NB; i++) {
> + char ns_name[4] = {};
> +
> + snprintf(ns_name, 4, "NS%d", i);
> + data->ns[i] = netns_new(ns_name, false);
> + if (!ASSERT_OK_PTR(data->ns[i], "create ns"))
> + goto fail;
> +
> + nstoken = open_netns(NS0);
> + if (!ASSERT_OK_PTR(nstoken, "open NS0"))
> + goto fail;
> +
> + SYS(fail, "ip link add veth%d index %d%d%d type veth peer name veth0 netns %s",
> + i, i, i, i, ns_name);
> + SYS(fail, "ip link set veth%d up", i);
> + close_netns(nstoken);
> +
> + nstoken = open_netns(ns_name);
> + if (!ASSERT_OK_PTR(nstoken, "open ns"))
> + goto fail;
> +
> + SYS(fail, "ip addr add %s.%d/24 dev veth0", IPV4_NETWORK, i);
> + SYS(fail, "ip link set veth0 up");
> + close_netns(nstoken);
nstoken = NULL;
Otherwise, the other "goto fail;" of this loop will close and free the already
closed nstoken again.
Some of the other close_netns(nstoken) in this patch may have similar issue.
> + }
> +
> + return 0;
> +
> +fail:
> + close_netns(nstoken);
> + cleanup(data);
> + return -1;
> +}
next prev parent reply other threads:[~2025-01-07 19:48 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-03 10:10 [PATCH 0/3] selftests: bpf: Migrate test_xdp_redirect.sh to test_progs Bastien Curutchet (eBPF Foundation)
2025-01-03 10:10 ` [PATCH 1/3] selftests/bpf: test_xdp_redirect: Rename BPF sections Bastien Curutchet (eBPF Foundation)
2025-01-03 13:18 ` Alexis Lothoré
2025-01-03 10:10 ` [PATCH 2/3] selftests/bpf: Migrate test_xdp_redirect.sh to xdp_do_redirect.c Bastien Curutchet (eBPF Foundation)
2025-01-03 12:54 ` Alexis Lothoré
2025-01-06 7:54 ` Bastien Curutchet
2025-01-03 13:17 ` Alexis Lothoré
2025-01-06 8:24 ` Bastien Curutchet
2025-01-07 19:48 ` Martin KaFai Lau [this message]
2025-01-03 10:10 ` [PATCH 3/3] selftests/bpf: Migrate test_xdp_redirect.c to test_xdp_do_redirect.c Bastien Curutchet (eBPF Foundation)
2025-01-03 10:20 ` [PATCH 0/3] selftests: bpf: Migrate test_xdp_redirect.sh to test_progs Bastien Curutchet
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=01084af1-4f39-46f8-a278-9cfa7f242a11@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=davem@davemloft.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=mykolal@fb.com \
--cc=netdev@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