Jakub Kicinski | ff69c21 | 2017-10-04 20:10:05 -0700 | [diff] [blame] | 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 | |
Quentin Monnet | 0641c3c | 2017-10-23 09:24:16 -0700 | [diff] [blame] | 13 | **bpftool** [*OPTIONS*] **map** *COMMAND* |
| 14 | |
Prashant Bhole | c541b73 | 2017-11-08 13:55:49 +0900 | [diff] [blame] | 15 | *OPTIONS* := { { **-j** | **--json** } [{ **-p** | **--pretty** }] | { **-f** | **--bpffs** } } |
Jakub Kicinski | ff69c21 | 2017-10-04 20:10:05 -0700 | [diff] [blame] | 16 | |
| 17 | *COMMANDS* := |
Jakub Kicinski | 6ebe6db | 2018-01-02 14:48:36 -0800 | [diff] [blame^] | 18 | { **show** | **list** | **dump** | **update** | **lookup** | **getnext** | **delete** |
Quentin Monnet | 47ff7ac | 2017-10-23 09:24:15 -0700 | [diff] [blame] | 19 | | **pin** | **help** } |
Jakub Kicinski | ff69c21 | 2017-10-04 20:10:05 -0700 | [diff] [blame] | 20 | |
| 21 | MAP COMMANDS |
| 22 | ============= |
| 23 | |
Jakub Kicinski | 6ebe6db | 2018-01-02 14:48:36 -0800 | [diff] [blame^] | 24 | | **bpftool** **map { show | list }** [*MAP*] |
Quentin Monnet | 47ff7ac | 2017-10-23 09:24:15 -0700 | [diff] [blame] | 25 | | **bpftool** **map dump** *MAP* |
| 26 | | **bpftool** **map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*] |
| 27 | | **bpftool** **map lookup** *MAP* **key** *BYTES* |
| 28 | | **bpftool** **map getnext** *MAP* [**key** *BYTES*] |
| 29 | | **bpftool** **map delete** *MAP* **key** *BYTES* |
| 30 | | **bpftool** **map pin** *MAP* *FILE* |
| 31 | | **bpftool** **map help** |
Jakub Kicinski | ff69c21 | 2017-10-04 20:10:05 -0700 | [diff] [blame] | 32 | | |
Quentin Monnet | 47ff7ac | 2017-10-23 09:24:15 -0700 | [diff] [blame] | 33 | | *MAP* := { **id** *MAP_ID* | **pinned** *FILE* } |
| 34 | | *VALUE* := { *BYTES* | *MAP* | *PROGRAM* } |
| 35 | | *UPDATE_FLAGS* := { **any** | **exist** | **noexist** } |
Jakub Kicinski | ff69c21 | 2017-10-04 20:10:05 -0700 | [diff] [blame] | 36 | |
| 37 | DESCRIPTION |
| 38 | =========== |
Jakub Kicinski | 6ebe6db | 2018-01-02 14:48:36 -0800 | [diff] [blame^] | 39 | **bpftool map { show | list }** [*MAP*] |
Jakub Kicinski | ff69c21 | 2017-10-04 20:10:05 -0700 | [diff] [blame] | 40 | Show information about loaded maps. If *MAP* is specified |
| 41 | show information only about given map, otherwise list all |
| 42 | maps currently loaded on the system. |
| 43 | |
| 44 | Output will start with map ID followed by map type and |
| 45 | zero or more named attributes (depending on kernel version). |
| 46 | |
| 47 | **bpftool map dump** *MAP* |
| 48 | Dump all entries in a given *MAP*. |
| 49 | |
| 50 | **bpftool map update** *MAP* **key** *BYTES* **value** *VALUE* [*UPDATE_FLAGS*] |
| 51 | Update map entry for a given *KEY*. |
| 52 | |
| 53 | *UPDATE_FLAGS* can be one of: **any** update existing entry |
| 54 | or add if doesn't exit; **exist** update only if entry already |
| 55 | exists; **noexist** update only if entry doesn't exist. |
| 56 | |
| 57 | **bpftool map lookup** *MAP* **key** *BYTES* |
| 58 | Lookup **key** in the map. |
| 59 | |
| 60 | **bpftool map getnext** *MAP* [**key** *BYTES*] |
| 61 | Get next key. If *key* is not specified, get first key. |
| 62 | |
| 63 | **bpftool map delete** *MAP* **key** *BYTES* |
| 64 | Remove entry from the map. |
| 65 | |
| 66 | **bpftool map pin** *MAP* *FILE* |
| 67 | Pin map *MAP* as *FILE*. |
| 68 | |
| 69 | Note: *FILE* must be located in *bpffs* mount. |
| 70 | |
| 71 | **bpftool map help** |
| 72 | Print short help message. |
| 73 | |
Quentin Monnet | a2bc2e5 | 2017-10-23 09:24:06 -0700 | [diff] [blame] | 74 | OPTIONS |
| 75 | ======= |
| 76 | -h, --help |
| 77 | Print short generic help message (similar to **bpftool help**). |
| 78 | |
| 79 | -v, --version |
| 80 | Print version number (similar to **bpftool version**). |
| 81 | |
Quentin Monnet | 0641c3c | 2017-10-23 09:24:16 -0700 | [diff] [blame] | 82 | -j, --json |
| 83 | Generate JSON output. For commands that cannot produce JSON, this |
| 84 | option has no effect. |
| 85 | |
| 86 | -p, --pretty |
| 87 | Generate human-readable JSON output. Implies **-j**. |
| 88 | |
Prashant Bhole | c541b73 | 2017-11-08 13:55:49 +0900 | [diff] [blame] | 89 | -f, --bpffs |
| 90 | Show file names of pinned maps. |
| 91 | |
Jakub Kicinski | ff69c21 | 2017-10-04 20:10:05 -0700 | [diff] [blame] | 92 | EXAMPLES |
| 93 | ======== |
| 94 | **# bpftool map show** |
| 95 | :: |
| 96 | |
| 97 | 10: hash name some_map flags 0x0 |
| 98 | key 4B value 8B max_entries 2048 memlock 167936B |
| 99 | |
| 100 | **# bpftool map update id 10 key 13 00 07 00 value 02 00 00 00 01 02 03 04** |
| 101 | |
| 102 | **# bpftool map lookup id 10 key 0 1 2 3** |
| 103 | |
| 104 | :: |
| 105 | |
| 106 | key: 00 01 02 03 value: 00 01 02 03 04 05 06 07 |
| 107 | |
| 108 | |
| 109 | **# bpftool map dump id 10** |
| 110 | :: |
| 111 | |
| 112 | key: 00 01 02 03 value: 00 01 02 03 04 05 06 07 |
| 113 | key: 0d 00 07 00 value: 02 00 00 00 01 02 03 04 |
| 114 | Found 2 elements |
| 115 | |
| 116 | **# bpftool map getnext id 10 key 0 1 2 3** |
| 117 | :: |
| 118 | |
| 119 | key: |
| 120 | 00 01 02 03 |
| 121 | next key: |
| 122 | 0d 00 07 00 |
| 123 | |
| 124 | | |
| 125 | | **# mount -t bpf none /sys/fs/bpf/** |
| 126 | | **# bpftool map pin id 10 /sys/fs/bpf/map** |
| 127 | | **# bpftool map del pinned /sys/fs/bpf/map key 13 00 07 00** |
| 128 | |
| 129 | SEE ALSO |
| 130 | ======== |
Roman Gushchin | 5ccda64 | 2017-12-13 15:18:54 +0000 | [diff] [blame] | 131 | **bpftool**\ (8), **bpftool-prog**\ (8), **bpftool-cgroup**\ (8) |