bpftool: Fix bpftool build by switching to bpf_object__open_file()

As part of libbpf in 5e61f27070 ("libbpf: stop enforcing kern_version,
populate it for users") non-LIBBPF_API __bpf_object__open_xattr() API
was removed from libbpf.h header. This broke bpftool, which relied on
that function. This patch fixes the build by switching to newly added
bpf_object__open_file() which provides the same capabilities, but is
official and future-proof API.

v1->v2:
- fix prog_type shadowing (Stanislav).

Fixes: 5e61f27070 ("libbpf: stop enforcing kern_version, populate it for users")
Reported-by: Stanislav Fomichev <sdf@google.com>
Signed-off-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Reviewed-by: Stanislav Fomichev <sdf@google.com>
Link: https://lore.kernel.org/bpf/20191007225604.2006146-1-andriin@fb.com
This commit is contained in:
Andrii Nakryiko 2019-10-07 15:56:04 -07:00 committed by Alexei Starovoitov
parent dcb5f40054
commit 32e3e58e4c
3 changed files with 15 additions and 13 deletions

View file

@ -27,7 +27,7 @@ bool json_output;
bool show_pinned;
bool block_mount;
bool verifier_logs;
int bpf_flags;
bool relaxed_maps;
struct pinned_obj_table prog_table;
struct pinned_obj_table map_table;
@ -396,7 +396,7 @@ int main(int argc, char **argv)
show_pinned = true;
break;
case 'm':
bpf_flags = MAPS_RELAX_COMPAT;
relaxed_maps = true;
break;
case 'n':
block_mount = true;