Skip to content

libbpf: Move section-defined program flags to prog_flags

Toke Høiland-Jørgensen bpf netdev 2 versions – Applied

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

Get series with b4
b4 am [email protected] change-id 20260901-libbpf-frags-flags-6bdeecd96114

Versions newest first · linked by author and title

  1. v3 Latest4 patches 3 repliesApplied 4/4
  2. v24 patches 5 repliesSuperseded

Changes in v3 from the cover letter

- Also fix destructive flag setting in bpf_verif_scale.c
- Reorder patches so fixups precede the libbpf change.

Patches in v3 All 4 applied

#Subject and filesSizeRepliesApplied
1/4bpftool: Set BPF_F_XDP_DEV_BOUND_ONLY flag non-destructivelytools/bpf/bpftool/prog.c+1 -12 repliesApplied
2/4selftests/bpf: Set BPF program flags non-destructivelytools/testing/selftests/bpf/prog_tests/attach_probe.c tools/testing/selftests/bpf/prog_tests/bpf_verif_scale.c tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c +2 more+9 -70 repliesApplied
3/4libbpf: Move section-defined program flags to prog_flagstools/lib/bpf/libbpf.c+14 -61 replyApplied
4/4selftests/bpf: Check for flag presence in bpf_program__flags()tools/testing/selftests/bpf/prog_tests/kernel_flag.c tools/testing/selftests/bpf/prog_tests/xdp_adjust_frags.c tools/testing/selftests/bpf/prog_tests/xdp_devmap_attach.c+11 -00 repliesApplied

Reviews trailers per patch

1 of 4 patches has a Reviewed-by or Acked-by.

PatchLarysa Zaremba
1/4R-b
2/4
3/4
4/4

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

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/4] libbpf: Move section-defined program flags to prog_flags

This series moves the libbpf section-defined program flags into bpf_program->prog_flags, thereby making them available for applications to inspect and modify before loading the program into the kernel. See patch 3 in the series for details.

Setting program flags with bpf_program__set_flags() was always potentially a destructive action, as it clobbers any existing flags. Since this changes the flags value to be pre-populated at initialisation, this clobbering can be visible in cases it wasn't before. To prevent any fallout, the first two commits fixes up existing in-tree users of bpf_program__set_flags() to be non-destructive.

v3:
- Also fix destructive flag setting in bpf_verif_scale.c
- Reorder patches so fixups precede the libbpf change.
v2:
- Use a generic section setup function that also applies to BPF_F_SLEEPABLE

---
Toke Høiland-Jørgensen (4):
bpftool: Set BPF_F_XDP_DEV_BOUND_ONLY flag non-destructively selftests/bpf: Set BPF program flags non-destructively
libbpf: Move section-defined program flags to prog_flags selftests/bpf: Check for flag presence in bpf_program__flags()

 tools/bpf/bpftool/prog.c                             |  2 +-
 tools/lib/bpf/libbpf.c                               | 20 ++++++++++++++------
 .../testing/selftests/bpf/prog_tests/attach_probe.c  |  6 ++++--
 .../selftests/bpf/prog_tests/bpf_verif_scale.c       |  2 +-
 tools/testing/selftests/bpf/prog_tests/kernel_flag.c |  3 +++
 .../selftests/bpf/prog_tests/kprobe_multi_test.c     |  2 +-
 .../selftests/bpf/prog_tests/xdp_adjust_frags.c      |  3 +++
 .../selftests/bpf/prog_tests/xdp_devmap_attach.c     |  5 +++++
 .../testing/selftests/bpf/prog_tests/xdp_metadata.c  |  4 ++--
 tools/testing/selftests/bpf/xdp_hw_metadata.c        |  2 +-
 10 files changed, 35 insertions(+), 14 deletions(-)

---
base-commit: 1555de33018fad06ca5dfa2fad5d3d1c6a6eb2fe
change-id: 20260901-libbpf-frags-flags-6bdeecd96114