bpftool-iter.rst 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. .. SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
  2. ============
  3. bpftool-iter
  4. ============
  5. -------------------------------------------------------------------------------
  6. tool to create BPF iterators
  7. -------------------------------------------------------------------------------
  8. :Manual section: 8
  9. .. include:: substitutions.rst
  10. SYNOPSIS
  11. ========
  12. **bpftool** [*OPTIONS*] **iter** *COMMAND*
  13. *OPTIONS* := { |COMMON_OPTIONS| }
  14. *COMMANDS* := { **pin** | **help** }
  15. ITER COMMANDS
  16. =============
  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. DESCRIPTION
  23. ===========
  24. bpftool iter pin *OBJ* *PATH* [map *MAP*]
  25. A bpf iterator combines a kernel iterating of particular kernel data (e.g.,
  26. tasks, bpf_maps, etc.) and a bpf program called for each kernel data object
  27. (e.g., one task, one bpf_map, etc.). User space can *read* kernel iterator
  28. output through *read()* syscall.
  29. The *pin* command creates a bpf iterator from *OBJ*, and pin it to *PATH*.
  30. The *PATH* should be located in *bpffs* mount. It must not contain a dot
  31. character ('.'), which is reserved for future extensions of *bpffs*.
  32. Map element bpf iterator requires an additional parameter *MAP* so bpf
  33. program can iterate over map elements for that map. User can have a bpf
  34. program in kernel to run with each map element, do checking, filtering,
  35. aggregation, etc. without copying data to user space.
  36. User can then *cat PATH* to see the bpf iterator output.
  37. bpftool iter help
  38. Print short help message.
  39. OPTIONS
  40. =======
  41. .. include:: common_options.rst
  42. EXAMPLES
  43. ========
  44. **# bpftool iter pin bpf_iter_netlink.o /sys/fs/bpf/my_netlink**
  45. ::
  46. Create a file-based bpf iterator from bpf_iter_netlink.o and pin it
  47. to /sys/fs/bpf/my_netlink
  48. **# bpftool iter pin bpf_iter_hashmap.o /sys/fs/bpf/my_hashmap map id 20**
  49. ::
  50. Create a file-based bpf iterator from bpf_iter_hashmap.o and map with
  51. id 20, and pin it to /sys/fs/bpf/my_hashmap