Skip to content

bpftool: Support symbolic map creation flags

Tianyi Chen bpf linux-kselftest lkml 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest2 patches 3 repliesIn review
  2. v22 patches 0 repliesSuperseded
  3. v12 patches 0 repliesSuperseded

Changes in v3 from the cover letter

- Expose the parser's existing flag table through feature list_builtins map_create_flags, and use that command for Bash completion. Update the feature help, manual and group completion for the new group.
- Explain that when comma is not a word break, Readline replaces the whole word and completion must repeat the already-entered flag prefix.
- Give invalid_combination its own comment: the kernel validates combinations of known flags; the preceding all_bits case instead checks that unknown numeric bits are passed through to the kernel.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2bpftool: Accept symbolic map creation flagstools/bpf/bpftool/Documentation/bpftool-feature.rst tools/bpf/bpftool/Documentation/bpftool-map.rst tools/bpf/bpftool/bash-completion/bpftool +3 more+125 -131 reply
2/2selftests/bpf: Cover symbolic bpftool map creation flagstools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c+100 -02 replies

Reviews trailers per patch

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

Read the v3 thread

Cover letter [PATCH bpf-next v3 0/2] bpftool: Support symbolic map creation flags

Add comma-separated BPF_F_* names to map create flags while retaining base-0 numeric input, with matching documentation, completion and tests.

Changes in v3:
- Expose the parser's existing flag table through feature list_builtins map_create_flags, and use that command for Bash completion. Update the feature help, manual and group completion for the new group.
- Explain that when comma is not a word break, Readline replaces the whole word and completion must repeat the already-entered flag prefix.
- Give invalid_combination its own comment: the kernel validates combinations of known flags; the preceding all_bits case instead checks that unknown numeric bits are passed through to the kernel.

These address the v2 review comments:
https://lore.kernel.org/r/693f57c4fee08005c6e67811a2fbc497e95fbb7373154e9ecdb1f9a76afaba60@mail.kernel.org
https://lore.kernel.org/r/7dbfef853aacc32527a352d59861e86f00b7a1e4634c070e569aed415792b926@mail.kernel.org

Validation of v3:
- Built bpftool and the focused BPF selftest runner with LLVM 20, alongside the ring-buffer and batch v2 series and recursive dump v3.
- All 29 bpftool_map_flags subtests passed in an x86-64 KVM guest running Linux 7.3.0-rc1, with no skips or failures.
- Plain, JSON and pretty-JSON list_builtins output contains exactly the 19 names in the parser table. The existing map shorthand still selects map_types.
- Real Bash Readline completion checked with default COMP_WORDBREAKS and with comma included: first and subsequent flags remain in one argument; after an explicit space, entries gets its normal trailing space. The new list_builtins group also completes correctly.
- Bash syntax, bpftool synchronization checks, diff checks and feature/map manual generation passed.

Changes in v2:
- Complete list elements without adding a trailing space, so the user can immediately append another comma-separated flag.

v2: https://lore.kernel.org/r/[email protected]
v1: https://lore.kernel.org/r/[email protected]
Request: https://github.com/libbpf/bpftool/issues/57

Tianyi Chen (2):
bpftool: Accept symbolic map creation flags selftests/bpf: Cover symbolic bpftool map creation flags

 .../bpftool/Documentation/bpftool-feature.rst |  10 +-
 .../bpf/bpftool/Documentation/bpftool-map.rst |  13 ++-
 tools/bpf/bpftool/bash-completion/bpftool     |  22 +++-
 tools/bpf/bpftool/feature.c                   |   7 +-
 tools/bpf/bpftool/main.h                      |   1 +
 tools/bpf/bpftool/map.c                       |  85 ++++++++++++++-
 .../bpf/prog_tests/bpftool_map_flags.c        | 100 ++++++++++++++++++
 7 files changed, 225 insertions(+), 13 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpftool_map_flags.c
Signature · 1 line
2.55.0