selftests/bpf: Add test for xdp_md context in BPF_PROG_TEST_RUN
authorZvi Effron <zeffron@riotgames.com>
Wed, 7 Jul 2021 22:16:57 +0000 (22:16 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 8 Jul 2021 02:51:13 +0000 (19:51 -0700)
commit939b9c6890da97ea19822e3bd295816175b86fbd
tree4f999fefe1fa29fbc1a4c27169ed5d0f200285dd
parentec94670fcb3bdeaf3baaa8d86f54e90a5557f53b
selftests/bpf: Add test for xdp_md context in BPF_PROG_TEST_RUN

Add a test for using xdp_md as a context to BPF_PROG_TEST_RUN for XDP
programs.

The test uses a BPF program that takes in a return value from XDP
meta data, then reduces the size of the XDP meta data by 4 bytes.

Test cases validate the possible failure cases for passing in invalid
xdp_md contexts, that the return value is successfully passed
in, and that the adjusted meta data is successfully copied out.

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-5-zeffron@riotgames.com
tools/testing/selftests/bpf/prog_tests/xdp_context_test_run.c [new file with mode: 0644]
tools/testing/selftests/bpf/progs/test_xdp_context_test_run.c [new file with mode: 0644]