From: Quentin Monnet <quentin.monnet@netronome.com>
To: Krzesimir Nowak <krzesimir@kinvolk.io>, bpf@vger.kernel.org
Cc: "Alban Crequy" <alban@kinvolk.io>,
"Iago López Galeiras" <iago@kinvolk.io>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Martin KaFai Lau" <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"Jakub Kicinski" <jakub.kicinski@netronome.com>,
"Stanislav Fomichev" <sdf@google.com>,
"Prashant Bhole" <bhole_prashant_q7@lab.ntt.co.jp>,
"Okash Khawaja" <osk@fb.com>,
"David Calavera" <david.calavera@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [BPF v1] tools: bpftool: Fix JSON output when lookup fails
Date: Thu, 6 Jun 2019 09:35:03 +0100 [thread overview]
Message-ID: <3b26789b-3b51-8c47-b710-8df09b63ce73@netronome.com> (raw)
In-Reply-To: <20190605191707.24429-1-krzesimir@kinvolk.io>
2019-06-05 21:17 UTC+0200 ~ Krzesimir Nowak <krzesimir@kinvolk.io>
> In commit 9a5ab8bf1d6d ("tools: bpftool: turn err() and info() macros
> into functions") one case of error reporting was special cased, so it
> could report a lookup error for a specific key when dumping the map
> element. What the code forgot to do is to wrap the key and value keys
> into a JSON object, so an example output of pretty JSON dump of a
> sockhash map (which does not support looking up its values) is:
>
> [
> "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x00"
> ],
> "value": {
> "error": "Operation not supported"
> },
> "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x01"
> ],
> "value": {
> "error": "Operation not supported"
> }
> ]
>
> Note the key-value pairs inside the toplevel array. They should be
> wrapped inside a JSON object, otherwise it is an invalid JSON. This
> commit fixes this, so the output now is:
>
> [{
> "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x00"
> ],
> "value": {
> "error": "Operation not supported"
> }
> },{
> "key": ["0x0a","0x41","0x00","0x02","0x1f","0x78","0x00","0x01"
> ],
> "value": {
> "error": "Operation not supported"
> }
> }
> ]
>
> Fixes: 9a5ab8bf1d6d ("tools: bpftool: turn err() and info() macros into functions")
> Cc: Quentin Monnet <quentin.monnet@netronome.com>
> Signed-off-by: Krzesimir Nowak <krzesimir@kinvolk.io>
Thanks for the fix!
Quentin
prev parent reply other threads:[~2019-06-06 8:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-05 19:17 [BPF v1] tools: bpftool: Fix JSON output when lookup fails Krzesimir Nowak
2019-06-05 19:36 ` Andrii Nakryiko
2019-06-05 20:10 ` Daniel Borkmann
2019-06-06 8:35 ` Quentin Monnet [this message]
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=3b26789b-3b51-8c47-b710-8df09b63ce73@netronome.com \
--to=quentin.monnet@netronome.com \
--cc=alban@kinvolk.io \
--cc=ast@kernel.org \
--cc=bhole_prashant_q7@lab.ntt.co.jp \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=david.calavera@gmail.com \
--cc=iago@kinvolk.io \
--cc=jakub.kicinski@netronome.com \
--cc=kafai@fb.com \
--cc=krzesimir@kinvolk.io \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=osk@fb.com \
--cc=sdf@google.com \
--cc=songliubraving@fb.com \
--cc=yhs@fb.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).