4 -------------------------------------------------------------------------------
5 tool for inspection and simple manipulation of eBPF maps
6 -------------------------------------------------------------------------------
13 **bpftool** [*OPTIONS*] **map** *COMMAND*
15 *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
18 { **show** | **list** | **dump** | **update** | **lookup** | **getnext** | **delete**
19 | **pin** | **help** }
24 | **bpftool** **map { show | list }** [*MAP*]
25 | **bpftool** **map dump** *MAP*
26 | **bpftool** **map update** *MAP* **key** [**hex**] *BYTES* **value** [**hex**] *VALUE* [*UPDATE_FLAGS*]
27 | **bpftool** **map lookup** *MAP* **key** [**hex**] *BYTES*
28 | **bpftool** **map getnext** *MAP* [**key** [**hex**] *BYTES*]
29 | **bpftool** **map delete** *MAP* **key** [**hex**] *BYTES*
30 | **bpftool** **map pin** *MAP* *FILE*
31 | **bpftool** **map help**
33 | *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
34 | *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
35 | *VALUE* := { *BYTES* | *MAP* | *PROG* }
36 | *UPDATE_FLAGS* := { **any** | **exist** | **noexist** }
40 **bpftool map { show | list }** [*MAP*]
41 Show information about loaded maps. If *MAP* is specified
42 show information only about given map, otherwise list all
43 maps currently loaded on the system.
45 Output will start with map ID followed by map type and
46 zero or more named attributes (depending on kernel version).
48 **bpftool map dump** *MAP*
49 Dump all entries in a given *MAP*.
51 **bpftool map update** *MAP* **key** [**hex**] *BYTES* **value** [**hex**] *VALUE* [*UPDATE_FLAGS*]
52 Update map entry for a given *KEY*.
54 *UPDATE_FLAGS* can be one of: **any** update existing entry
55 or add if doesn't exit; **exist** update only if entry already
56 exists; **noexist** update only if entry doesn't exist.
58 If the **hex** keyword is provided in front of the bytes
59 sequence, the bytes are parsed as hexadeximal values, even if
60 no "0x" prefix is added. If the keyword is not provided, then
61 the bytes are parsed as decimal values, unless a "0x" prefix
62 (for hexadecimal) or a "0" prefix (for octal) is provided.
64 **bpftool map lookup** *MAP* **key** [**hex**] *BYTES*
65 Lookup **key** in the map.
67 **bpftool map getnext** *MAP* [**key** [**hex**] *BYTES*]
68 Get next key. If *key* is not specified, get first key.
70 **bpftool map delete** *MAP* **key** [**hex**] *BYTES*
71 Remove entry from the map.
73 **bpftool map pin** *MAP* *FILE*
74 Pin map *MAP* as *FILE*.
76 Note: *FILE* must be located in *bpffs* mount.
79 Print short help message.
84 Print short generic help message (similar to **bpftool help**).
87 Print version number (similar to **bpftool version**).
90 Generate JSON output. For commands that cannot produce JSON, this
94 Generate human-readable JSON output. Implies **-j**.
97 Show file names of pinned maps.
101 **# bpftool map show**
104 10: hash name some_map flags 0x0
105 key 4B value 8B max_entries 2048 memlock 167936B
107 The following three commands are equivalent:
110 | **# bpftool map update id 10 key hex 20 c4 b7 00 value hex 0f ff ff ab 01 02 03 4c**
111 | **# bpftool map update id 10 key 0x20 0xc4 0xb7 0x00 value 0x0f 0xff 0xff 0xab 0x01 0x02 0x03 0x4c**
112 | **# bpftool map update id 10 key 32 196 183 0 value 15 255 255 171 1 2 3 76**
114 **# bpftool map lookup id 10 key 0 1 2 3**
118 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
121 **# bpftool map dump id 10**
124 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
125 key: 0d 00 07 00 value: 02 00 00 00 01 02 03 04
128 **# bpftool map getnext id 10 key 0 1 2 3**
137 | **# mount -t bpf none /sys/fs/bpf/**
138 | **# bpftool map pin id 10 /sys/fs/bpf/map**
139 | **# bpftool map del pinned /sys/fs/bpf/map key 13 00 07 00**
143 **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8)