Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp914218pxb; Wed, 6 Apr 2022 04:07:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzH5o7lvaemrjwlxGtporywrUestXcizd6b0JG9FDdAarEL6rSKYFLOnBKdFTeAbcavEWdT X-Received: by 2002:a17:903:120c:b0:154:c135:60d3 with SMTP id l12-20020a170903120c00b00154c13560d3mr8084890plh.48.1649243274693; Wed, 06 Apr 2022 04:07:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649243274; cv=none; d=google.com; s=arc-20160816; b=Q8OVZ3eqrO+GX0M2Q95EGuB3lGGPa8lJqcfLGcam5umLkW26MtiWd+8Pn4+ai9XGCZ USapqNJ1n+/zJMbgQy0vVJBLhX7XMcclr3yn4HzJzj3AZVOlkGasbnw1W3AQVDI07dLD rVOLjiJEW/GFc0P5deB78DH4SZO0aUCTCCusvX/gKGk8/+WPD94Mb4lxlt3KKKQYeQqb lquzHmUmVKFpvPjxjt5+8yoVuRcCUaprUY5E5g2uxgF1REiZoBUcTB0ss/m5CrcCgNT7 W/aQ0FyM4WKujnnQFedpmEQyAPkaMReCkQ2n/nzHv4Iy0bdE+odNH0RWqfujbliYC2aT EOPw== 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=GsxbN8FYT0h8/2CkEdOjoEhuv5YNX7gtDuwRG+2rsfM=; b=XqjA9MHxR6IbgEIywj3gKP5uT/cDazu8wzJ4M0BpyLJKDTKMQFtp4CxXQXdNK6TBpf T9O9W3rtIb0LxaXI71S9KfjQwIKH7I/S9uogLczPllhRGExooJ8kuGgqIxwbz3vYgece lRjiR52CDH99oKIFCc/YvFv2lkTNpZOfJsvD1LOL1i9L080y9lJdNPgA/h23Gy+/Rw0r 1F0nryLGxLoXnApll8gM44LvF8x3HzhUNNXddSqFkii/sBb/Q913cfjjNLhr8fKNaccJ MoLpQWt9pZuZg+VWZUxHWbeFRIFqxswHMR3G0lLHR6kNvnW3fZoB81xK/9cYrgOdnPVR nn6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FTbZR1It; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id q91-20020a17090a1b6400b001c74c0f7c62si4019765pjq.129.2022.04.06.04.07.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Apr 2022 04:07:54 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FTbZR1It; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 B4F6D411F15; Wed, 6 Apr 2022 02:30:16 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378059AbiDEUkP (ORCPT + 99 others); Tue, 5 Apr 2022 16:40:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349099AbiDEJtH (ORCPT ); Tue, 5 Apr 2022 05:49:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6EFAA997F; Tue, 5 Apr 2022 02:40:51 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 825D661368; Tue, 5 Apr 2022 09:40:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8BC0CC385A2; Tue, 5 Apr 2022 09:40:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649151650; bh=kTwXVej5jnwI0ge7d0/k1GflTMj2Y/jFHaUkXu9gn7Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FTbZR1Itp97KYlzM3vj0IA7NUK54TJ+AY3e7rbE/BtTPiawvi0QabAinsn9QtwG/1 tisCZTm6QChrw4ibPSMJ/AVh53YjZ1IkvHEmUXyi5EdXfFdItGk4jTQkRmsnqSIgcW JBd3SSZuPn+ZzvLHc6BMaBavdVmNHFd/TW7QkF6o= 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.15 455/913] bpftool: Fix the error when lookup in no-btf maps Date: Tue, 5 Apr 2022 09:25:17 +0200 Message-Id: <20220405070353.487822593@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070339.801210740@linuxfoundation.org> References: <20220405070339.801210740@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 407071d54ab1..72ef9ddae260 100644 --- a/tools/bpf/bpftool/map.c +++ b/tools/bpf/bpftool/map.c @@ -1042,11 +1042,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