summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/tracing_struct.c
diff options
context:
space:
mode:
authorPaul Chaignon <paul.chaignon@gmail.com>2025-10-09 22:11:43 +0200
committerMartin KaFai Lau <martin.lau@kernel.org>2025-10-10 10:43:03 -0700
commit838baa351cee86526973fb3ef49c0f4c1b2f3b0c (patch)
treeea4e5121be12ec9c6261f31c84d7caacbc2b1d92 /tools/testing/selftests/bpf/prog_tests/tracing_struct.c
parent57bb2f6717930a5e670da179c316159719b724a2 (diff)
bpf: Craft non-linear skbs in BPF_PROG_TEST_RUN
This patch adds support for crafting non-linear skbs in BPF test runs for tc programs. The size of the linear area is given by ctx->data_end, with a minimum of ETH_HLEN always pulled in the linear area. If ctx or ctx->data_end are null, a linear skb is used. This is particularly useful to test support for non-linear skbs in large codebases such as Cilium. We've had multiple bugs in the past few years where we were missing calls to bpf_skb_pull_data(). This support in BPF_PROG_TEST_RUN would allow us to automatically cover this case in our BPF tests. LWT program types are currently excluded in this patch. Allowing non-linear skbs for these programs would require a bit more care because they are able to call helpers (ex., bpf_clone_redirect, bpf_redirect) that themselves call eth_type_trans(). eth_type_trans() assumes there are at least ETH_HLEN bytes in the linear area. That may not be true for LWT programs as we already pulled the L2 header via the eth_type_trans() call in bpf_prog_test_run_skb(). In addition to the selftests introduced later in the series, this patch was tested by enabling non-linear skbs for all tc selftests programs and checking test failures were expected. Suggested-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Tested-by: syzbot@syzkaller.appspotmail.com Link: https://patch.msgid.link/5694d4d1af31bddf974afcb1bbb1e28b8998dcd0.1760037899.git.paul.chaignon@gmail.com
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/tracing_struct.c')
0 files changed, 0 insertions, 0 deletions