]> asedeno.scripts.mit.edu Git - linux.git/blob - tools/bpf/bpftool/Documentation/bpftool-map.rst
tools: bpftool: fold hex keyword in command help
[linux.git] / tools / bpf / bpftool / Documentation / bpftool-map.rst
1 ================
2 bpftool-map
3 ================
4 -------------------------------------------------------------------------------
5 tool for inspection and simple manipulation of eBPF maps
6 -------------------------------------------------------------------------------
7
8 :Manual section: 8
9
10 SYNOPSIS
11 ========
12
13         **bpftool** [*OPTIONS*] **map** *COMMAND*
14
15         *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } }
16
17         *COMMANDS* :=
18         { **show** | **list** | **dump** | **update** | **lookup** | **getnext** | **delete**
19         | **pin** | **help** }
20
21 MAP COMMANDS
22 =============
23
24 |       **bpftool** **map { show | list }**   [*MAP*]
25 |       **bpftool** **map dump**    *MAP*
26 |       **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*
30 |       **bpftool** **map pin**     *MAP*  *FILE*
31 |       **bpftool** **map help**
32 |
33 |       *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
34 |       *DATA* := { [**hex**] *BYTES* }
35 |       *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* }
36 |       *VALUE* := { *DATA* | *MAP* | *PROG* }
37 |       *UPDATE_FLAGS* := { **any** | **exist** | **noexist** }
38
39 DESCRIPTION
40 ===========
41         **bpftool map { show | list }**   [*MAP*]
42                   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
52         **bpftool map update**  *MAP*  **key** *DATA*   **value** *VALUE* [*UPDATE_FLAGS*]
53                   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
59                   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
65         **bpftool map lookup**  *MAP*  **key** *DATA*
66                   Lookup **key** in the map.
67
68         **bpftool map getnext** *MAP* [**key** *DATA*]
69                   Get next key.  If *key* is not specified, get first key.
70
71         **bpftool map delete**  *MAP*  **key** *DATA*
72                   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
82 OPTIONS
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
90         -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
97         -f, --bpffs
98                   Show file names of pinned maps.
99
100 EXAMPLES
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
108 The 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**
114
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
142 SEE ALSO
143 ========
144         **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8)