1BPFTOOL-MAP(8)                                                  BPFTOOL-MAP(8)
2
3
4

NAME

6       bpftool-map - tool for inspection and simple manipulation of eBPF maps
7

SYNOPSIS

9          bpftool [OPTIONS] map COMMAND
10
11          OPTIONS  := { { -j | --json } [{ -p | --pretty }] | { -f | --bpffs }
12          }
13
14          COMMANDS := { show | list | dump |  update  |  lookup  |  getnext  |
15          delete | pin | help }
16

MAP COMMANDS

18       bpftool map { show | list }   [MAP]
19       bpftool map dump       MAP
20       bpftool map update     MAP  key DATA   value VALUE [UPDATE_FLAGS]
21       bpftool map lookup     MAP  key DATA
22       bpftool map getnext    MAP [key DATA]
23       bpftool map delete     MAP  key DATA
24       bpftool map pin        MAP  FILE
25       bpftool map event_pipe MAP [cpu N index M]
26       bpftool map help
27
28       MAP := { id MAP_ID | pinned FILE }
29       DATA := { [hex] BYTES }
30       PROG := { id PROG_ID | pinned FILE | tag PROG_TAG }
31       VALUE := { DATA | MAP | PROG }
32       UPDATE_FLAGS := { any | exist | noexist }
33
34

DESCRIPTION

36          bpftool map { show | list } [MAP]
37                 Show information about loaded maps.  If MAP is specified show
38                 information only about given map,  otherwise  list  all  maps
39                 currently loaded on the system.
40
41                 Output  will  start with map ID followed by map type and zero
42                 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 DATA value VALUE [UPDATE_FLAGS]
48                 Update map entry for a given KEY.
49
50                 UPDATE_FLAGS can be one of: any update existing entry or  add
51                 if  doesn't  exit; exist update only if entry already exists;
52                 noexist update only if entry doesn't exist.
53
54                 If the  hex  keyword  is  provided  in  front  of  the  bytes
55                 sequence, the bytes are parsed as hexadeximal values, even if
56                 no "0x" prefix is added. If the keyword is not provided, then
57                 the  bytes are parsed as decimal values, unless a "0x" prefix
58                 (for hexadecimal) or a "0" prefix (for octal) is provided.
59
60          bpftool map lookup MAP key DATA
61                 Lookup key in the map.
62
63          bpftool map getnext MAP [key DATA]
64                 Get next key.  If key is not specified, get first key.
65
66          bpftool map delete MAP key DATA
67                 Remove entry from the map.
68
69          bpftool map pin MAP FILE
70                 Pin map MAP as FILE.
71
72                 Note: FILE must be located in bpffs mount.
73
74          bpftool map event_pipe MAP [cpu N index M]
75                 Read events from a BPF_MAP_TYPE_PERF_EVENT_ARRAY map.
76
77                 Install perf rings into a perf event array map and dump  out‐
78                 put  of  any  bpf_perf_event_output() call in the kernel.  By
79                 default read the number of CPUs on  the  system  and  install
80                 perf  ring  for  each  CPU  in the corresponding index in the
81                 array.
82
83                 If cpu and index are specified, install perf ring  for  given
84                 cpu at index in the array (single ring).
85
86                 Note  that installing a perf ring into an array will silently
87                 replace any existing ring.  Any other application  will  stop
88                 receiving events if it installed its rings earlier.
89
90          bpftool map help
91                 Print short help message.
92

OPTIONS

94          -h, --help
95                 Print short generic help message (similar to bpftool help).
96
97          -v, --version
98                 Print version number (similar to bpftool version).
99
100          -j, --json
101                 Generate  JSON output. For commands that cannot produce JSON,
102                 this option has no effect.
103
104          -p, --pretty
105                 Generate human-readable JSON output. Implies -j.
106
107          -f, --bpffs
108                 Show file names of pinned maps.
109

EXAMPLES

111       # bpftool map show
112
113          10: hash  name some_map  flags 0x0
114                key 4B  value 8B  max_entries 2048  memlock 167936B
115
116       The following three commands are equivalent:
117
118       # bpftool map update id 10 key hex   20   c4   b7   00 value hex   0f   ff   ff   ab   01   02   03   4c
119       # bpftool map update id 10 key     0x20 0xc4 0xb7 0x00 value     0x0f 0xff 0xff 0xab 0x01 0x02 0x03 0x4c
120       # bpftool map update id 10 key       32  196  183    0 value       15  255  255  171    1    2    3   76
121
122
123       # bpftool map lookup id 10 key 0 1 2 3
124
125          key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
126
127       # bpftool map dump id 10
128
129          key: 00 01 02 03  value: 00 01 02 03 04 05 06 07
130          key: 0d 00 07 00  value: 02 00 00 00 01 02 03 04
131          Found 2 elements
132
133       # bpftool map getnext id 10 key 0 1 2 3
134
135          key:
136          00 01 02 03
137          next key:
138          0d 00 07 00
139
140       # mount -t bpf none /sys/fs/bpf/
141       # bpftool map pin id 10 /sys/fs/bpf/map
142       # bpftool map del pinned /sys/fs/bpf/map key 13 00 07 00
143
144

SEE ALSO

146          bpftool(8), bpftool-prog(8), bpftool-cgroup(8)
147
148
149
150
151                                                                BPFTOOL-MAP(8)
Impressum