1BPFTOOL-ITER(8)                                                BPFTOOL-ITER(8)
2
3
4

NAME

6       bpftool-iter - tool to create BPF iterators
7

SYNOPSIS

9          bpftool [OPTIONS] iter COMMAND
10
11          COMMANDS := { pin | help }
12

ITER COMMANDS

14       bpftool iter pin OBJ PATH [map MAP]
15       bpftool iter help
16
17       OBJ := /a/file/of/bpf_iter_target.o
18       MAP := { id MAP_ID | pinned FILE }
19
20

DESCRIPTION

22          bpftool iter pin OBJ PATH [map MAP]
23                 A bpf iterator combines a kernel iterating of particular ker‐
24                 nel data (e.g., tasks, bpf_maps, etc.)   and  a  bpf  program
25                 called  for  each  kernel  data  object  (e.g., one task, one
26                 bpf_map, etc.). User space can read  kernel  iterator  output
27                 through read() syscall.
28
29                 The  pin  command creates a bpf iterator from OBJ, and pin it
30                 to PATH. The PATH should be located in bpffs mount.  It  must
31                 not  contain  a  dot  character  ('.'), which is reserved for
32                 future extensions of bpffs.
33
34                 Map element bpf iterator requires an additional parameter MAP
35                 so  bpf  program  can iterate over map elements for that map.
36                 User can have a bpf program in kernel to run  with  each  map
37                 element,  do  checking,  filtering, aggregation, etc. without
38                 copying data to user space.
39
40                 User can then cat PATH to see the bpf iterator output.
41
42          bpftool iter help
43                 Print short help message.
44

OPTIONS

46          -h, --help
47                 Print short help message (similar to bpftool help).
48
49          -V, --version
50                 Print  version  number  (similar  to  bpftool  version),  and
51                 optional  features  that  were included when bpftool was com‐
52                 piled. Optional features include linking  against  libbfd  to
53                 provide  the  disassembler for JIT-ted programs (bpftool prog
54                 dump jited) and usage of BPF skeletons  (some  features  like
55                 bpftool  prog  profile  or  showing  pids  associated  to BPF
56                 objects may rely on it).
57
58          -j, --json
59                 Generate JSON output. For commands that cannot produce  JSON,
60                 this option has no effect.
61
62          -p, --pretty
63                 Generate human-readable JSON output. Implies -j.
64
65          -d, --debug
66                 Print  all logs available, even debug-level information. This
67                 includes logs from libbpf as well as from the verifier,  when
68                 attempting to load programs.
69

EXAMPLES

71       # bpftool iter pin bpf_iter_netlink.o /sys/fs/bpf/my_netlink
72
73          Create a file-based bpf iterator from bpf_iter_netlink.o and pin it
74          to /sys/fs/bpf/my_netlink
75
76       # bpftool iter pin bpf_iter_hashmap.o /sys/fs/bpf/my_hashmap map id 20
77
78          Create a file-based bpf iterator from bpf_iter_hashmap.o and map with
79          id 20, and pin it to /sys/fs/bpf/my_hashmap
80

SEE ALSO

82          bpf(2),       bpf-helpers(7),       bpftool(8),      bpftool-btf(8),
83          bpftool-cgroup(8),        bpftool-feature(8),        bpftool-gen(8),
84          bpftool-link(8),  bpftool-map(8),  bpftool-net(8),  bpftool-perf(8),
85          bpftool-prog(8), bpftool-struct_ops(8)
86
87
88
89
90                                                               BPFTOOL-ITER(8)
Impressum