mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Quentin Monnet <quentin.monnet@netronome.com>
To: Alban Crequy <alban.crequy@gmail.com>,
	ast@kernel.org, daniel@iogearbox.net
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	alban@kinvolk.io, iago@kinvolk.io
Subject: Re: [PATCH bpf-next v1 7/7] tools: bpftool: add error message on map pinning failure
Date: Wed, 20 Mar 2019 19:01:28 +0000	[thread overview]
Message-ID: <f6872b7e-c1b4-748f-91c4-005d7d67c77a@netronome.com> (raw)
In-Reply-To: <20190320173332.18105-7-alban@kinvolk.io>

2019-03-20 18:33 UTC+0100 ~ Alban Crequy <alban.crequy@gmail.com>
> From: Alban Crequy <alban@kinvolk.io>
> 
> Symptoms, when "dir" does not exist:
> 
> $ sudo bpftool map create /sys/fs/bpf/dir/fooB type hash key 8 value 8 entries 8 name fooB flags 1
> $ echo $?
> 255
> 
> This patch prints an error message when the map pinning fails.
> 
> Signed-off-by: Alban Crequy <alban@kinvolk.io>
> ---
>  tools/bpf/bpftool/map.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
> index 9befcabc299d..c825eb1bbf8f 100644
> --- a/tools/bpf/bpftool/map.c
> +++ b/tools/bpf/bpftool/map.c
> @@ -1305,8 +1305,10 @@ static int do_create(int argc, char **argv)
>  
>  	err = do_pin_fd(fd, pinfile);
>  	close(fd);
> -	if (err)
> +	if (err) {
> +		p_err("failed to pin map to %s", pinfile);
>  		return err;
> +	}

do_pin_fd() is already susceptible to print an error message, and this
may lead to several messages (thus breaking JSON output).

Instead, you could change do_pin_fd() to store the result from
bpf_obj_pin(), compare it, and print the message there if non-0.

>  
>  	if (json_output)
>  		jsonw_null(json_wtr);
> 


  reply	other threads:[~2019-03-20 19:01 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-20 17:33 [PATCH bpf-next v1 1/7] tools: bpftool: fix infinite loop Alban Crequy
2019-03-20 17:33 ` [PATCH bpf-next v1 2/7] tools: bpftool: fix error message on invalid argument count Alban Crequy
2019-03-20 21:02   ` Jakub Kicinski
2019-03-20 17:33 ` [PATCH bpf-next v1 3/7] tools: bpftool: create map of maps Alban Crequy
2019-03-20 19:00   ` Quentin Monnet
2019-03-20 17:33 ` [PATCH bpf-next v1 4/7] tools: bpftool: implement map exec command Alban Crequy
2019-03-20 19:01   ` Quentin Monnet
2019-03-20 21:23   ` Jakub Kicinski
2019-03-21  9:57     ` Alban Crequy
2019-03-21 20:16       ` Jakub Kicinski
2019-03-20 17:33 ` [PATCH bpf-next v1 5/7] tools: bpftool: support loading map by fd from parent process Alban Crequy
2019-03-20 19:05   ` Quentin Monnet
2019-03-20 17:33 ` [PATCH bpf-next v1 6/7] tools: bpftool: fix bpffs mount when pinning subdirectories Alban Crequy
2019-03-20 19:01   ` Quentin Monnet
2019-03-20 17:33 ` [PATCH bpf-next v1 7/7] tools: bpftool: add error message on map pinning failure Alban Crequy
2019-03-20 19:01   ` Quentin Monnet [this message]
2019-03-20 20:54 ` [PATCH bpf-next v1 1/7] tools: bpftool: fix infinite loop Jakub Kicinski

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=f6872b7e-c1b4-748f-91c4-005d7d67c77a@netronome.com \
    --to=quentin.monnet@netronome.com \
    --cc=alban.crequy@gmail.com \
    --cc=alban@kinvolk.io \
    --cc=ast@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=iago@kinvolk.io \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®