Skip to content

Conversation

pchaigno
Copy link
Member

No description provided.

@pchaigno pchaigno force-pushed the test-non-linear-skb branch 30 times, most recently from ff3d651 to c4fcfe4 Compare August 31, 2025 16:53
@pchaigno pchaigno force-pushed the test-non-linear-skb branch 3 times, most recently from 2b271f3 to b23e79a Compare September 12, 2025 18:56
@pchaigno pchaigno force-pushed the test-non-linear-skb branch 16 times, most recently from 1c563bb to 4708da7 Compare September 18, 2025 08:44
This bit of refactoring aims to simplify the next patch in this series,
in which freeing 'data' is a bit less straightforward.

Tested-by: [email protected]
Signed-off-by: Paul Chaignon <[email protected]>
This patch reorders the initialization of bpf_prog_test_run_skb to
simplify the subsequent patch. Program types are checked first, followed
by the ctx init, and finally the data init. With the subsequent patch,
program types and the ctx init provide information that is used in the
data init. Thus, we need the data init to happen last.

Signed-off-by: Paul Chaignon <[email protected]>
This patch adds support for crafting non-linear skbs in BPF test runs
for tc programs, via a new flag BPF_F_TEST_SKB_NON_LINEAR. When this
flag is set, the size of the linear area is given by ctx->data_end, with
a minimum of ETH_HLEN always pulled in the linear area.

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.

In addition to the selftests introduced later in the series, this patch
was tested by setting BPF_F_TEST_SKB_NON_LINEAR for all tc selftests
programs and checking test failures were expected.

Tested-by: [email protected]
Suggested-by: Daniel Borkmann <[email protected]>
Signed-off-by: Paul Chaignon <[email protected]>
This patch adds support for a new tag __linear_size in the test loader,
to specify the size of the linear area in case of non-linear skbs. If
the tag is absent or null, a linear skb is crafted.

Signed-off-by: Paul Chaignon <[email protected]>
This patch adds new selftests in the direct packet access suite, to
cover the non-linear case with BPF_F_TEST_SKB_NON_LINEAR. The three
first tests cover the behavior of the bounds check with a non-linear
skb (first two with min. linear size, third with long enough linear
size). The last test adds a call to bpf_skb_pull_data() to be able to
access the packet.

Signed-off-by: Paul Chaignon <[email protected]>
@pchaigno pchaigno force-pushed the test-non-linear-skb branch 3 times, most recently from 7b2af52 to d9291e3 Compare September 18, 2025 10:28
Signed-off-by: Paul Chaignon <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant