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          OPTIONS  := { { -j | --json } [{ -p | --pretty }] | { -d | --debug }
12          }
13
14          COMMANDS := { pin | help }
15

ITER COMMANDS

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

DESCRIPTION

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

OPTIONS

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

EXAMPLES

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

SEE ALSO

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