Skip to content

Support non-linear skbs for BPF_PROG_TEST_RUN

Paul Chaignon bpf 8 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest5 patches 0 repliesApplied 5/5
  2. v75 patches 2 repliesSuperseded
  3. v65 patches 4 repliesSuperseded
Earlier versions · 5
VersionPostedPatchesRepliesStatus
v55 patches6 repliesSuperseded
v45 patches0 repliesSuperseded
v35 patches2 repliesSuperseded
v24 patches3 repliesSuperseded
v14 patches9 repliesSuperseded

Changes in v8 from the cover letter

- Fix uninitialized data pointer spotted by Martin.
- Error out in test_loader if __linear_size tag is used on unsupported program types.

Patches in v8 All 5 applied

#Subject and filesSizeRepliesApplied
1/5bpf: Refactor cleanup of bpf_prog_test_run_skbnet/bpf/test_run.c+14 -120 repliesApplied
2/5bpf: Reorder bpf_prog_test_run_skb initializationnet/bpf/test_run.c+13 -130 repliesApplied
3/5bpf: Craft non-linear skbs in BPF_PROG_TEST_RUNnet/bpf/test_run.c+82 -210 repliesApplied
4/5selftests/bpf: Support non-linear flag in test loadertools/testing/selftests/bpf/progs/bpf_misc.h tools/testing/selftests/bpf/progs/verifier_direct_packet_access.c tools/testing/selftests/bpf/test_loader.c+32 -20 repliesApplied
5/5selftests/bpf: Test direct packet access on non-linear skbstools/testing/selftests/bpf/progs/verifier_direct_packet_access.c+58 -00 repliesApplied

Reviews trailers per patch

None of the 5 patches has a Reviewed-by or Acked-by.

Patch[email protected]
1/5T-b
2/5
3/5T-b
4/5
5/5

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v8 thread

Cover letter [PATCH bpf-next v8 0/5] Support non-linear skbs for BPF_PROG_TEST_RUN

This patchset adds support for non-linear skbs when running tc programs with BPF_PROG_TEST_RUN.

We've had multiple bugs in the past few years in Cilium caused by missing calls to bpf_skb_pull_data(). Daniel suggested this new BPF_PROG_TEST_RUN flag as a way to uncover these bugs in our BPF tests.

Changes in v8:
- Fix uninitialized data pointer spotted by Martin.
- Error out in test_loader if __linear_size tag is used on unsupported program types.
Changes in v7:
- Refactor use of 'size' variable as suggested by Martin.
- Support copying back the non-linear area to data_out.
- Minor code changes for readability, suggested by Martin.
Changes in v6:
- Disallow non-linear skb in prog_run_skb only for LWT programs instead of all non-L2 program types, on suggestion from Martin.
- Reject non-null ctx->data and ctx->data_meta, as suggested by Amery.
- Bound linear_size to 'PAGE_SIZE - headroom - tailroom' to be consistent with prog_run_xdp, as suggested by Martin.
- Allocate exactly linear_size bytes in bpf_test_init, spotted by Martin.
- Fix wrong conflict resolution on double-free fix, spotted by Amery.
- Rebased.
Changes in v5:
- Fix double free on data in first patch.
Changes in v4:
- Per Martin's suggestion, follow the XDP code pattern and use bpf_test_init only to initialize the linear area. That way data is directly copied to the right areas and we avoid the call to __pskb_pull_tail.
- Fixed outdated commit descriptions.
- Rebased.
Changes in v3:
- Dropped BPF_F_TEST_SKB_NON_LINEAR and used the ctx->data_end to determine if the user wants non-linear skb, as suggested by Amery.
- Introduced a second commit with a bit of refactoring to allow for the above requested change.
- Fix bug found by syzkaller on third commit.
- Rebased.
Changes in v2:
- Made the linear size configurable via ctx->data_end, as suggested by Amery.
- Reworked the selftests to allow testing the configurable linear size.
- Fix warnings reported by kernel test robot on first commit.
- Rebased.

Paul Chaignon (5):
bpf: Refactor cleanup of bpf_prog_test_run_skb
bpf: Reorder bpf_prog_test_run_skb initialization
bpf: Craft non-linear skbs in BPF_PROG_TEST_RUN selftests/bpf: Support non-linear flag in test loader selftests/bpf: Test direct packet access on non-linear skbs

 net/bpf/test_run.c                            | 143 +++++++++++++-----
 tools/testing/selftests/bpf/progs/bpf_misc.h  |   4 +
 .../bpf/progs/verifier_direct_packet_access.c |  59 ++++++++
 tools/testing/selftests/bpf/test_loader.c     |  29 +++-
 4 files changed, 193 insertions(+), 42 deletions(-)
Signature · 1 line
2.43.0