blob: 3954b3ea4f26ebf6c9af366c00f7d6c7377b6af0 [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
13 **bpftool** **map** *COMMAND*
14
15 *COMMANDS* :=
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070016 { **show** | **dump** | **update** | **lookup** | **getnext** | **delete**
17 | **pin** | **help** }
Jakub Kicinskiff69c212017-10-04 20:10:05 -070018
19MAP COMMANDS
20=============
21
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070022| **bpftool** **map show** [*MAP*]
23| **bpftool** **map dump** *MAP*
24| **bpftool** **map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*]
25| **bpftool** **map lookup** *MAP* **key** *BYTES*
26| **bpftool** **map getnext** *MAP* [**key** *BYTES*]
27| **bpftool** **map delete** *MAP* **key** *BYTES*
28| **bpftool** **map pin** *MAP* *FILE*
29| **bpftool** **map help**
Jakub Kicinskiff69c212017-10-04 20:10:05 -070030|
Quentin Monnet47ff7ac2017-10-23 09:24:15 -070031| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
32| *VALUE* := { *BYTES* | *MAP* | *PROGRAM* }
33| *UPDATE_FLAGS* := { **any** | **exist** | **noexist** }
Jakub Kicinskiff69c212017-10-04 20:10:05 -070034
35DESCRIPTION
36===========
37 **bpftool map show** [*MAP*]
38 Show information about loaded maps. If *MAP* is specified
39 show information only about given map, otherwise list all
40 maps currently loaded on the system.
41
42 Output will start with map ID followed by map type and
43 zero or more named attributes (depending on kernel version).
44
45 **bpftool map dump** *MAP*
46 Dump all entries in a given *MAP*.
47
48 **bpftool map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*]
49 Update map entry for a given *KEY*.
50
51 *UPDATE_FLAGS* can be one of: **any** update existing entry
52 or add if doesn't exit; **exist** update only if entry already
53 exists; **noexist** update only if entry doesn't exist.
54
55 **bpftool map lookup** *MAP* **key** *BYTES*
56 Lookup **key** in the map.
57
58 **bpftool map getnext** *MAP* [**key** *BYTES*]
59 Get next key. If *key* is not specified, get first key.
60
61 **bpftool map delete** *MAP* **key** *BYTES*
62 Remove entry from the map.
63
64 **bpftool map pin** *MAP* *FILE*
65 Pin map *MAP* as *FILE*.
66
67 Note: *FILE* must be located in *bpffs* mount.
68
69 **bpftool map help**
70 Print short help message.
71
Quentin Monneta2bc2e52017-10-23 09:24:06 -070072OPTIONS
73=======
74 -h, --help
75 Print short generic help message (similar to **bpftool help**).
76
77 -v, --version
78 Print version number (similar to **bpftool version**).
79
Jakub Kicinskiff69c212017-10-04 20:10:05 -070080EXAMPLES
81========
82**# bpftool map show**
83::
84
85 10: hash name some_map flags 0x0
86 key 4B value 8B max_entries 2048 memlock 167936B
87
88**# bpftool map update id 10 key 13 00 07 00 value 02 00 00 00 01 02 03 04**
89
90**# bpftool map lookup id 10 key 0 1 2 3**
91
92::
93
94 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
95
96
97**# bpftool map dump id 10**
98::
99
100 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
101 key: 0d 00 07 00 value: 02 00 00 00 01 02 03 04
102 Found 2 elements
103
104**# bpftool map getnext id 10 key 0 1 2 3**
105::
106
107 key:
108 00 01 02 03
109 next key:
110 0d 00 07 00
111
112|
113| **# mount -t bpf none /sys/fs/bpf/**
114| **# bpftool map pin id 10 /sys/fs/bpf/map**
115| **# bpftool map del pinned /sys/fs/bpf/map key 13 00 07 00**
116
117SEE ALSO
118========
119 **bpftool**\ (8), **bpftool-prog**\ (8)