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 BYTES   value VALUE [UPDATE_FLAGS]
21       bpftool map lookup  MAP  key BYTES
22       bpftool map getnext MAP [key BYTES]
23       bpftool map delete  MAP  key BYTES
24       bpftool map pin     MAP  FILE
25       bpftool map help
26
27       MAP := { id MAP_ID | pinned FILE }
28       PROG := { id PROG_ID | pinned FILE | tag PROG_TAG }
29       VALUE := { BYTES | MAP | PROG }
30       UPDATE_FLAGS := { any | exist | noexist }
31
32

DESCRIPTION

34          bpftool map { show | list } [MAP]
35                 Show information about loaded maps.  If MAP is specified show
36                 information only about given map,  otherwise  list  all  maps
37                 currently loaded on the system.
38
39                 Output  will  start with map ID followed by map type and zero
40                 or more named attributes (depending on kernel version).
41
42          bpftool map dump MAP
43                 Dump all entries in a given MAP.
44
45          bpftool map update MAP key BYTES value VALUE [UPDATE_FLAGS]
46                 Update map entry for a given KEY.
47
48                 UPDATE_FLAGS can be one of: any update existing entry or  add
49                 if  doesn't  exit; exist update only if entry already exists;
50                 noexist update only if entry doesn't exist.
51
52          bpftool map lookup MAP key BYTES
53                 Lookup key in the map.
54
55          bpftool map getnext MAP [key BYTES]
56                 Get next key.  If key is not specified, get first key.
57
58          bpftool map delete MAP key BYTES
59                 Remove entry from the map.
60
61          bpftool map pin MAP FILE
62                 Pin map MAP as FILE.
63
64                 Note: FILE must be located in bpffs mount.
65
66          bpftool map help
67                 Print short help message.
68

OPTIONS

70          -h, --help
71                 Print short generic help message (similar to bpftool help).
72
73          -v, --version
74                 Print version number (similar to bpftool version).
75
76          -j, --json
77                 Generate JSON output. For commands that cannot produce  JSON,
78                 this option has no effect.
79
80          -p, --pretty
81                 Generate human-readable JSON output. Implies -j.
82
83          -f, --bpffs
84                 Show file names of pinned maps.
85

EXAMPLES

87       # bpftool map show
88
89          10: hash  name some_map  flags 0x0
90                key 4B  value 8B  max_entries 2048  memlock 167936B
91
92       #  bpftool  map update id 10 key 13 00 07 00 value 02 00 00 00 01 02 03
93       04
94
95       # bpftool map lookup id 10 key 0 1 2 3
96
97          key: 00 01 02 03 value: 00 01 02 03 04 05 06 07
98
99       # bpftool map dump id 10
100
101          key: 00 01 02 03  value: 00 01 02 03 04 05 06 07
102          key: 0d 00 07 00  value: 02 00 00 00 01 02 03 04
103          Found 2 elements
104
105       # bpftool map getnext id 10 key 0 1 2 3
106
107          key:
108          00 01 02 03
109          next key:
110          0d 00 07 00
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
116

SEE ALSO

118          bpftool(8), bpftool-prog(8), bpftool-cgroup(8)
119
120
121
122
123                                                                BPFTOOL-MAP(8)
Impressum