netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: Benjamin Poirier <bpoirier@suse.com>
Cc: Daniel Borkmann <daniel@iogearbox.net>,
	netdev@vger.kernel.org, bpf@vger.kernel.org
Subject: Re: [PATCH v2 bpf-next 2/2] bpftool: Improve handling of ENOSPC on reuseport_array map dumps
Date: Fri, 12 Apr 2019 17:00:33 -0700	[thread overview]
Message-ID: <20190412170033.4249f5a7@cakuba.netronome.com> (raw)
In-Reply-To: <20190412030322.15494-2-bpoirier@suse.com>

On Fri, 12 Apr 2019 12:03:22 +0900, Benjamin Poirier wrote:
> avoids outputting a series of
> 	value:
> 	No space left on device
> 
> The value itself is not wrong but bpf_fd_reuseport_array_lookup_elem() can
> only return it if the map was created with value_size = 8. There's nothing
> bpftool can do about it. Instead of repeating this error for every key in
> the map, print an explanatory warning and a specialized error.
> 
> example before:
> key: 00 00 00 00
> value:
> No space left on device
> key: 01 00 00 00
> value:
> No space left on device
> key: 02 00 00 00
> value:
> No space left on device
> Found 0 elements
> 
> example after:
> Warning: cannot read values from reuseport_sockarray map with value_size != 8
> key: 00 00 00 00  value: <cannot read>
> key: 01 00 00 00  value: <cannot read>
> key: 02 00 00 00  value: <cannot read>
> Found 0 elements
> 
> Signed-off-by: Benjamin Poirier <bpoirier@suse.com>
> ---
>  tools/bpf/bpftool/map.c | 11 ++++++++++-
>  1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index 71840faaeab5..e6d72f777767 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -716,8 +716,12 @@ static int dump_map_elem(int fd, void *key, void *value,
>  	} else {
>  		const char *msg = NULL;
>  
> -		if (errno == ENOENT)
> +		if (lookup_errno == ENOENT) {
>  			msg = "<no entry>";
> +		} else if (lookup_errno == ENOSPC && map_info->type ==
> +			 BPF_MAP_TYPE_REUSEPORT_SOCKARRAY) {
> +			msg = "<cannot read>";
> +		}

In addition to Quentin's nit please don't use the curly brackets for
single-line statements.

>  		print_entry_error(map_info, key,
>  				  msg ? : strerror(lookup_errno), !!msg);
> @@ -774,6 +778,11 @@ static int do_dump(int argc, char **argv)
>  			}
>  		}
>  
> +	if (info.type == BPF_MAP_TYPE_REUSEPORT_SOCKARRAY &&
> +	    info.value_size != 8) {
> +		p_info("Warning: cannot read values from %s map with value_size != 8",
> +		       map_type_name[info.type]);
> +	}

Same here :)

>  	while (true) {
>  		err = bpf_map_get_next_key(fd, prev_key, key);
>  		if (err) {


  parent reply	other threads:[~2019-04-13  0:00 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11  8:27 [PATCH bpf-next] bpftool: Exit early when it's not possible to dump a REUSEPORT_SOCKARRAY map Benjamin Poirier
2019-04-11 11:20 ` Quentin Monnet
2019-04-11 20:31 ` Jakub Kicinski
2019-04-12  3:03 ` [PATCH v2 bpf-next 1/2] bpftool: Use print_entry_error() in case of ENOENT when dumping Benjamin Poirier
2019-04-12  3:03   ` [PATCH v2 bpf-next 2/2] bpftool: Improve handling of ENOSPC on reuseport_array map dumps Benjamin Poirier
2019-04-12 10:28     ` Quentin Monnet
2019-04-13  0:00     ` Jakub Kicinski [this message]
2019-04-12 10:28   ` [PATCH v2 bpf-next 1/2] bpftool: Use print_entry_error() in case of ENOENT when dumping Quentin Monnet
2019-04-12 22:49     ` Benjamin Poirier
2019-04-12 23:53       ` Jakub Kicinski
2019-04-14 23:29         ` Benjamin Poirier
2019-04-12 23:57   ` Jakub Kicinski
2019-04-15  7:15   ` [PATCH v3 " Benjamin Poirier
2019-04-15  7:15     ` [PATCH v3 bpf-next 2/2] bpftool: Improve handling of ENOSPC on reuseport_array map dumps Benjamin Poirier
2019-04-15  9:20       ` Quentin Monnet
2019-04-15 18:38       ` Jakub Kicinski
2019-04-15  9:18     ` [PATCH v3 bpf-next 1/2] bpftool: Use print_entry_error() in case of ENOENT when dumping Quentin Monnet
2019-04-15 18:38     ` Jakub Kicinski
2019-04-16  8:29     ` Daniel Borkmann

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=20190412170033.4249f5a7@cakuba.netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=bpf@vger.kernel.org \
    --cc=bpoirier@suse.com \
    --cc=daniel@iogearbox.net \
    --cc=netdev@vger.kernel.org \
    /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).