bpf: Add BPF program and map iterators as built-in BPF programs.
authorAlexei Starovoitov <ast@kernel.org>
Wed, 19 Aug 2020 04:27:57 +0000 (21:27 -0700)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 20 Aug 2020 14:02:36 +0000 (16:02 +0200)
commitf0fdfefb2d4da5b76c3f810be0edb2ab90360224
tree453bb56dfa2c9e377bf1086ddf76670f5a4a56e2
parent005142b8a1f0f32d33fbe04b728464c1b7acfa0e
bpf: Add BPF program and map iterators as built-in BPF programs.

The program and map iterators work similar to seq_file-s.
Once the program is pinned in bpffs it can be read with "cat" tool
to print human readable output. In this case about BPF programs and maps.
For example:
$ cat /sys/fs/bpf/progs.debug
  id name            attached
   5 dump_bpf_map    bpf_iter_bpf_map
   6 dump_bpf_prog   bpf_iter_bpf_prog
$ cat /sys/fs/bpf/maps.debug
  id name            max_entries
   3 iterator.rodata     1

To avoid kernel build dependency on clang 10 separate bpf skeleton generation
into manual "make" step and instead check-in generated .skel.h into git.

Unlike 'bpftool prog show' in-kernel BTF name is used (when available)
to print full name of BPF program instead of 16-byte truncated name.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/20200819042759.51280-3-alexei.starovoitov@gmail.com
kernel/bpf/preload/iterators/.gitignore [new file with mode: 0644]
kernel/bpf/preload/iterators/Makefile [new file with mode: 0644]
kernel/bpf/preload/iterators/README [new file with mode: 0644]
kernel/bpf/preload/iterators/iterators.bpf.c [new file with mode: 0644]
kernel/bpf/preload/iterators/iterators.skel.h [new file with mode: 0644]