Commit 66cf6e0b authored by Stanislav Fomichev's avatar Stanislav Fomichev Committed by Daniel Borkmann

bpftool: add peek command

This is intended to be used with queues and stacks and be more
user-friendly than 'lookup' without key/value.

Example:
bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
bpftool map update pinned /sys/fs/bpf/q value 0 1 2 3
bpftool map peek pinned /sys/fs/bpf/q
value: 00 01 02 03
Signed-off-by: default avatarStanislav Fomichev <sdf@google.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 04a5d323
...@@ -31,6 +31,7 @@ MAP COMMANDS ...@@ -31,6 +31,7 @@ MAP COMMANDS
| **bpftool** **map delete** *MAP* **key** *DATA* | **bpftool** **map delete** *MAP* **key** *DATA*
| **bpftool** **map pin** *MAP* *FILE* | **bpftool** **map pin** *MAP* *FILE*
| **bpftool** **map event_pipe** *MAP* [**cpu** *N* **index** *M*] | **bpftool** **map event_pipe** *MAP* [**cpu** *N* **index** *M*]
| **bpftool** **map peek** *MAP*
| **bpftool** **map help** | **bpftool** **map help**
| |
| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* } | *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
...@@ -107,6 +108,9 @@ DESCRIPTION ...@@ -107,6 +108,9 @@ DESCRIPTION
replace any existing ring. Any other application will stop replace any existing ring. Any other application will stop
receiving events if it installed its rings earlier. receiving events if it installed its rings earlier.
**bpftool map peek** *MAP*
Peek next **value** in the queue or stack.
**bpftool map help** **bpftool map help**
Print short help message. Print short help message.
......
...@@ -1168,6 +1168,7 @@ static int do_help(int argc, char **argv) ...@@ -1168,6 +1168,7 @@ static int do_help(int argc, char **argv)
" %s %s delete MAP key DATA\n" " %s %s delete MAP key DATA\n"
" %s %s pin MAP FILE\n" " %s %s pin MAP FILE\n"
" %s %s event_pipe MAP [cpu N index M]\n" " %s %s event_pipe MAP [cpu N index M]\n"
" %s %s peek MAP\n"
" %s %s help\n" " %s %s help\n"
"\n" "\n"
" " HELP_SPEC_MAP "\n" " " HELP_SPEC_MAP "\n"
...@@ -1185,7 +1186,7 @@ static int do_help(int argc, char **argv) ...@@ -1185,7 +1186,7 @@ static int do_help(int argc, char **argv)
bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2],
bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2],
bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2], bin_name, argv[-2],
bin_name, argv[-2]); bin_name, argv[-2], bin_name, argv[-2]);
return 0; return 0;
} }
...@@ -1202,6 +1203,7 @@ static const struct cmd cmds[] = { ...@@ -1202,6 +1203,7 @@ static const struct cmd cmds[] = {
{ "pin", do_pin }, { "pin", do_pin },
{ "event_pipe", do_event_pipe }, { "event_pipe", do_event_pipe },
{ "create", do_create }, { "create", do_create },
{ "peek", do_lookup },
{ 0 } { 0 }
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment