[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <01084af1-4f39-46f8-a278-9cfa7f242a11@linux.dev>
Date: Tue, 7 Jan 2025 11:48:36 -0800
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: "Bastien Curutchet (eBPF Foundation)" <bastien.curutchet@...tlin.com>
Cc: Alexei Starovoitov <ast@...nel.org>,
Daniel Borkmann <daniel@...earbox.net>, "David S. Miller"
<davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Jesper Dangaard Brouer <hawk@...nel.org>,
John Fastabend <john.fastabend@...il.com>,
Andrii Nakryiko <andrii@...nel.org>, Eduard Zingerman <eddyz87@...il.com>,
Song Liu <song@...nel.org>, Yonghong Song <yonghong.song@...ux.dev>,
KP Singh <kpsingh@...nel.org>, Stanislav Fomichev <sdf@...ichev.me>,
Hao Luo <haoluo@...gle.com>, Jiri Olsa <jolsa@...nel.org>,
Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
Alexis Lothore <alexis.lothore@...tlin.com>, netdev@...r.kernel.org,
bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/3] selftests/bpf: Migrate test_xdp_redirect.sh to
xdp_do_redirect.c
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;
> +}
Powered by blists - more mailing lists