[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8b72630d-8804-4b80-b4bd-857066b64b08@linux.dev>
Date: Fri, 10 Jan 2025 17:45:45 -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 bpf-next v2 2/3] selftests/bpf: Migrate
test_xdp_redirect.sh to xdp_do_redirect.c
On 1/10/25 1:21 AM, Bastien Curutchet (eBPF Foundation) wrote:
> +static void ping_test(struct test_data *data)
> +{
> + struct test_xdp_redirect *skel = NULL;
> + struct xdp_dummy *skel_dummy = NULL;
> + struct nstoken *nstoken = NULL;
> + int i, ret;
> +
> + skel_dummy = xdp_dummy__open_and_load();
> + if (!ASSERT_OK_PTR(skel_dummy, "open and load xdp_dummy skeleton"))
> + goto close;
> +
> + for (i = 1; i < NS_NB; i++) {
> + char ns_name[4] = {};
> +
> + snprintf(ns_name, 4, "NS%d", i);
> + nstoken = open_netns(ns_name);
> + if (!ASSERT_OK_PTR(nstoken, "open ns"))
> + goto close;
> +
> + ret = bpf_xdp_attach(if_nametoindex("veth0"),
> + bpf_program__fd(skel_dummy->progs.xdp_dummy_prog),
> + data->xdp_flags, NULL);
> + if (!ASSERT_GE(ret, 0, "bpf_xdp_attach dummy_prog"))
> + goto close;
> +
> + close_netns(nstoken);
> + nstoken = NULL;
> + }
> +
> + skel = test_xdp_redirect__open_and_load();
> + if (!ASSERT_OK_PTR(skel, "open and load skeleton"))
> + goto close;
> +
> + nstoken = open_netns(NS0);
> + if (!ASSERT_OK_PTR(nstoken, "open NS0"))
> + goto close;
> +
> + ret = bpf_xdp_attach(VETH2_INDEX,
> + bpf_program__fd(skel->progs.xdp_redirect_to_111),
> + data->xdp_flags, NULL);
> + if (!ASSERT_GE(ret, 0, "bpf_xdp_attach"))
> + goto close;
> +
> + ret = bpf_xdp_attach(VETH1_INDEX,
> + bpf_program__fd(skel->progs.xdp_redirect_to_222),
> + data->xdp_flags, NULL);
> + if (!ASSERT_GE(ret, 0, "bpf_xdp_attach"))
> + goto close;
> +
> + close_netns(nstoken);
> + nstoken = NULL;
> +
> + nstoken = open_netns(NS1);
> + if (!ASSERT_OK_PTR(nstoken, "open NS1"))
> + goto close;
> +
> + SYS(close, "ping -c 1 %s.2", IPV4_NETWORK);
I added "> /dev/null" to remove noise for common case.
Applied. Thanks.
Powered by blists - more mailing lists