Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752374AbdL0TR3 (ORCPT ); Wed, 27 Dec 2017 14:17:29 -0500 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:47988 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751145AbdL0TR1 (ORCPT ); Wed, 27 Dec 2017 14:17:27 -0500 From: Roman Gushchin To: CC: , , Roman Gushchin , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH v3 bpf-next 1/2] tools/bpftool: use version from the kernel source tree Date: Wed, 27 Dec 2017 19:16:28 +0000 Message-ID: <20171227191629.4920-1-guro@fb.com> X-Mailer: git-send-email 2.14.3 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [2620:10d:c092:180::1:bb81] X-ClientProxiedBy: AM5PR0202CA0015.eurprd02.prod.outlook.com (2603:10a6:203:69::25) To BL2PR15MB1075.namprd15.prod.outlook.com (2603:10b6:201:17::9) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 482f2a54-636e-4325-a145-08d54d5e6661 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(4534020)(4602075)(4627115)(201703031133081)(201702281549075)(5600026)(4604075)(2017052603307)(7153060);SRVR:BL2PR15MB1075; X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB1075;3:i4QBubvZnQyQnm97c6po7SVq57X8n7Z1lVv+EuL2d7XwjqS/O2kDa4P25G8a3xn547SBnM75M9JEaGOUitmJIWQZ6X/MI94gS5D25l9AkNJV6boIoaUSn1r2JPDlX6EW5NYQHTewX0Wm3q2bG5sQX9WQqwDGUapFmPs59oGpI865q7IlxEoyF7Qf7dmmhCTshhZlftX+Ear5Etmxn5Ii8nilvznIqwtyOr70v5XLOUxWWQCxXCsGB17esSHqyp/G;25:jTZukHOay71iHX7TM66QOXUG1UwVWd6POaNFFuy9/kU5pxcnRWPIi+KngJUERDTrROo5yKZGpha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dOrRV/Wh4Rs9C6smRYjmhk;4:EHovXXO8s5uYmDJxh9jb5RzKNwwfW1EIKR3o1QwAXUgUIHqtJEOrc4D8fVlBOLwac4fGfaLB091SYWJF0MCVbYY5R+JhmrOrpJmwg9aWLQMZrRTUzzWt3mja9WWaCIAHw7eqn7lWKhmGgE7xvNWGbUFkQ7bxn76JcauQOMRxfUpCREwWSK0bvvYwmrELQBwrlMkmkHW9sXqIPjMUQa+02hjQJX0EC6iBR35eKFcqIu7L4hLGt+YbdbB4rNv0Y+7GRc+iBjkTAxs9K4YDsVtF3VZWkTvl/VtvlQ6RUlSppS/XPeux1atA0tjE7HQ0iO1l X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(67672495146484); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040470)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231023)(11241501184)(944501075)(3002001)(10201501046)(6041268)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011);SRVR:BL2PR15MB1075;BCL:0;PCL:0;RULEID:(100000803101)(100110400095);SRVR:BL2PR15MB1075; X-Forefront-PRVS: 0534947130 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(366004)(376002)(39860400002)(346002)(39380400002)(189003)(199004)(106356001)(36756003)(1076002)(50466002)(48376002)(6116002)(2906002)(25786009)(6512007)(478600001)(86362001)(97736004)(53936002)(4326008)(6486002)(6506007)(386003)(52396003)(52116002)(51416003)(53416004)(7736002)(305945005)(6916009)(6666003)(69596002)(5660300001)(2351001)(81156014)(2361001)(105586002)(8676002)(16586007)(8936002)(81166006)(54906003)(68736007)(47776003)(50226002)(316002)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:BL2PR15MB1075;H:castle.thefacebook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?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Z+fcBr16fM577XtbDmVMAn8eJ3VI0mV2bSk3l2nrpCJwBu4+jH1DREJIGy04px0c2JuJ6BX6N7aqpiaL0WThhDe9Avjy7aspvzoPSKSNWzTMOnD8oKo14Rc7Ng2xQiMe7ppqhjSdd1b/LZxZBmvuQG3VlYsECbmoM+WVsAPP8ndx9a2BjUGalJGt/ePpOmrBE2lVSVATmN+t SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;BL2PR15MB1075;20:eeX2v93GeEIiv4pMefGofthPB7jpm+IhbXXsG56yxfSOSl8aYryX8waXAQ9dCyKwoDtnNcjo/j5VWTkKx0uTROT6OmIjp89bFhUpbXcSqlZd9i2wNx9eYMurB4O1MubD+yEu8QrzW75jUchE+zylUyok1Npa3XTHeCNON27fN0M= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Dec 2017 19:16:57.1169 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 482f2a54-636e-4325-a145-08d54d5e6661 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 8ae927fe-1255-47a7-a2af-5f3a069daaa2 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL2PR15MB1075 X-OriginatorOrg: fb.com X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2017-12-27_12:,, signatures=0 X-Proofpoint-Spam-Reason: safe X-FB-Internal: Safe Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2692 Lines: 91 Bpftool determines it's own version based on the kernel version, which is picked from the linux/version.h header. It's strange to use the version of the installed kernel headers, and makes much more sense to use the version of the actual source tree, where bpftool sources are. Fix this by building kernelversion target and use the resulting string as bpftool version. Example: before: $ bpftool version bpftool v4.14.6 after: $ bpftool version bpftool v4.15.0-rc3 $bpftool version --json {"version":"4.15.0-rc3"} Signed-off-by: Roman Gushchin Reviewed-by: Jakub Kicinski Cc: Alexei Starovoitov Cc: Daniel Borkmann --- tools/bpf/bpftool/Makefile | 3 +++ tools/bpf/bpftool/main.c | 13 ++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 3f17ad317512..f8f31a8d9269 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -23,6 +23,8 @@ endif LIBBPF = $(BPF_PATH)libbpf.a +BPFTOOL_VERSION=$(shell make --no-print-directory -sC ../../.. kernelversion) + $(LIBBPF): FORCE $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(OUTPUT) $(OUTPUT)libbpf.a FEATURES_DUMP=$(FEATURE_DUMP_EXPORT) @@ -38,6 +40,7 @@ CC = gcc CFLAGS += -O2 CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wshadow CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/tools/include/uapi -I$(srctree)/tools/include -I$(srctree)/tools/lib/bpf -I$(srctree)/kernel/bpf/ +CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"' LIBS = -lelf -lbfd -lopcodes $(LIBBPF) INSTALL ?= install diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index ecd53ccf1239..3a0396d87c42 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -95,21 +94,13 @@ static int do_help(int argc, char **argv) static int do_version(int argc, char **argv) { - unsigned int version[3]; - - version[0] = LINUX_VERSION_CODE >> 16; - version[1] = LINUX_VERSION_CODE >> 8 & 0xf; - version[2] = LINUX_VERSION_CODE & 0xf; - if (json_output) { jsonw_start_object(json_wtr); jsonw_name(json_wtr, "version"); - jsonw_printf(json_wtr, "\"%u.%u.%u\"", - version[0], version[1], version[2]); + jsonw_printf(json_wtr, "\"%s\"", BPFTOOL_VERSION); jsonw_end_object(json_wtr); } else { - printf("%s v%u.%u.%u\n", bin_name, - version[0], version[1], version[2]); + printf("%s v%s\n", bin_name, BPFTOOL_VERSION); } return 0; } -- 2.14.3