^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) bpftool-iter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) ============
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) tool to create BPF iterators
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) -------------------------------------------------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) :Manual section: 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) SYNOPSIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) **bpftool** [*OPTIONS*] **iter** *COMMAND*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) *COMMANDS* := { **pin** | **help** }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) ITER COMMANDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) ===================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) | **bpftool** **iter pin** *OBJ* *PATH* [**map** *MAP*]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) | **bpftool** **iter help**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) | *OBJ* := /a/file/of/bpf_iter_target.o
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) | *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) DESCRIPTION
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) ===========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) **bpftool iter pin** *OBJ* *PATH* [**map** *MAP*]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) A bpf iterator combines a kernel iterating of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) particular kernel data (e.g., tasks, bpf_maps, etc.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) and a bpf program called for each kernel data object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) (e.g., one task, one bpf_map, etc.). User space can
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) *read* kernel iterator output through *read()* syscall.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) The *pin* command creates a bpf iterator from *OBJ*,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) and pin it to *PATH*. The *PATH* should be located
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) in *bpffs* mount. It must not contain a dot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) character ('.'), which is reserved for future extensions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) of *bpffs*.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) Map element bpf iterator requires an additional parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *MAP* so bpf program can iterate over map elements for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) that map. User can have a bpf program in kernel to run
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) with each map element, do checking, filtering, aggregation,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) etc. without copying data to user space.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) User can then *cat PATH* to see the bpf iterator output.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) **bpftool iter help**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) Print short help message.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) OPTIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) =======
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) .. include:: common_options.rst
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) EXAMPLES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) ========
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) **# bpftool iter pin bpf_iter_netlink.o /sys/fs/bpf/my_netlink**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) Create a file-based bpf iterator from bpf_iter_netlink.o and pin it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) to /sys/fs/bpf/my_netlink
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) **# bpftool iter pin bpf_iter_hashmap.o /sys/fs/bpf/my_hashmap map id 20**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) ::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) Create a file-based bpf iterator from bpf_iter_hashmap.o and map with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) id 20, and pin it to /sys/fs/bpf/my_hashmap