Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp726803pxb; Tue, 5 Apr 2022 20:33:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqLcAnpS9JGka92TakqI6XGLcA2oc5s41MRWnczkHYr/oiAQkoj+nITD70Ta0MwE7AEMeF X-Received: by 2002:a17:902:6a8a:b0:156:8ff6:daf0 with SMTP id n10-20020a1709026a8a00b001568ff6daf0mr6606949plk.117.1649216028699; Tue, 05 Apr 2022 20:33:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649216028; cv=none; d=google.com; s=arc-20160816; b=uvnHbRt/2V4CzWsz5/RsWlFGiefnVpiRpM8JBME5xJRjLRI/O5INwc9aQjHcFkfupF sDT+6eFbyRlcHJjCyqNru4ZiHjbQg2g6XdpiYq8lq1UQPWqKDJBP4Zrvmv4zIqo5XkXf GCxYDOQ8q+aX0UYwtap8VJurEuynIfPcQIHpy/2wY9SAbhlnuVoEEnNZxQl8E9M10xXY Ci+JUgsrhMgmRDvc+xtJjIy0Gj6xHTPaj6dNeliGEvMSKhrmXLhIwlzYiahcAkR02M0f 4WY0uqSnp7XYgQYbxlzpqZI3fLMs54YEX0uedneFHwV34XG2XrN0LJUDnHK+NCXLoLBs ZgCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DNf/Fnc+0blQLjrN6FDCDR7647ew5pDe2PRJFGnNNv8=; b=ajoB0KCeS22KucV2/L3d/PNY1c+dro71zYFbMcJmwNq5UaduD/B3fBIAXk/o8a6HmM WUzZBIJcdgO54KVvNcCJZ/zuAXuilSbcHZ6J9VATVcnyGf+wQgm/jx9btEghGEKsMnPA cpzBl+vawR4r3G1qSIXf+xgdiLLYkQYO7meph0Ehw2cUXGkBqeSbBqXaQTsLQVBQofRR 2RQeYW5JxPd5aFptiAW9x7+qk3tElYAUjjHiV46frKnow0wu7bPrJPfHK0t21biXIDpK 8B598CNvi7AV996idUZDUFeO1CLueiCnQRLdGh06fvJ6Iap6If3LC+8bFk5f2NGFuicd y2Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qhBgsmoW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id k129-20020a633d87000000b0038217505808si201555pga.119.2022.04.05.20.33.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 20:33:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=qhBgsmoW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D06A8360CEC; Tue, 5 Apr 2022 20:04:48 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236895AbiDEJDm (ORCPT + 99 others); Tue, 5 Apr 2022 05:03:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33834 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237390AbiDEIR6 (ORCPT ); Tue, 5 Apr 2022 04:17:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 74BD4B53F5; Tue, 5 Apr 2022 01:06:12 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id EEE39B81A32; Tue, 5 Apr 2022 08:06:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51451C385A0; Tue, 5 Apr 2022 08:06:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649145969; bh=yjGmY8fE2gNy+34hXTdeIbHMJGLxylssHADL0OpCWeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qhBgsmoWPJERMB6X/yeTRW3GyMQpPFMNnZd+qlJzfJbJ6bPcasV3L/+rIUp1EtQM1 r6VGS1IZvjxygSbhnKV6m8eOvld2BQAUXhipWQ4osZ63KO2DjQLiFpVaqTbp0rSLN2 9+h5xc71huE6ciCegk6WLmKuOHOPl/esDNzZyd40= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yinjun Zhang , Simon Horman , Andrii Nakryiko , =?UTF-8?q?Niklas=20S=C3=B6derlund?= , Jiri Olsa , Sasha Levin Subject: [PATCH 5.17 0547/1126] bpftool: Fix the error when lookup in no-btf maps Date: Tue, 5 Apr 2022 09:21:34 +0200 Message-Id: <20220405070423.688699213@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070407.513532867@linuxfoundation.org> References: <20220405070407.513532867@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Yinjun Zhang [ 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 Signed-off-by: Simon Horman Signed-off-by: Andrii Nakryiko Reviewed-by: Niklas Söderlund Acked-by: Jiri Olsa Link: https://lore.kernel.org/bpf/1644249625-22479-1-git-send-email-yinjun.zhang@corigine.com Signed-off-by: Sasha Levin --- tools/bpf/bpftool/map.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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); -- 2.34.1