blob: 5f512b14bff96a6cfbd871b6c2228cca3b0c08dd [file] [log] [blame]
Jakub Kicinskiff69c212017-10-04 20:10:05 -07001================
2bpftool-map
3================
4-------------------------------------------------------------------------------
5tool for inspection and simple manipulation of eBPF maps
6-------------------------------------------------------------------------------
7
8:Manual section: 8
9
10SYNOPSIS
11========
12
Quentin Monnet0641c3c2017-10-23 09:24:16 -070013 **bpftool** [*OPTIONS*] **map** *COMMAND*
14
Prashant Bholec541b732017-11-08 13:55:49 +090015 *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
Jakub Kicinskiff69c212017-10-04 20:10:05 -070016
17 *COMMANDS* :=
Jakub Kicinski6ebe6db2018-01-02 14:48:36 -080018 { **show** | **list** | **dump** | **update** | **lookup** | **getnext** | **delete**
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070019 | **pin** | **help** }
Jakub Kicinskiff69c212017-10-04 20:10:05 -070020
21MAP COMMANDS
22=============
23
Jakub Kicinski6ebe6db2018-01-02 14:48:36 -080024| **bpftool** **map { show | list }** [*MAP*]
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070025| **bpftool** **map dump** *MAP*
Quentin Monnet0c90f222018-04-17 19:46:34 -070026| **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*
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070030| **bpftool** **map pin** *MAP* *FILE*
31| **bpftool** **map help**
Jakub Kicinskiff69c212017-10-04 20:10:05 -070032|
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070033| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
Quentin Monnet21484812018-02-07 20:27:15 -080034| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
35| *VALUE* := { *BYTES* | *MAP* | *PROG* }
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070036| *UPDATE_FLAGS* := { **any** | **exist** | **noexist** }
Jakub Kicinskiff69c212017-10-04 20:10:05 -070037
38DESCRIPTION
39===========
Jakub Kicinski6ebe6db2018-01-02 14:48:36 -080040 **bpftool map { show | list }** [*MAP*]
Jakub Kicinskiff69c212017-10-04 20:10:05 -070041 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.
44
45 Output will start with map ID followed by map type and
46 zero or more named attributes (depending on kernel version).
47
48 **bpftool map dump** *MAP*
49 Dump all entries in a given *MAP*.
50
Quentin Monnet0c90f222018-04-17 19:46:34 -070051 **bpftool map update** *MAP* **key** [**hex**] *BYTES* **value** [**hex**] *VALUE* [*UPDATE_FLAGS*]
Jakub Kicinskiff69c212017-10-04 20:10:05 -070052 Update map entry for a given *KEY*.
53
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.
57
Quentin Monnet0c90f222018-04-17 19:46:34 -070058 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.
63
64 **bpftool map lookup** *MAP* **key** [**hex**] *BYTES*
Jakub Kicinskiff69c212017-10-04 20:10:05 -070065 Lookup **key** in the map.
66
Quentin Monnet0c90f222018-04-17 19:46:34 -070067 **bpftool map getnext** *MAP* [**key** [**hex**] *BYTES*]
Jakub Kicinskiff69c212017-10-04 20:10:05 -070068 Get next key. If *key* is not specified, get first key.
69
Quentin Monnet0c90f222018-04-17 19:46:34 -070070 **bpftool map delete** *MAP* **key** [**hex**] *BYTES*
Jakub Kicinskiff69c212017-10-04 20:10:05 -070071 Remove entry from the map.
72
73 **bpftool map pin** *MAP* *FILE*
74 Pin map *MAP* as *FILE*.
75
76 Note: *FILE* must be located in *bpffs* mount.
77
78 **bpftool map help**
79 Print short help message.
80
Quentin Monneta2bc2e52017-10-23 09:24:06 -070081OPTIONS
82=======
83 -h, --help
84 Print short generic help message (similar to **bpftool help**).
85
86 -v, --version
87 Print version number (similar to **bpftool version**).
88
Quentin Monnet0641c3c2017-10-23 09:24:16 -070089 -j, --json
90 Generate JSON output. For commands that cannot produce JSON, this
91 option has no effect.
92
93 -p, --pretty
94 Generate human-readable JSON output. Implies **-j**.
95
Prashant Bholec541b732017-11-08 13:55:49 +090096 -f, --bpffs
97 Show file names of pinned maps.
98
Jakub Kicinskiff69c212017-10-04 20:10:05 -070099EXAMPLES
100========
101**# bpftool map show**
102::
103
104 10: hash name some_map flags 0x0
105 key 4B value 8B max_entries 2048 memlock 167936B
106
Quentin Monnet0c90f222018-04-17 19:46:34 -0700107The following three commands are equivalent:
108
109|
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**
Jakub Kicinskiff69c212017-10-04 20:10:05 -0700113
114**# bpftool map lookup id 10 key 0 1 2 3**
115
116::
117
118 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
119
120
121**# bpftool map dump id 10**
122::
123
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
126 Found 2 elements
127
128**# bpftool map getnext id 10 key 0 1 2 3**
129::
130
131 key:
132 00 01 02 03
133 next key:
134 0d 00 07 00
135
136|
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**
140
141SEE ALSO
142========
Roman Gushchin5ccda642017-12-13 15:18:54 +0000143 **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8)