From: "Toke Høiland-Jørgensen" <toke@redhat.com>
To: Amery Hung <ameryhung@gmail.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>,
Stanislav Fomichev <sdf@fomichev.me>,
Andrii Nakryiko <andrii@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
Martin KaFai Lau <martin.lau@linux.dev>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
KP Singh <kpsingh@kernel.org>, Hao Luo <haoluo@google.com>,
Jiri Olsa <jolsa@kernel.org>, Shuah Khan <shuah@kernel.org>,
netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH bpf 2/2] selftests/bpf: Update xdp_context_test_run test to check maximum metadata size
Date: Mon, 05 Jan 2026 20:04:24 +0100 [thread overview]
Message-ID: <87eco36fuv.fsf@toke.dk> (raw)
In-Reply-To: <CAMB2axPO7VENB-XUSUb5eU1ae7h0NBjbVukzxaObBDMMmkGYAw@mail.gmail.com>
Amery Hung <ameryhung@gmail.com> writes:
> On Mon, Jan 5, 2026 at 3:48 AM Toke Høiland-Jørgensen <toke@redhat.com> wrote:
>>
>> Update the selftest to check that the metadata size check takes the
>> xdp_frame size into account in bpf_prog_test_run. The original
>> check (for meta size 256) was broken because the data frame supplied was
>> smaller than this, triggering a different EINVAL return. So supply a
>> larger data frame for this test to make sure we actually exercise the
>> check we think we are.
>>
>> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
>> ---
>> .../bpf/prog_tests/xdp_context_test_run.c | 14 +++++++++++---
>> 1 file changed, 11 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c b/tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c
>> index ee94c281888a..24d7d6d8fea1 100644
>> --- a/tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c
>> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c
>> @@ -47,6 +47,7 @@ void test_xdp_context_test_run(void)
>> struct test_xdp_context_test_run *skel = NULL;
>> char data[sizeof(pkt_v4) + sizeof(__u32)];
>> char bad_ctx[sizeof(struct xdp_md) + 1];
>> + char large_data[256];
>> struct xdp_md ctx_in, ctx_out;
>> DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
>> .data_in = &data,
>> @@ -94,9 +95,6 @@ void test_xdp_context_test_run(void)
>> test_xdp_context_error(prog_fd, opts, 4, sizeof(__u32), sizeof(data),
>> 0, 0, 0);
>>
>> - /* Meta data must be 255 bytes or smaller */
>> - test_xdp_context_error(prog_fd, opts, 0, 256, sizeof(data), 0, 0, 0);
>> -
>> /* Total size of data must be data_end - data_meta or larger */
>> test_xdp_context_error(prog_fd, opts, 0, sizeof(__u32),
>> sizeof(data) + 1, 0, 0, 0);
>> @@ -116,6 +114,16 @@ void test_xdp_context_test_run(void)
>> test_xdp_context_error(prog_fd, opts, 0, sizeof(__u32), sizeof(data),
>> 0, 0, 1);
>>
>> + /* Meta data must be 216 bytes or smaller (256 - sizeof(struct
>> + * xdp_frame)). Test both nearest invalid size and nearest invalid
>> + * 4-byte-aligned size, and make sure data_in is large enough that we
>> + * actually hit the cheeck on metadata length
>
> nit: a typo here: cheeck -> check
Oops. Will leave this for the maintainers to fix up unless there's
another reason to respin, though...
>> + */
>> + opts.data_in = large_data;
>> + opts.data_size_in = sizeof(large_data);
>> + test_xdp_context_error(prog_fd, opts, 0, 217, sizeof(large_data), 0, 0, 0);
>> + test_xdp_context_error(prog_fd, opts, 0, 220, sizeof(large_data), 0, 0, 0);
>> +
>> test_xdp_context_test_run__destroy(skel);
>> }
>
> Reviewed-by: Amery Hung <ameryhung@gmail.com>
Thanks!
-Toke
next prev parent reply other threads:[~2026-01-05 19:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 11:47 [PATCH bpf 1/2] bpf, test_run: Subtract size of xdp_frame from allowed metadata size Toke Høiland-Jørgensen
2026-01-05 11:47 ` [PATCH bpf 2/2] selftests/bpf: Update xdp_context_test_run test to check maximum " Toke Høiland-Jørgensen
2026-01-05 18:44 ` Amery Hung
2026-01-05 19:04 ` Toke Høiland-Jørgensen [this message]
2026-01-05 18:36 ` [PATCH bpf 1/2] bpf, test_run: Subtract size of xdp_frame from allowed " Amery Hung
2026-01-06 19:50 ` 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=87eco36fuv.fsf@toke.dk \
--to=toke@redhat.com \
--cc=ameryhung@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--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=martin.lau@linux.dev \
--cc=netdev@vger.kernel.org \
--cc=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--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