]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Support input xdp_md context in BPF_PROG_TEST_RUN
authorZvi Effron <zeffron@riotgames.com>
Wed, 7 Jul 2021 22:16:55 +0000 (22:16 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 8 Jul 2021 02:51:13 +0000 (19:51 -0700)
commitc19844c780bc417a7a47497eba7ee07f8ea8d7f8
tree078b3af08b95b3ef685452b5bb4be8fd95b17618
parentb0111bb7db80737b19256a46c12f3641114ec687
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: Cody Haas <chaas@riotgames.com>
Co-developed-by: Lisa Watanabe <lwatanabe@riotgames.com>
Signed-off-by: Cody Haas <chaas@riotgames.com>
Signed-off-by: Lisa Watanabe <lwatanabe@riotgames.com>
Signed-off-by: Zvi Effron <zeffron@riotgames.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210707221657.3985075-3-zeffron@riotgames.com
include/uapi/linux/bpf.h
net/bpf/test_run.c