18c2ecf20Sopenharmony_ci============
28c2ecf20Sopenharmony_cibpftool-iter
38c2ecf20Sopenharmony_ci============
48c2ecf20Sopenharmony_ci-------------------------------------------------------------------------------
58c2ecf20Sopenharmony_citool to create BPF iterators
68c2ecf20Sopenharmony_ci-------------------------------------------------------------------------------
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci:Manual section: 8
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ciSYNOPSIS
118c2ecf20Sopenharmony_ci========
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci	**bpftool** [*OPTIONS*] **iter** *COMMAND*
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci	*COMMANDS* := { **pin** | **help** }
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ciITER COMMANDS
188c2ecf20Sopenharmony_ci===================
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci|	**bpftool** **iter pin** *OBJ* *PATH* [**map** *MAP*]
218c2ecf20Sopenharmony_ci|	**bpftool** **iter help**
228c2ecf20Sopenharmony_ci|
238c2ecf20Sopenharmony_ci|	*OBJ* := /a/file/of/bpf_iter_target.o
248c2ecf20Sopenharmony_ci|	*MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciDESCRIPTION
278c2ecf20Sopenharmony_ci===========
288c2ecf20Sopenharmony_ci	**bpftool iter pin** *OBJ* *PATH* [**map** *MAP*]
298c2ecf20Sopenharmony_ci		  A bpf iterator combines a kernel iterating of
308c2ecf20Sopenharmony_ci		  particular kernel data (e.g., tasks, bpf_maps, etc.)
318c2ecf20Sopenharmony_ci		  and a bpf program called for each kernel data object
328c2ecf20Sopenharmony_ci		  (e.g., one task, one bpf_map, etc.). User space can
338c2ecf20Sopenharmony_ci		  *read* kernel iterator output through *read()* syscall.
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci		  The *pin* command creates a bpf iterator from *OBJ*,
368c2ecf20Sopenharmony_ci		  and pin it to *PATH*. The *PATH* should be located
378c2ecf20Sopenharmony_ci		  in *bpffs* mount. It must not contain a dot
388c2ecf20Sopenharmony_ci		  character ('.'), which is reserved for future extensions
398c2ecf20Sopenharmony_ci		  of *bpffs*.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci		  Map element bpf iterator requires an additional parameter
428c2ecf20Sopenharmony_ci		  *MAP* so bpf program can iterate over map elements for
438c2ecf20Sopenharmony_ci		  that map. User can have a bpf program in kernel to run
448c2ecf20Sopenharmony_ci		  with each map element, do checking, filtering, aggregation,
458c2ecf20Sopenharmony_ci		  etc. without copying data to user space.
468c2ecf20Sopenharmony_ci
478c2ecf20Sopenharmony_ci		  User can then *cat PATH* to see the bpf iterator output.
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci	**bpftool iter help**
508c2ecf20Sopenharmony_ci		  Print short help message.
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciOPTIONS
538c2ecf20Sopenharmony_ci=======
548c2ecf20Sopenharmony_ci	.. include:: common_options.rst
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ciEXAMPLES
578c2ecf20Sopenharmony_ci========
588c2ecf20Sopenharmony_ci**# bpftool iter pin bpf_iter_netlink.o /sys/fs/bpf/my_netlink**
598c2ecf20Sopenharmony_ci
608c2ecf20Sopenharmony_ci::
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ci   Create a file-based bpf iterator from bpf_iter_netlink.o and pin it
638c2ecf20Sopenharmony_ci   to /sys/fs/bpf/my_netlink
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci**# bpftool iter pin bpf_iter_hashmap.o /sys/fs/bpf/my_hashmap map id 20**
668c2ecf20Sopenharmony_ci
678c2ecf20Sopenharmony_ci::
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci   Create a file-based bpf iterator from bpf_iter_hashmap.o and map with
708c2ecf20Sopenharmony_ci   id 20, and pin it to /sys/fs/bpf/my_hashmap
71