From: Stanislav Fomichev <sdf@google.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, ast@kernel.org, daniel@iogearbox.net,
jakub.kicinski@netronome.com, quentin.monnet@netronome.com,
Stanislav Fomichev <sdf@google.com>
Subject: [PATCH bpf-next 5/6] bpftool: add push and enqueue commands
Date: Tue, 15 Jan 2019 15:22:51 -0800 [thread overview]
Message-ID: <20190115232252.5736-6-sdf@google.com> (raw)
In-Reply-To: <20190115232252.5736-1-sdf@google.com>
This is intended to be used with queues and stacks and be more
user-friendly than 'update' without the key.
Example:
bpftool map create /sys/fs/bpf/q type queue value 4 entries 10 name q
bpftool map push pinned /sys/fs/bpf/q value 0 1 2 3
bpftool map peek pinned /sys/fs/bpf/q
value: 00 01 02 03
bpftool map create /sys/fs/bpf/s type stack value 4 entries 10 name s
bpftool map enqueue pinned /sys/fs/bpf/s value 0 1 2 3
bpftool map peek pinned /sys/fs/bpf/s
value: 00 01 02 03
Signed-off-by: Stanislav Fomichev <sdf@google.com>
---
tools/bpf/bpftool/Documentation/bpftool-map.rst | 8 ++++++++
tools/bpf/bpftool/bash-completion/bpftool | 4 ++--
tools/bpf/bpftool/map.c | 7 ++++++-
3 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/tools/bpf/bpftool/Documentation/bpftool-map.rst b/tools/bpf/bpftool/Documentation/bpftool-map.rst
index b79da683da88..435a79d2eed5 100644
--- a/tools/bpf/bpftool/Documentation/bpftool-map.rst
+++ b/tools/bpf/bpftool/Documentation/bpftool-map.rst
@@ -32,6 +32,8 @@ MAP COMMANDS
| **bpftool** **map pin** *MAP* *FILE*
| **bpftool** **map event_pipe** *MAP* [**cpu** *N* **index** *M*]
| **bpftool** **map peek** *MAP*
+| **bpftool** **map push** *MAP* **value** *VALUE*
+| **bpftool** **map enqueue** *MAP* **value** *VALUE*
| **bpftool** **map help**
|
| *MAP* := { **id** *MAP_ID* | **pinned** *FILE* }
@@ -111,6 +113,12 @@ DESCRIPTION
**bpftool map peek** *MAP*
Peek next **value** in the queue or stack.
+ **bpftool map push** *MAP* **value** *VALUE*
+ Push **value** onto the stack.
+
+ **bpftool map enqueue** *MAP* **value** *VALUE*
+ Enqueue **value** into the queue.
+
**bpftool map help**
Print short help message.
diff --git a/tools/bpf/bpftool/bash-completion/bpftool b/tools/bpf/bpftool/bash-completion/bpftool
index fe4880d9bd8d..69096e058308 100644
--- a/tools/bpf/bpftool/bash-completion/bpftool
+++ b/tools/bpf/bpftool/bash-completion/bpftool
@@ -452,7 +452,7 @@ _bpftool()
;;
esac
;;
- update)
+ update|push|enqueue)
case $prev in
$command)
COMPREPLY=( $( compgen -W "$MAP_TYPE" -- "$cur" ) )
@@ -547,7 +547,7 @@ _bpftool()
[[ $prev == $object ]] && \
COMPREPLY=( $( compgen -W 'delete dump getnext help \
lookup pin event_pipe show list update create \
- peek' -- \
+ peek push enqueue' -- \
"$cur" ) )
;;
esac
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index d7344fcd2089..6b5fcbe2d9d4 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -1169,6 +1169,8 @@ static int do_help(int argc, char **argv)
" %s %s pin MAP FILE\n"
" %s %s event_pipe MAP [cpu N index M]\n"
" %s %s peek MAP\n"
+ " %s %s push MAP value VALUE\n"
+ " %s %s enqueue MAP value VALUE\n"
" %s %s help\n"
"\n"
" " HELP_SPEC_MAP "\n"
@@ -1186,7 +1188,8 @@ 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]);
return 0;
}
@@ -1204,6 +1207,8 @@ static const struct cmd cmds[] = {
{ "event_pipe", do_event_pipe },
{ "create", do_create },
{ "peek", do_lookup },
+ { "push", do_update },
+ { "enqueue", do_update },
{ 0 }
};
--
2.20.1.97.g81188d93c3-goog
next prev parent reply other threads:[~2019-01-15 23:23 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-15 23:22 [PATCH bpf-next 0/6] bpftool: support queue and stack Stanislav Fomichev
2019-01-15 23:22 ` [PATCH bpf-next 1/6] bpftool: make key and value optional in update command Stanislav Fomichev
2019-01-15 23:22 ` [PATCH bpf-next 2/6] bpftool: make key optional in lookup command Stanislav Fomichev
2019-01-15 23:22 ` [PATCH bpf-next 3/6] bpftool: don't print empty key/value for maps Stanislav Fomichev
2019-01-15 23:22 ` [PATCH bpf-next 4/6] bpftool: add peek command Stanislav Fomichev
2019-01-15 23:22 ` Stanislav Fomichev [this message]
2019-01-15 23:22 ` [PATCH bpf-next 6/6] bpftool: add pop and dequeue commands Stanislav Fomichev
2019-01-16 1:46 ` Jakub Kicinski
2019-01-16 16:45 ` Stanislav Fomichev
2019-01-16 1:52 ` [PATCH bpf-next 0/6] bpftool: support queue and stack Jakub Kicinski
2019-01-16 16:52 ` Stanislav Fomichev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190115232252.5736-6-sdf@google.com \
--to=sdf@google.com \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=jakub.kicinski@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=quentin.monnet@netronome.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).