From: Jiri Olsa <jolsa@redhat.com>
To: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>
Cc: netdev@vger.kernel.org, bpf@vger.kernel.org,
"Martin KaFai Lau" <kafai@fb.com>,
"Song Liu" <songliubraving@fb.com>, "Yonghong Song" <yhs@fb.com>,
"John Fastabend" <john.fastabend@gmail.com>,
"KP Singh" <kpsingh@chromium.org>,
"Toke Høiland-Jørgensen" <toke@redhat.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Jiri Pirko" <jiri@mellanox.com>
Subject: [PATCH bpf-next 3/3] bpftool: Fix pretty print dump for maps without BTF loaded
Date: Fri, 4 Feb 2022 23:58:23 +0100 [thread overview]
Message-ID: <20220204225823.339548-3-jolsa@kernel.org> (raw)
In-Reply-To: <20220204225823.339548-1-jolsa@kernel.org>
The commit e5043894b21f ("bpftool: Use libbpf_get_error() to check
error") forced map dump with pretty print enabled to has BTF loaded,
which is not necessarily needed.
Keeping the libbpf_get_error call, but setting errno to 0 because
get_map_kv_btf does nothing for this case.
This fixes test_offload.py for me, which failed because of the
pretty print fails with:
Test map dump...
Traceback (most recent call last):
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 1251, in <module>
_, entries = bpftool("map dump id %d" % (m["id"]))
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 169, in bpftool
return tool("bpftool", args, {"json":"-p"}, JSON=JSON, ns=ns,
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 155, in tool
ret, stdout = cmd(ns + name + " " + params + args,
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 109, in cmd
return cmd_result(proc, include_stderr=include_stderr, fail=fail)
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 131, in cmd_result
raise Exception("Command failed: %s\n%s" % (proc.args, stderr))
Exception: Command failed: bpftool -p map dump id 4325
Fixes: e5043894b21f ("bpftool: Use libbpf_get_error() to check error")
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/bpf/bpftool/map.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index c66a3c979b7a..2ccf85042e75 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -862,6 +862,7 @@ map_dump(int fd, struct bpf_map_info *info, json_writer_t *wtr,
prev_key = NULL;
if (wtr) {
+ errno = 0;
btf = get_map_kv_btf(info);
err = libbpf_get_error(btf);
if (err) {
--
2.34.1
next prev parent reply other threads:[~2022-02-04 22:59 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-04 22:58 [PATCH bpf-next 1/3] libbpf: Add names for auxiliary maps Jiri Olsa
2022-02-04 22:58 ` [PATCH bpf-next 2/3] selftests/bpf/test_offload.py: Add more base maps names Jiri Olsa
2022-02-04 22:58 ` Jiri Olsa [this message]
2022-02-04 23:08 ` [PATCH bpf-next 3/3] bpftool: Fix pretty print dump for maps without BTF loaded Andrii Nakryiko
2022-02-04 23:04 ` [PATCH bpf-next 1/3] libbpf: Add names for auxiliary maps Andrii Nakryiko
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=20220204225823.339548-3-jolsa@kernel.org \
--to=jolsa@redhat.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=jiri@mellanox.com \
--cc=john.fastabend@gmail.com \
--cc=kafai@fb.com \
--cc=kpsingh@chromium.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=songliubraving@fb.com \
--cc=toke@redhat.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).