]> git.baikalelectronics.ru Git - kernel.git/commit
libbpf: Return btf_fd for load_sk_storage_btf
authorMichal Rostecki <mrostecki@opensuse.org>
Wed, 29 May 2019 18:31:09 +0000 (20:31 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Sat, 1 Jun 2019 00:03:39 +0000 (17:03 -0700)
commit3d9baaced37030cee20f4d642fcbeec3a51578df
tree7c5a15cd500f3fd35f8357672f97fd0ab8b0e74e
parent076eda31dc9343ad2e4be5b5cab2b7413a33748e
libbpf: Return btf_fd for load_sk_storage_btf

Before this change, function load_sk_storage_btf expected that
libbpf__probe_raw_btf was returning a BTF descriptor, but in fact it was
returning an information about whether the probe was successful (0 or
1). load_sk_storage_btf was using that value as an argument of the close
function, which was resulting in closing stdout and thus terminating the
process which called that function.

That bug was visible in bpftool. `bpftool feature` subcommand was always
exiting too early (because of closed stdout) and it didn't display all
requested probes. `bpftool -j feature` or `bpftool -p feature` were not
returning a valid json object.

This change renames the libbpf__probe_raw_btf function to
libbpf__load_raw_btf, which now returns a BTF descriptor, as expected in
load_sk_storage_btf.

v2:
- Fix typo in the commit message.

v3:
- Simplify BTF descriptor handling in bpf_object__probe_btf_* functions.
- Rename libbpf__probe_raw_btf function to libbpf__load_raw_btf and
return a BTF descriptor.

v4:
- Fix typo in the commit message.

Fixes: 3d18bd4c45b5 ("libbpf: detect supported kernel BTF features and sanitize BTF")
Signed-off-by: Michal Rostecki <mrostecki@opensuse.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/libbpf.c
tools/lib/bpf/libbpf_internal.h
tools/lib/bpf/libbpf_probes.c