[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190116164531.GC726@mini-arch>
Date: Wed, 16 Jan 2019 08:45:31 -0800
From: Stanislav Fomichev <sdf@...ichev.me>
To: Jakub Kicinski <jakub.kicinski@...ronome.com>
Cc: Stanislav Fomichev <sdf@...gle.com>, netdev@...r.kernel.org,
davem@...emloft.net, ast@...nel.org, daniel@...earbox.net,
quentin.monnet@...ronome.com
Subject: Re: [PATCH bpf-next 6/6] bpftool: add pop and dequeue commands
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;
> > +}
Powered by blists - more mailing lists