blob: c3eef8c972cd0140ef4e2dab1c363ccda4bc5839 [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*
Jakub Kicinskic642ea22018-05-03 18:37:14 -070026| **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*
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* }
Jakub Kicinskic642ea22018-05-03 18:37:14 -070034| *DATA* := { [**hex**] *BYTES* }
Quentin Monnet21484812018-02-07 20:27:15 -080035| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
Jakub Kicinskic642ea22018-05-03 18:37:14 -070036| *VALUE* := { *DATA* | *MAP* | *PROG* }
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070037| *UPDATE_FLAGS* := { **any** | **exist** | **noexist** }
Jakub Kicinskiff69c212017-10-04 20:10:05 -070038
39DESCRIPTION
40===========
Jakub Kicinski6ebe6db2018-01-02 14:48:36 -080041 **bpftool map { show | list }** [*MAP*]
Jakub Kicinskiff69c212017-10-04 20:10:05 -070042 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.
45
46 Output will start with map ID followed by map type and
47 zero or more named attributes (depending on kernel version).
48
49 **bpftool map dump** *MAP*
50 Dump all entries in a given *MAP*.
51
Jakub Kicinskic642ea22018-05-03 18:37:14 -070052 **bpftool map update** *MAP* **key** *DATA* **value** *VALUE* [*UPDATE_FLAGS*]
Jakub Kicinskiff69c212017-10-04 20:10:05 -070053 Update map entry for a given *KEY*.
54
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.
58
Quentin Monnet0c90f222018-04-17 19:46:34 -070059 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.
64
Jakub Kicinskic642ea22018-05-03 18:37:14 -070065 **bpftool map lookup** *MAP* **key** *DATA*
Jakub Kicinskiff69c212017-10-04 20:10:05 -070066 Lookup **key** in the map.
67
Jakub Kicinskic642ea22018-05-03 18:37:14 -070068 **bpftool map getnext** *MAP* [**key** *DATA*]
Jakub Kicinskiff69c212017-10-04 20:10:05 -070069 Get next key. If *key* is not specified, get first key.
70
Jakub Kicinskic642ea22018-05-03 18:37:14 -070071 **bpftool map delete** *MAP* **key** *DATA*
Jakub Kicinskiff69c212017-10-04 20:10:05 -070072 Remove entry from the map.
73
74 **bpftool map pin** *MAP* *FILE*
75 Pin map *MAP* as *FILE*.
76
77 Note: *FILE* must be located in *bpffs* mount.
78
79 **bpftool map help**
80 Print short help message.
81
Quentin Monneta2bc2e52017-10-23 09:24:06 -070082OPTIONS
83=======
84 -h, --help
85 Print short generic help message (similar to **bpftool help**).
86
87 -v, --version
88 Print version number (similar to **bpftool version**).
89
Quentin Monnet0641c3c2017-10-23 09:24:16 -070090 -j, --json
91 Generate JSON output. For commands that cannot produce JSON, this
92 option has no effect.
93
94 -p, --pretty
95 Generate human-readable JSON output. Implies **-j**.
96
Prashant Bholec541b732017-11-08 13:55:49 +090097 -f, --bpffs
98 Show file names of pinned maps.
99
Jakub Kicinskiff69c212017-10-04 20:10:05 -0700100EXAMPLES
101========
102**# bpftool map show**
103::
104
105 10: hash name some_map flags 0x0
106 key 4B value 8B max_entries 2048 memlock 167936B
107
Quentin Monnet0c90f222018-04-17 19:46:34 -0700108The following three commands are equivalent:
109
110|
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**
Jakub Kicinskiff69c212017-10-04 20:10:05 -0700114
115**# bpftool map lookup id 10 key 0 1 2 3**
116
117::
118
119 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
120
121
122**# bpftool map dump id 10**
123::
124
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
127 Found 2 elements
128
129**# bpftool map getnext id 10 key 0 1 2 3**
130::
131
132 key:
133 00 01 02 03
134 next key:
135 0d 00 07 00
136
137|
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**
141
142SEE ALSO
143========
Roman Gushchin5ccda642017-12-13 15:18:54 +0000144 **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8)