[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <c4ee29b6-5dfc-44f6-af5c-02d042b42cc0@linux.dev>
Date: Wed, 2 Oct 2024 14:24:08 -0700
From: Martin KaFai Lau <martin.lau@...ux.dev>
To: Florian Kauer <florian.kauer@...utronix.de>
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>,
Toke Høiland-Jørgensen <toke@...hat.com>,
David Ahern <dsahern@...nel.org>, Hangbin Liu <liuhangbin@...il.com>,
Mykola Lysenko <mykolal@...com>, Shuah Khan <shuah@...nel.org>,
netdev@...r.kernel.org, bpf@...r.kernel.org, linux-kernel@...r.kernel.org,
Jesper Dangaard Brouer <brouer@...hat.com>, linux-kselftest@...r.kernel.org
Subject: Re: [PATCH net v4 2/2] bpf: selftests: send packet to devmap redirect
XDP
On 9/11/24 1:41 AM, Florian Kauer wrote:
> @@ -25,14 +28,11 @@ static void test_xdp_with_devmap_helpers(void)
> if (!ASSERT_OK_PTR(skel, "test_xdp_with_devmap_helpers__open_and_load"))
> return;
>
> - dm_fd = bpf_program__fd(skel->progs.xdp_redir_prog);
> - err = bpf_xdp_attach(IFINDEX_LO, dm_fd, XDP_FLAGS_SKB_MODE, NULL);
> + dm_fd_redir = bpf_program__fd(skel->progs.xdp_redir_prog);
> + err = bpf_xdp_attach(IFINDEX_LO, dm_fd_redir, XDP_FLAGS_SKB_MODE, NULL);
> if (!ASSERT_OK(err, "Generic attach of program with 8-byte devmap"))
> goto out_close;
>
> - err = bpf_xdp_detach(IFINDEX_LO, XDP_FLAGS_SKB_MODE, NULL);
> - ASSERT_OK(err, "XDP program detach");
> -
> dm_fd = bpf_program__fd(skel->progs.xdp_dummy_dm);
> map_fd = bpf_map__fd(skel->maps.dm_ports);
> err = bpf_prog_get_info_by_fd(dm_fd, &info, &len);
> @@ -47,6 +47,23 @@ static void test_xdp_with_devmap_helpers(void)
> ASSERT_OK(err, "Read devmap entry");
> ASSERT_EQ(info.id, val.bpf_prog.id, "Match program id to devmap entry prog_id");
>
> + /* send a packet to trigger any potential bugs in there */
> + char data[10] = {};
> + DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
> + .data_in = &data,
> + .data_size_in = 10,
> + .flags = BPF_F_TEST_XDP_LIVE_FRAMES,
> + .repeat = 1,
> + );
> + err = bpf_prog_test_run_opts(dm_fd_redir, &opts);
I am seeing pr_warn on "Driver unsupported XDP return value on prog
xdp_redir_prog...". There is an existing bug in xdp_redir_prog(). I fixed it
with this:
SEC("xdp")
int xdp_redir_prog(struct xdp_md *ctx)
{
- return bpf_redirect_map(&dm_ports, 1, 0);
+ return bpf_redirect_map(&dm_ports, 0, 0);
}
and also wrapped the above "lo" test in its own netns also.
Applied to the bpf tree. Thanks.
Powered by blists - more mailing lists