bpftool-map.rst 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. ================
  2. bpftool-map
  3. ================
  4. -------------------------------------------------------------------------------
  5. tool for inspection and simple manipulation of eBPF maps
  6. -------------------------------------------------------------------------------
  7. :Manual section: 8
  8. SYNOPSIS
  9. ========
  10. **bpftool** [*OPTIONS*] **map** *COMMAND*
  11. *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
  12. *COMMANDS* :=
  13. { **show** | **list** | **dump** | **update** | **lookup** | **getnext** | **delete**
  14. | **pin** | **help** }
  15. MAP COMMANDS
  16. =============
  17. | **bpftool** **map { show | list }** [*MAP*]
  18. | **bpftool** **map dump** *MAP*
  19. | **bpftool** **map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*]
  20. | **bpftool** **map lookup** *MAP* **key** *BYTES*
  21. | **bpftool** **map getnext** *MAP* [**key** *BYTES*]
  22. | **bpftool** **map delete** *MAP* **key** *BYTES*
  23. | **bpftool** **map pin** *MAP* *FILE*
  24. | **bpftool** **map help**
  25. |
  26. | *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
  27. | *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
  28. | *VALUE* := { *BYTES* | *MAP* | *PROG* }
  29. | *UPDATE_FLAGS* := { **any** | **exist** | **noexist** }
  30. DESCRIPTION
  31. ===========
  32. **bpftool map { show | list }** [*MAP*]
  33. Show information about loaded maps. If *MAP* is specified
  34. show information only about given map, otherwise list all
  35. maps currently loaded on the system.
  36. Output will start with map ID followed by map type and
  37. zero or more named attributes (depending on kernel version).
  38. **bpftool map dump** *MAP*
  39. Dump all entries in a given *MAP*.
  40. **bpftool map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*]
  41. Update map entry for a given *KEY*.
  42. *UPDATE_FLAGS* can be one of: **any** update existing entry
  43. or add if doesn't exit; **exist** update only if entry already
  44. exists; **noexist** update only if entry doesn't exist.
  45. **bpftool map lookup** *MAP* **key** *BYTES*
  46. Lookup **key** in the map.
  47. **bpftool map getnext** *MAP* [**key** *BYTES*]
  48. Get next key. If *key* is not specified, get first key.
  49. **bpftool map delete** *MAP* **key** *BYTES*
  50. Remove entry from the map.
  51. **bpftool map pin** *MAP* *FILE*
  52. Pin map *MAP* as *FILE*.
  53. Note: *FILE* must be located in *bpffs* mount.
  54. **bpftool map help**
  55. Print short help message.
  56. OPTIONS
  57. =======
  58. -h, --help
  59. Print short generic help message (similar to **bpftool help**).
  60. -v, --version
  61. Print version number (similar to **bpftool version**).
  62. -j, --json
  63. Generate JSON output. For commands that cannot produce JSON, this
  64. option has no effect.
  65. -p, --pretty
  66. Generate human-readable JSON output. Implies **-j**.
  67. -f, --bpffs
  68. Show file names of pinned maps.
  69. EXAMPLES
  70. ========
  71. **# bpftool map show**
  72. ::
  73. 10: hash name some_map flags 0x0
  74. key 4B value 8B max_entries 2048 memlock 167936B
  75. **# bpftool map update id 10 key 13 00 07 00 value 02 00 00 00 01 02 03 04**
  76. **# bpftool map lookup id 10 key 0 1 2 3**
  77. ::
  78. key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
  79. **# bpftool map dump id 10**
  80. ::
  81. key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
  82. key: 0d 00 07 00 value: 02 00 00 00 01 02 03 04
  83. Found 2 elements
  84. **# bpftool map getnext id 10 key 0 1 2 3**
  85. ::
  86. key:
  87. 00 01 02 03
  88. next key:
  89. 0d 00 07 00
  90. |
  91. | **# mount -t bpf none /sys/fs/bpf/**
  92. | **# bpftool map pin id 10 /sys/fs/bpf/map**
  93. | **# bpftool map del pinned /sys/fs/bpf/map key 13 00 07 00**
  94. SEE ALSO
  95. ========
  96. **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8)