blob: 457e868bd32f427a3469fcec79a347e0fd58a633 [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*
26| **bpftool** **map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*]
27| **bpftool** **map lookup** *MAP* **key** *BYTES*
28| **bpftool** **map getnext** *MAP* [**key** *BYTES*]
29| **bpftool** **map delete** *MAP* **key** *BYTES*
30| **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
51 **bpftool map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*]
52 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
58 **bpftool map lookup** *MAP* **key** *BYTES*
59 Lookup **key** in the map.
60
61 **bpftool map getnext** *MAP* [**key** *BYTES*]
62 Get next key. If *key* is not specified, get first key.
63
64 **bpftool map delete** *MAP* **key** *BYTES*
65 Remove entry from the map.
66
67 **bpftool map pin** *MAP* *FILE*
68 Pin map *MAP* as *FILE*.
69
70 Note: *FILE* must be located in *bpffs* mount.
71
72 **bpftool map help**
73 Print short help message.
74
Quentin Monneta2bc2e52017-10-23 09:24:06 -070075OPTIONS
76=======
77 -h, --help
78 Print short generic help message (similar to **bpftool help**).
79
80 -v, --version
81 Print version number (similar to **bpftool version**).
82
Quentin Monnet0641c3c2017-10-23 09:24:16 -070083 -j, --json
84 Generate JSON output. For commands that cannot produce JSON, this
85 option has no effect.
86
87 -p, --pretty
88 Generate human-readable JSON output. Implies **-j**.
89
Prashant Bholec541b732017-11-08 13:55:49 +090090 -f, --bpffs
91 Show file names of pinned maps.
92
Jakub Kicinskiff69c212017-10-04 20:10:05 -070093EXAMPLES
94========
95**# bpftool map show**
96::
97
98 10: hash name some_map flags 0x0
99 key 4B value 8B max_entries 2048 memlock 167936B
100
101**# bpftool map update id 10 key 13 00 07 00 value 02 00 00 00 01 02 03 04**
102
103**# bpftool map lookup id 10 key 0 1 2 3**
104
105::
106
107 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
108
109
110**# bpftool map dump id 10**
111::
112
113 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
114 key: 0d 00 07 00 value: 02 00 00 00 01 02 03 04
115 Found 2 elements
116
117**# bpftool map getnext id 10 key 0 1 2 3**
118::
119
120 key:
121 00 01 02 03
122 next key:
123 0d 00 07 00
124
125|
126| **# mount -t bpf none /sys/fs/bpf/**
127| **# bpftool map pin id 10 /sys/fs/bpf/map**
128| **# bpftool map del pinned /sys/fs/bpf/map key 13 00 07 00**
129
130SEE ALSO
131========
Roman Gushchin5ccda642017-12-13 15:18:54 +0000132 **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8)