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