From: Stanislav Fomichev <sdf@fomichev.me>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Stanislav Fomichev <sdf@google.com>,
netdev@vger.kernel.org, davem@davemloft.net, ast@kernel.org,
daniel@iogearbox.net, quentin.monnet@netronome.com
Subject: Re: [PATCH bpf-next 6/6] bpftool: add pop and dequeue commands
Date: Wed, 16 Jan 2019 08:45:31 -0800 [thread overview]
Message-ID: <20190116164531.GC726@mini-arch> (raw)
In-Reply-To: <20190115174618.0bd5e56b@cakuba.netronome.com>
On 01/15, Jakub Kicinski wrote:
> On Tue, 15 Jan 2019 15:22:52 -0800, Stanislav Fomichev wrote:
> > +static int do_pop_dequeue(int argc, char **argv)
> > +{
> > + struct bpf_map_info info = {};
> > + __u32 len = sizeof(info);
> > + void *key, *value;
> > + int err;
> > + int fd;
> > +
> > + if (argc < 2)
> > + usage();
> > +
> > + fd = map_parse_fd_and_info(&argc, &argv, &info, &len);
> > + if (fd < 0)
> > + return -1;
> > +
> > + err = alloc_key_value(&info, &key, &value);
> > + if (err)
> > + goto exit_free;
> > +
> > + err = bpf_map_lookup_and_delete_elem(fd, key, value);
> > + if (err) {
> > + if (errno == ENOENT) {
> > + if (json_output)
> > + jsonw_null(json_wtr);
> > + else
> > + printf("Error: empty map\n");
> > + } else {
> > + p_err("pop failed: %s", strerror(errno));
> > + }
> > +
> > + goto exit_free;
> > + }
> > +
> > + print_key_value(&info, key, value);
> > +
> > +exit_free:
> > + free(key);
> > + free(value);
> > + close(fd);
> > +
> > + if (!err && json_output)
> > + jsonw_null(json_wtr);
>
> These two lines look out of place?
Ah, indeed, sorry about that. Will remove in v2.
>
> > + return err;
> > +}
next prev parent reply other threads:[~2019-01-16 16:45 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 ` [PATCH bpf-next 5/6] bpftool: add push and enqueue commands Stanislav Fomichev
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 [this message]
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=20190116164531.GC726@mini-arch \
--to=sdf@fomichev.me \
--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 \
--cc=sdf@google.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).