Skip to content

Dynptr convenience helpers

Joanne Koong bpf 2 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest6 patches 50 repliesIn review
  2. v18 patches 24 repliesSuperseded

Changes in v2 from the cover letter

v1: https://lore.kernel.org/bpf/[email protected]/
* Drop patch adding "bpf_dynptr_data_rdonly"
* Add offset arg for bpf_dynptr_clone, to advance offset for cloned dynptr
* bpf_dynptr_iterator operates on a cloned dynptr instead of the original (Kumar,Andrii)

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/6bpf: Add bpf_dynptr_trim and bpf_dynptr_advanceinclude/uapi/linux/bpf.h kernel/bpf/helpers.c tools/include/uapi/linux/bpf.h+103 -00 replies
2/6bpf: Add bpf_dynptr_is_null and bpf_dynptr_is_rdonlyinclude/uapi/linux/bpf.h kernel/bpf/helpers.c scripts/bpf_doc.py +1 more+77 -30 replies
3/6bpf: Add bpf_dynptr_get_size and bpf_dynptr_get_offsetinclude/linux/bpf.h include/uapi/linux/bpf.h kernel/bpf/helpers.c +2 more+90 -60 replies
4/6bpf: Add bpf_dynptr_cloneinclude/uapi/linux/bpf.h kernel/bpf/helpers.c kernel/bpf/verifier.c +1 more+173 -510 replies
5/6bpf: Add bpf_dynptr_iteratorinclude/uapi/linux/bpf.h kernel/bpf/helpers.c kernel/bpf/verifier.c +1 more+170 -150 replies
6/6selftests/bpf: Tests for dynptr convenience helperstools/testing/selftests/bpf/prog_tests/dynptr.c tools/testing/selftests/bpf/progs/dynptr_fail.c tools/testing/selftests/bpf/progs/dynptr_success.c+1002 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 bpf-next 0/6] Dynptr convenience helpers

This patchset is the 3rd in the dynptr series. The 1st can be found here [0] and the 2nd can be found here [1].

In this patchset, the following convenience helpers are added for interacting with bpf dynamic pointers:

* bpf_dynptr_data_rdonly
* bpf_dynptr_trim
* bpf_dynptr_advance
* bpf_dynptr_is_null
* bpf_dynptr_is_rdonly
* bpf_dynptr_get_size
* bpf_dynptr_get_offset
* bpf_dynptr_clone
* bpf_dynptr_iterator

Querying dynptr information is abstracted to helper functions instead of directly exposing bpf_dynptr internals because this avoids imposing restrictions on the dynptr struct in the case of any future modifications, as well as consolidates any logic for parsing the fields to one place.

In the future, some of these convenience helper calls will be inlined.

Please note that this patchset will be rebased on top of dynptr refactoring/fixes once that is landed upstream.

[0] https://lore.kernel.org/bpf/[email protected]/
[1] https://lore.kernel.org/bpf/[email protected]/

v1 -> v2:
v1: https://lore.kernel.org/bpf/[email protected]/
* Drop patch adding "bpf_dynptr_data_rdonly"
* Add offset arg for bpf_dynptr_clone, to advance offset for cloned dynptr
* bpf_dynptr_iterator operates on a cloned dynptr instead of the original (Kumar,Andrii)

Joanne Koong (6):
bpf: Add bpf_dynptr_trim and bpf_dynptr_advance
bpf: Add bpf_dynptr_is_null and bpf_dynptr_is_rdonly
bpf: Add bpf_dynptr_get_size and bpf_dynptr_get_offset
bpf: Add bpf_dynptr_clone
bpf: Add bpf_dynptr_iterator
selftests/bpf: Tests for dynptr convenience helpers

 include/linux/bpf.h                           |   2 +-
 include/uapi/linux/bpf.h                      | 114 ++++
 kernel/bpf/helpers.c                          | 218 ++++++-
 kernel/bpf/verifier.c                         | 205 +++++--
 kernel/trace/bpf_trace.c                      |   4 +-
 scripts/bpf_doc.py                            |   3 +
 tools/include/uapi/linux/bpf.h                | 114 ++++
 .../testing/selftests/bpf/prog_tests/dynptr.c |  31 +
 .../testing/selftests/bpf/progs/dynptr_fail.c | 439 ++++++++++++++
 .../selftests/bpf/progs/dynptr_success.c      | 534 +++++++++++++++++-
 10 files changed, 1601 insertions(+), 63 deletions(-)
Signature · 1 line
2.30.2