bpftool-iter.rst 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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
  26. particular kernel data (e.g., tasks, bpf_maps, etc.)
  27. and a bpf program called for each kernel data object
  28. (e.g., one task, one bpf_map, etc.). User space can
  29. *read* kernel iterator output through *read()* syscall.
  30. The *pin* command creates a bpf iterator from *OBJ*,
  31. and pin it to *PATH*. The *PATH* should be located
  32. in *bpffs* mount. It must not contain a dot
  33. character ('.'), which is reserved for future extensions
  34. of *bpffs*.
  35. Map element bpf iterator requires an additional parameter
  36. *MAP* so bpf program can iterate over map elements for
  37. that map. User can have a bpf program in kernel to run
  38. with each map element, do checking, filtering, aggregation,
  39. etc. without copying data to user space.
  40. User can then *cat PATH* to see the bpf iterator output.
  41. **bpftool iter help**
  42. Print short help message.
  43. OPTIONS
  44. =======
  45. .. include:: common_options.rst
  46. EXAMPLES
  47. ========
  48. **# bpftool iter pin bpf_iter_netlink.o /sys/fs/bpf/my_netlink**
  49. ::
  50. Create a file-based bpf iterator from bpf_iter_netlink.o and pin it
  51. to /sys/fs/bpf/my_netlink
  52. **# bpftool iter pin bpf_iter_hashmap.o /sys/fs/bpf/my_hashmap map id 20**
  53. ::
  54. Create a file-based bpf iterator from bpf_iter_hashmap.o and map with
  55. id 20, and pin it to /sys/fs/bpf/my_hashmap