Patch "bpftool: Fix the error when lookup in no-btf maps" has been added to the 5.17-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bpftool: Fix the error when lookup in no-btf maps

to the 5.17-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bpftool-fix-the-error-when-lookup-in-no-btf-maps.patch
and it can be found in the queue-5.17 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 039ee49f197b6f3e88974784d054d3b490c3b43c
Author: Yinjun Zhang <yinjun.zhang@xxxxxxxxxxxx>
Date:   Tue Feb 8 00:00:25 2022 +0800

    bpftool: Fix the error when lookup in no-btf maps
    
    [ Upstream commit edc21dc909c6c133a2727f063eadd7907af51f94 ]
    
    When reworking btf__get_from_id() in commit a19f93cfafdf 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: a19f93cfafdf ("libbpf: Add internal helper to load BTF data by FD")
    Signed-off-by: Yinjun Zhang <yinjun.zhang@xxxxxxxxxxxx>
    Signed-off-by: Simon Horman <simon.horman@xxxxxxxxxxxx>
    Signed-off-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
    Reviewed-by: Niklas Söderlund <niklas.soderlund@xxxxxxxxxxxx>
    Acked-by: Jiri Olsa <jolsa@xxxxxxxxxx>
    Link: https://lore.kernel.org/bpf/1644249625-22479-1-git-send-email-yinjun.zhang@xxxxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/tools/bpf/bpftool/map.c b/tools/bpf/bpftool/map.c
index c66a3c979b7a..7a341a472ea4 100644
--- a/tools/bpf/bpftool/map.c
+++ b/tools/bpf/bpftool/map.c
@@ -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);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux