1================ 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** [*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 21MAP 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 event_pipe** *MAP* [**cpu** *N* **index** *M*] 32| **bpftool** **map help** 33| 34| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* } 35| *DATA* := { [**hex**] *BYTES* } 36| *PROG* := { **id** *PROG_ID* | **pinned** *FILE* | **tag** *PROG_TAG* } 37| *VALUE* := { *DATA* | *MAP* | *PROG* } 38| *UPDATE_FLAGS* := { **any** | **exist** | **noexist** } 39 40DESCRIPTION 41=========== 42 **bpftool map { show | list }** [*MAP*] 43 Show information about loaded maps. If *MAP* is specified 44 show information only about given map, otherwise list all 45 maps currently loaded on the system. 46 47 Output will start with map ID followed by map type and 48 zero or more named attributes (depending on kernel version). 49 50 **bpftool map dump** *MAP* 51 Dump all entries in a given *MAP*. 52 53 **bpftool map update** *MAP* **key** *DATA* **value** *VALUE* [*UPDATE_FLAGS*] 54 Update map entry for a given *KEY*. 55 56 *UPDATE_FLAGS* can be one of: **any** update existing entry 57 or add if doesn't exit; **exist** update only if entry already 58 exists; **noexist** update only if entry doesn't exist. 59 60 If the **hex** keyword is provided in front of the bytes 61 sequence, the bytes are parsed as hexadeximal values, even if 62 no "0x" prefix is added. If the keyword is not provided, then 63 the bytes are parsed as decimal values, unless a "0x" prefix 64 (for hexadecimal) or a "0" prefix (for octal) is provided. 65 66 **bpftool map lookup** *MAP* **key** *DATA* 67 Lookup **key** in the map. 68 69 **bpftool map getnext** *MAP* [**key** *DATA*] 70 Get next key. If *key* is not specified, get first key. 71 72 **bpftool map delete** *MAP* **key** *DATA* 73 Remove entry from the map. 74 75 **bpftool map pin** *MAP* *FILE* 76 Pin map *MAP* as *FILE*. 77 78 Note: *FILE* must be located in *bpffs* mount. 79 80 **bpftool** **map event_pipe** *MAP* [**cpu** *N* **index** *M*] 81 Read events from a BPF_MAP_TYPE_PERF_EVENT_ARRAY map. 82 83 Install perf rings into a perf event array map and dump 84 output of any bpf_perf_event_output() call in the kernel. 85 By default read the number of CPUs on the system and 86 install perf ring for each CPU in the corresponding index 87 in the array. 88 89 If **cpu** and **index** are specified, install perf ring 90 for given **cpu** at **index** in the array (single ring). 91 92 Note that installing a perf ring into an array will silently 93 replace any existing ring. Any other application will stop 94 receiving events if it installed its rings earlier. 95 96 **bpftool map help** 97 Print short help message. 98 99OPTIONS 100======= 101 -h, --help 102 Print short generic help message (similar to **bpftool help**). 103 104 -v, --version 105 Print version number (similar to **bpftool version**). 106 107 -j, --json 108 Generate JSON output. For commands that cannot produce JSON, this 109 option has no effect. 110 111 -p, --pretty 112 Generate human-readable JSON output. Implies **-j**. 113 114 -f, --bpffs 115 Show file names of pinned maps. 116 117EXAMPLES 118======== 119**# bpftool map show** 120:: 121 122 10: hash name some_map flags 0x0 123 key 4B value 8B max_entries 2048 memlock 167936B 124 125The following three commands are equivalent: 126 127| 128| **# bpftool map update id 10 key hex 20 c4 b7 00 value hex 0f ff ff ab 01 02 03 4c** 129| **# bpftool map update id 10 key 0x20 0xc4 0xb7 0x00 value 0x0f 0xff 0xff 0xab 0x01 0x02 0x03 0x4c** 130| **# bpftool map update id 10 key 32 196 183 0 value 15 255 255 171 1 2 3 76** 131 132**# bpftool map lookup id 10 key 0 1 2 3** 133 134:: 135 136 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07 137 138 139**# bpftool map dump id 10** 140:: 141 142 key: 00 01 02 03 value: 00 01 02 03 04 05 06 07 143 key: 0d 00 07 00 value: 02 00 00 00 01 02 03 04 144 Found 2 elements 145 146**# bpftool map getnext id 10 key 0 1 2 3** 147:: 148 149 key: 150 00 01 02 03 151 next key: 152 0d 00 07 00 153 154| 155| **# mount -t bpf none /sys/fs/bpf/** 156| **# bpftool map pin id 10 /sys/fs/bpf/map** 157| **# bpftool map del pinned /sys/fs/bpf/map key 13 00 07 00** 158 159SEE ALSO 160======== 161 **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8) 162