From: Jiri Olsa <hidden> Date: 2022-02-04 22:58:33
Adding names for maps that bpftool uses for various detections.
These maps can appear in final map show output (due to deferred
removal in kernel) so some tests (like test_offload.py) needs
to filter them out.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/lib/bpf/libbpf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
From: Jiri Olsa <hidden> Date: 2022-02-04 22:58:39
Adding more base maps that can show in bpftool map output,
so we can properly filter them out.
This fixes for me following test_offload.py failure:
Test bpftool bound info reporting (own ns)...
FAIL: 3 BPF maps loaded, expected 2
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 1177, in <module>
check_dev_info(False, "")
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 645, in check_dev_info
maps = bpftool_map_list(expected=2, ns=ns)
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 190, in bpftool_map_list
fail(True, "%d BPF maps loaded, expected %d" %
File "/root/bpf-next/tools/testing/selftests/bpf/./test_offload.py", line 86, in fail
tb = "".join(traceback.extract_stack().format())
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/testing/selftests/bpf/test_offload.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
@@ -769,7 +769,11 @@ skip(ret != 0, "bpftool not installed")base_progs=progs_,base_maps=bpftool("map")base_map_names=[-'pid_iter.rodata'# created on each bpftool invocation+# created on each bpftool invocation+'pid_iter.rodata',+'bind_map_detect',+'global_data',+'array_mmap',]# Check netdevsim
From: Jiri Olsa <hidden> Date: 2022-02-04 22:59:17
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(+)
On Fri, Feb 4, 2022 at 2:58 PM Jiri Olsa [off-list ref] wrote:
quoted hunk
Adding names for maps that bpftool uses for various detections.
These maps can appear in final map show output (due to deferred
removal in kernel) so some tests (like test_offload.py) needs
to filter them out.
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
---
tools/lib/bpf/libbpf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
@@ -4412,7 +4412,7 @@ static int probe_kern_global_data(void)};intret,map,insn_cnt=ARRAY_SIZE(insns);-map=bpf_map_create(BPF_MAP_TYPE_ARRAY,NULL,sizeof(int),32,1,NULL);+map=bpf_map_create(BPF_MAP_TYPE_ARRAY,"global_data",sizeof(int),32,1,NULL);
some old kernel versions don't support map names, so you can't just
blindly specify them and log error
I'd rather fix test_offload.py instead of "fixing" libbpf.
quoted hunk
if (map < 0) {
ret = -errno;
cp = libbpf_strerror_r(ret, errmsg, sizeof(errmsg));
On Fri, Feb 4, 2022 at 2:58 PM Jiri Olsa [off-list ref] wrote:
quoted hunk
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(+)
I don't think that's right. errno can be modified by something inside
get_map_kv_btf() so this is unreliable approach. It's better to change
get_map_kv_btf() to return an error explicitly and a btf pointer
separate from error. Because btf == NULL isn't necessarily due to an
error anymore.