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 event_pipe** *MAP* [**cpu** *N* **index** *M*]
32 | **bpftool** **map help**
34 | *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
35 | *DATA* := { [**hex**] *BYTES* }
36 | *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
37 | *VALUE* := { *DATA* | *MAP* | *PROG* }
38 | *UPDATE_FLAGS* := { **any** | **exist** | **noexist** }
42 **bpftool map { show | list }** [*MAP*]
43 Show information about loaded maps. If *MAP* is specified
44 show information only about given map, otherwise list all
45 maps currently loaded on the system.
47 Output will start with map ID followed by map type and
48 zero or more named attributes (depending on kernel version).
50 **bpftool map dump** *MAP*
51 Dump all entries in a given *MAP*.
53 **bpftool map update** *MAP* **key** *DATA* **value** *VALUE* [*UPDATE_FLAGS*]
54 Update map entry for a given *KEY*.
56 *UPDATE_FLAGS* can be one of: **any** update existing entry
57 or add if doesn't exit; **exist** update only if entry already
58 exists; **noexist** update only if entry doesn't exist.
60 If the **hex** keyword is provided in front of the bytes
61 sequence, the bytes are parsed as hexadeximal values, even if
62 no "0x" prefix is added. If the keyword is not provided, then
63 the bytes are parsed as decimal values, unless a "0x" prefix
64 (for hexadecimal) or a "0" prefix (for octal) is provided.
66 **bpftool map lookup** *MAP* **key** *DATA*
67 Lookup **key** in the map.
69 **bpftool map getnext** *MAP* [**key** *DATA*]
70 Get next key. If *key* is not specified, get first key.
72 **bpftool map delete** *MAP* **key** *DATA*
73 Remove entry from the map.
75 **bpftool map pin** *MAP* *FILE*
76 Pin map *MAP* as *FILE*.
78 Note: *FILE* must be located in *bpffs* mount.
80 **bpftool** **map event_pipe** *MAP* [**cpu** *N* **index** *M*]
81 Read events from a BPF_MAP_TYPE_PERF_EVENT_ARRAY map.
83 Install perf rings into a perf event array map and dump
84 output of any bpf_perf_event_output() call in the kernel.
85 By default read the number of CPUs on the system and
86 install perf ring for each CPU in the corresponding index
89 If **cpu** and **index** are specified, install perf ring
90 for given **cpu** at **index** in the array (single ring).
92 Note that installing a perf ring into an array will silently
93 replace any existing ring. Any other application will stop
94 receiving events if it installed its rings earlier.
97 Print short help message.
102 Print short generic help message (similar to **bpftool help**).
105 Print version number (similar to **bpftool version**).
108 Generate JSON output. For commands that cannot produce JSON, this
109 option has no effect.
112 Generate human-readable JSON output. Implies **-j**.
115 Show file names of pinned maps.
119 **# bpftool map show**
122 10: hash name some_map flags 0x0
123 key 4B value 8B max_entries 2048 memlock 167936B
125 The following three commands are equivalent:
128 | **# bpftool map update id 10 key hex 20 c4 b7 00 value hex 0f ff ff ab 01 02 03 4c**
129 | **# bpftool map update id 10 key 0x20 0xc4 0xb7 0x00 value 0x0f 0xff 0xff 0xab 0x01 0x02 0x03 0x4c**
130 | **# bpftool map update id 10 key 32 196 183 0 value 15 255 255 171 1 2 3 76**
132 **# bpftool map lookup id 10 key 0 1 2 3**
136 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
139 **# bpftool map dump id 10**
142 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
143 key: 0d 00 07 00 value: 02 00 00 00 01 02 03 04
146 **# bpftool map getnext id 10 key 0 1 2 3**
155 | **# mount -t bpf none /sys/fs/bpf/**
156 | **# bpftool map pin id 10 /sys/fs/bpf/map**
157 | **# bpftool map del pinned /sys/fs/bpf/map key 13 00 07 00**
161 **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8)