[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190115174618.0bd5e56b@cakuba.netronome.com>
Date: Tue, 15 Jan 2019 17:46:18 -0800
From: Jakub Kicinski <jakub.kicinski@...ronome.com>
To: Stanislav Fomichev <sdf@...gle.com>
Cc: 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 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?
> + return err;
> +}
Powered by blists - more mailing lists