Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp652461pxb; Tue, 5 Apr 2022 17:23:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0TB1uBw6g/1KYBfOAp+mq81pqoQ/ac6mUkn+7EVU3tbQc3S8vbe2gg5apNwq2ZaHu8H7S X-Received: by 2002:a17:902:c40e:b0:154:80a7:95c9 with SMTP id k14-20020a170902c40e00b0015480a795c9mr6274479plk.28.1649204624834; Tue, 05 Apr 2022 17:23:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649204624; cv=none; d=google.com; s=arc-20160816; b=QQcxgqtLtG93lMcEP8dGWZN5SOjofB8xGLEDy4KcT/nKd0WV1U78EsgzUqxlRrJALz TR4HTU+huXLKQP1EeH4FAmFV8l0EYuwsnb+qFPwZeZc6xKwnHRCKrRchIKbIc1gMt/Ou N8Q7RKYsK1sQZUvmI89kUsTehy9BtQ6eNoPqyvvAgm+L20HBCRXuo671ypEx97aRXP+n 1rxNjS3+2CqCkxYxZ/IM4c47q1goz9xmHPt+1STZwM+adW68UWdTQ3HVrhynxi0TuXH2 KL2NbxZA0kpAb6Jp2T2HxruiPiy4Z1ZtraV23Zd0zsXwgoMvibwjepDqRoiqGTCTxVVt AHFg== 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=1y4zpKvOtFdxdU+hR8zrQmojC2T5yaYeU3pHB/Ihdio=; b=RVoZx4yu5NHU8H2cvypEQE+1cjPhuPALzFG9hqSPbG9SY7y8YsKBBElbdZF7YJe1KZ sRsavUHv5dv+IO8/Mckksq4bi+fX6+oSeEhcKBgHBMkuXM9mTCpt83M6COXUUE9S2W7I nmEqKY/FrKqNwd2IfWUHhstRbUcGk/PpanyButjnx/MCZKxQrOG4ZIPxnstOOZXluL+j a7cC4VncSkwWwWStAgoPRUnuuBBKwSYLAl3cR1aLIIhhOJGvAkV4I+DpxYrVWp1EtnFB cXKZaDtvRhuEzeHjXjLMxSpYQmgp0u/9vuDI7JgYJvgr3/QlJE3PM0NMhMWxKw/VX6Af FBjw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n0CMHKrP; 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 e9-20020a17090301c900b00156701abd74si5278966plh.215.2022.04.05.17.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 17:23:44 -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=n0CMHKrP; 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 745A42335CF; Tue, 5 Apr 2022 17:10:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352165AbiDEOBy (ORCPT + 99 others); Tue, 5 Apr 2022 10:01:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55266 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347989AbiDEJ3A (ORCPT ); Tue, 5 Apr 2022 05:29:00 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E4E6DFFB1; Tue, 5 Apr 2022 02:16:01 -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 3BA73B81B14; Tue, 5 Apr 2022 09:16:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84A48C385A2; Tue, 5 Apr 2022 09:15:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150158; bh=YyaqKt4emR4QrHkLMVt4S1mW679qGg2lM39pkxvrAYY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n0CMHKrPpyjVeD2FLMXVjvr89shnEb5OMWXfohD+xpCTnlw6au8qSDZIIW/13WsHC XGG2w5ggrApZIh9NQv8gs5QwolJ0CfUsUosx5F0P/XU7OtnpvO92k5nTbF01kYzpMh 2XomJjLnx4+EKQRcEkzm4Xj1w/bM4NfqRWhUY67Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Andrii Nakryiko , Arnaldo Carvalho de Melo Subject: [PATCH 5.16 0976/1017] libbpf: Define BTF_KIND_* constants in btf.h to avoid compilation errors Date: Tue, 5 Apr 2022 09:31:29 +0200 Message-Id: <20220405070423.175749554@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@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: Toke Høiland-Jørgensen commit eaa266d83a3730a15de2ceebcc89e8f6290e8cf6 upstream. The btf.h header included with libbpf contains inline helper functions to check for various BTF kinds. These helpers directly reference the BTF_KIND_* constants defined in the kernel header, and because the header file is included in user applications, this happens in the user application compile units. This presents a problem if a user application is compiled on a system with older kernel headers because the constants are not available. To avoid this, add #defines of the constants directly in btf.h before using them. Since the kernel header moved to an enum for BTF_KIND_*, the #defines can shadow the enum values without any errors, so we only need #ifndef guards for the constants that predates the conversion to enum. We group these so there's only one guard for groups of values that were added together. [0] Closes: https://github.com/libbpf/libbpf/issues/436 Fixes: 223f903e9c83 ("bpf: Rename BTF_KIND_TAG to BTF_KIND_DECL_TAG") Fixes: 5b84bd10363e ("libbpf: Add support for BTF_KIND_TAG") Signed-off-by: Toke Høiland-Jørgensen Signed-off-by: Andrii Nakryiko Acked-by: Arnaldo Carvalho de Melo Link: https://lore.kernel.org/bpf/20220118141327.34231-1-toke@redhat.com Signed-off-by: Greg Kroah-Hartman --- tools/lib/bpf/btf.h | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) --- a/tools/lib/bpf/btf.h +++ b/tools/lib/bpf/btf.h @@ -313,8 +313,28 @@ btf_dump__dump_type_data(struct btf_dump const struct btf_dump_type_data_opts *opts); /* - * A set of helpers for easier BTF types handling + * A set of helpers for easier BTF types handling. + * + * The inline functions below rely on constants from the kernel headers which + * may not be available for applications including this header file. To avoid + * compilation errors, we define all the constants here that were added after + * the initial introduction of the BTF_KIND* constants. */ +#ifndef BTF_KIND_FUNC +#define BTF_KIND_FUNC 12 /* Function */ +#define BTF_KIND_FUNC_PROTO 13 /* Function Proto */ +#endif +#ifndef BTF_KIND_VAR +#define BTF_KIND_VAR 14 /* Variable */ +#define BTF_KIND_DATASEC 15 /* Section */ +#endif +#ifndef BTF_KIND_FLOAT +#define BTF_KIND_FLOAT 16 /* Floating point */ +#endif +/* The kernel header switched to enums, so these two were never #defined */ +#define BTF_KIND_DECL_TAG 17 /* Decl Tag */ +#define BTF_KIND_TYPE_TAG 18 /* Type Tag */ + static inline __u16 btf_kind(const struct btf_type *t) { return BTF_INFO_KIND(t->info);