All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next v5 0/3] bpftool: Fail map dump for maps that can't be iterated
@ 2026-10-16 19:47 Maxim Skokov
  2026-10-16 19:47 ` [PATCH bpf-next v5 1/3] bpftool: Print ENOTSUPP as "Operation not supported" Maxim Skokov
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Maxim Skokov @ 2026-10-16 19:47 UTC (permalink / raw)
  To: bpf
  Cc: qmo, ast, daniel, andrii, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, kuba, shuah,
	linux-kselftest, hi

"bpftool map dump" treats only ENOENT from bpf_map_get_next_key() as the
end of the map. Map types that can't be iterated (local storage, ringbuf,
bloom filter, arena, queue, stack) fail on the first key, and bpftool
prints an empty dump, "[]" or "Found 0 elements", with only a non-zero
exit status.

Patch 1 adds a helper that prints ENOTSUPP (524), which the kernel
returns from some BPF commands, as "Operation not supported" instead of
"Unknown error 524", and uses it for map create, map element
operations, map freeze and prog run. Patch 2 asks for the first key
before printing anything and fails with the map type and the error.
Patch 3 adds a test_progs case on a socket storage map, and on a queue
map without BTF for the plain output path.

The new test fails without patches 1-2 and passes with them; the other
bpftool_* selftests pass. v5 was tested on x86_64 under a bpf-next
kernel (d2141481a764e). The ENOTSUPP message was also checked by hand
for map getnext, lookup and dump on ringbuf and socket storage maps,
map create of an LRU hash without preallocation, and prog run on a
kprobe program; map delete, pop and freeze use the same helper but
were not checked by hand.

Changes in v5 (patches 1-2 of v4 are now patches 2-3):
- new patch 1: helper for ENOTSUPP, used in map dump and the other
  places where bpftool prints the result of a command that can return
  it (Daniel)
- patch 2 (map dump) uses the helper; kept Quentin's Acked-by as the
  change is only the error string
- selftests: check the full error text for socket storage
- rebase on current bpf-next

Changes in v4:
- selftests: socket storage always has BTF, so the "Found" check could
  never fail there; check the count on a queue map without BTF instead,
  and fix the comment on create_sk_storage_map() (bpf-ci)
- selftests: split into sk_storage and queue subtests, new subject
- rebase on current bpf-next, patch 1 unchanged

Changes in v3:
- shorter comment on the probe (Quentin)
- selftests: unlink the pin on every exit path, so a killed run doesn't
  leave a stale pin that fails every later run with EEXIST (Sashiko)
- collect Acked-by on patch 1

Changes in v2:
- probe the first key before any output instead of printing a hint for
  ENOTSUPP only, so every non-iterable type gets an error and stdout gets
  no "[]" (Alexei)
- drop the Fixes tag and use a neutral example map (Alexei)
- selftests: check that JSON output is only the error object and plain
  stdout has no elements or count; clear the output buffer before each
  run (Sashiko)
- multi-line comment style (bpf-ci)

v4: https://lore.kernel.org/bpf/20260928001513.7072-1-skokovmaksimevg@gmail.com/
v3: https://lore.kernel.org/bpf/20260926170149.541352-1-skokovmaksimevg@gmail.com/
v2: https://lore.kernel.org/bpf/20260925162031.27259-1-skokovmaksimevg@gmail.com/
v1: https://lore.kernel.org/bpf/20260924160732.485650-1-skokovmaksimevg@gmail.com/

Maxim Skokov (3):
  bpftool: Print ENOTSUPP as "Operation not supported"
  bpftool: Fail map dump for maps that can't be iterated
  selftests/bpf: Test bpftool map dump on maps that can't be iterated

 tools/bpf/bpftool/common.c                    |  11 ++
 tools/bpf/bpftool/main.h                      |   1 +
 tools/bpf/bpftool/map.c                       |  40 ++++--
 tools/bpf/bpftool/prog.c                      |   2 +-
 .../bpf/prog_tests/bpftool_map_dump.c         | 133 ++++++++++++++++++
 5 files changed, 175 insertions(+), 12 deletions(-)
 create mode 100644 tools/testing/selftests/bpf/prog_tests/bpftool_map_dump.c


base-commit: d2141481a764efdfaac70965ea28e8925f6a6b80
-- 
2.47.3


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-10-17 14:50 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-16 19:47 [PATCH bpf-next v5 0/3] bpftool: Fail map dump for maps that can't be iterated Maxim Skokov
2026-10-16 19:47 ` [PATCH bpf-next v5 1/3] bpftool: Print ENOTSUPP as "Operation not supported" Maxim Skokov
2026-10-16 20:08   ` Quentin Monnet
2026-10-16 19:47 ` [PATCH bpf-next v5 2/3] bpftool: Fail map dump for maps that can't be iterated Maxim Skokov
2026-10-16 19:47 ` [PATCH bpf-next v5 3/3] selftests/bpf: Test bpftool map dump on " Maxim Skokov
2026-10-16 20:08   ` qmo
2026-10-17 14:50 ` [PATCH bpf-next v5 0/3] bpftool: Fail map dump for " patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.