mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-31 00:17:44 +00:00
bpftool: Fix the error when lookup in no-btf maps
[ Upstream commitedc21dc909
] When reworking btf__get_from_id() in commita19f93cfaf
the error handling when calling bpf_btf_get_fd_by_id() changed. Before the rework if bpf_btf_get_fd_by_id() failed the error would not be propagated to callers of btf__get_from_id(), after the rework it is. This lead to a change in behavior in print_key_value() that now prints an error when trying to lookup keys in maps with no btf available. Fix this by following the way used in dumping maps to allow to look up keys in no-btf maps, by which it decides whether and where to get the btf info according to the btf value type. Fixes:a19f93cfaf
("libbpf: Add internal helper to load BTF data by FD") Signed-off-by: Yinjun Zhang <yinjun.zhang@corigine.com> Signed-off-by: Simon Horman <simon.horman@corigine.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Reviewed-by: Niklas Söderlund <niklas.soderlund@corigine.com> Acked-by: Jiri Olsa <jolsa@kernel.org> Link: https://lore.kernel.org/bpf/1644249625-22479-1-git-send-email-yinjun.zhang@corigine.com Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
40dd2b2d0d
commit
e8b42ba320
1 changed files with 2 additions and 4 deletions
|
@ -1054,11 +1054,9 @@ static void print_key_value(struct bpf_map_info *info, void *key,
|
|||
json_writer_t *btf_wtr;
|
||||
struct btf *btf;
|
||||
|
||||
btf = btf__load_from_kernel_by_id(info->btf_id);
|
||||
if (libbpf_get_error(btf)) {
|
||||
p_err("failed to get btf");
|
||||
btf = get_map_kv_btf(info);
|
||||
if (libbpf_get_error(btf))
|
||||
return;
|
||||
}
|
||||
|
||||
if (json_output) {
|
||||
print_entry_json(info, key, value, btf);
|
||||
|
|
Loading…
Reference in a new issue