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** *DATA* **value** *VALUE* [*UPDATE_FLAGS*]
27 | **bpftool** **map lookup** *MAP* **key** *DATA*
28 | **bpftool** **map getnext** *MAP* [**key** *DATA*]
29 | **bpftool** **map delete** *MAP* **key** *DATA*
30 | **bpftool** **map pin** *MAP* *FILE*
31 | **bpftool** **map help**
33 | *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
34 | *DATA* := { [**hex**] *BYTES* }
35 | *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
36 | *VALUE* := { *DATA* | *MAP* | *PROG* }
37 | *UPDATE_FLAGS* := { **any** | **exist** | **noexist** }
41 **bpftool map { show | list }** [*MAP*]
42 Show information about loaded maps. If *MAP* is specified
43 show information only about given map, otherwise list all
44 maps currently loaded on the system.
46 Output will start with map ID followed by map type and
47 zero or more named attributes (depending on kernel version).
49 **bpftool map dump** *MAP*
50 Dump all entries in a given *MAP*.
52 **bpftool map update** *MAP* **key** *DATA* **value** *VALUE* [*UPDATE_FLAGS*]
53 Update map entry for a given *KEY*.
55 *UPDATE_FLAGS* can be one of: **any** update existing entry
56 or add if doesn't exit; **exist** update only if entry already
57 exists; **noexist** update only if entry doesn't exist.
59 If the **hex** keyword is provided in front of the bytes
60 sequence, the bytes are parsed as hexadeximal values, even if
61 no "0x" prefix is added. If the keyword is not provided, then
62 the bytes are parsed as decimal values, unless a "0x" prefix
63 (for hexadecimal) or a "0" prefix (for octal) is provided.
65 **bpftool map lookup** *MAP* **key** *DATA*
66 Lookup **key** in the map.
68 **bpftool map getnext** *MAP* [**key** *DATA*]
69 Get next key. If *key* is not specified, get first key.
71 **bpftool map delete** *MAP* **key** *DATA*
72 Remove entry from the map.
74 **bpftool map pin** *MAP* *FILE*
75 Pin map *MAP* as *FILE*.
77 Note: *FILE* must be located in *bpffs* mount.
80 Print short help message.
85 Print short generic help message (similar to **bpftool help**).
88 Print version number (similar to **bpftool version**).
91 Generate JSON output. For commands that cannot produce JSON, this
95 Generate human-readable JSON output. Implies **-j**.
98 Show file names of pinned maps.
102 **# bpftool map show**
105 10: hash name some_map flags 0x0
106 key 4B value 8B max_entries 2048 memlock 167936B
108 The following three commands are equivalent:
111 | **# bpftool map update id 10 key hex 20 c4 b7 00 value hex 0f ff ff ab 01 02 03 4c**
112 | **# bpftool map update id 10 key 0x20 0xc4 0xb7 0x00 value 0x0f 0xff 0xff 0xab 0x01 0x02 0x03 0x4c**
113 | **# bpftool map update id 10 key 32 196 183 0 value 15 255 255 171 1 2 3 76**
115 **# bpftool map lookup id 10 key 0 1 2 3**
119 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
122 **# bpftool map dump id 10**
125 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
126 key: 0d 00 07 00 value: 02 00 00 00 01 02 03 04
129 **# bpftool map getnext id 10 key 0 1 2 3**
138 | **# mount -t bpf none /sys/fs/bpf/**
139 | **# bpftool map pin id 10 /sys/fs/bpf/map**
140 | **# bpftool map del pinned /sys/fs/bpf/map key 13 00 07 00**
144 **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8)