]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
selftests/bpf: Test direct packet access on non-linear skbs
authorPaul Chaignon <paul.chaignon@gmail.com>
Thu, 9 Oct 2025 20:12:18 +0000 (22:12 +0200)
committerMartin KaFai Lau <martin.lau@kernel.org>
Fri, 10 Oct 2025 17:43:04 +0000 (10:43 -0700)
commitbc3eeb42597a514a0b5286f085d91c8b34e4a532
treef6bd442ece2caefa9b6f852d1c1976f0cc5ba75a
parent8d45d0398d10966b022b96481feb619ae1695de0
selftests/bpf: Test direct packet access on non-linear skbs

This patch adds new selftests in the direct packet access suite, to
cover the non-linear case. The first six tests cover the behavior of
the bounds check with a non-linear skb. The last test adds a call to
bpf_skb_pull_data() to be able to access the packet.

Note that the size of the linear area includes the L2 header, but for
some program types like cgroup_skb, ctx->data points to the L3 header.
Therefore, a linear area of 22 bytes will have only 8 bytes accessible
to the BPF program (22 - ETH_HLEN). For that reason, the cgroup_skb test
cases access the packet at an offset of 8 bytes.

Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Link: https://patch.msgid.link/ceedbfd719e58f0d49dcceb8592f5e6bd38ce5fe.1760037899.git.paul.chaignon@gmail.com
tools/testing/selftests/bpf/progs/verifier_direct_packet_access.c