Skip to content
Commit 47316f4a authored by Zvi Effron's avatar Zvi Effron Committed by Alexei Starovoitov
Browse files

bpf: Support input xdp_md context in BPF_PROG_TEST_RUN



Support passing a xdp_md via ctx_in/ctx_out in bpf_attr for
BPF_PROG_TEST_RUN.

The intended use case is to pass some XDP meta data to the test runs of
XDP programs that are used as tail calls.

For programs that use bpf_prog_test_run_xdp, support xdp_md input and
output. Unlike with an actual xdp_md during a non-test run, data_meta must
be 0 because it must point to the start of the provided user data. From
the initial xdp_md, use data and data_end to adjust the pointers in the
generated xdp_buff. All other non-zero fields are prohibited (with
EINVAL). If the user has set ctx_out/ctx_size_out, copy the (potentially
different) xdp_md back to the userspace.

We require all fields of input xdp_md except the ones we explicitly
support to be set to zero. The expectation is that in the future we might
add support for more fields and we want to fail explicitly if the user
runs the program on the kernel where we don't yet support them.

Co-developed-by: default avatarCody Haas <chaas@riotgames.com>
Co-developed-by: default avatarLisa Watanabe <lwatanabe@riotgames.com>
Signed-off-by: default avatarCody Haas <chaas@riotgames.com>
Signed-off-by: default avatarLisa Watanabe <lwatanabe@riotgames.com>
Signed-off-by: default avatarZvi Effron <zeffron@riotgames.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Acked-by: default avatarYonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210707221657.3985075-3-zeffron@riotgames.com
parent 7445cf31
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment