From patchwork Mon Jan 31 21:11:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12731213 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C0FACC4332F for ; Mon, 31 Jan 2022 21:11:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236798AbiAaVL5 (ORCPT ); Mon, 31 Jan 2022 16:11:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229692AbiAaVLz (ORCPT ); Mon, 31 Jan 2022 16:11:55 -0500 Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BF05C06173D for ; Mon, 31 Jan 2022 13:11:55 -0800 (PST) Received: by mail-ed1-x52b.google.com with SMTP id u24so29249767eds.11 for ; Mon, 31 Jan 2022 13:11:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zQmEESnjlSoQ6wiVFz0EdUVr4f3octanu8GZ1I2hj7A=; b=ibPN07agU2xjkpXfEt4RUAeRveUqaY7j467Yo5MV/C5b7OMJLNJiUFaVmxpzBXh6ZX n0pzuj+5niGaDqMqwgleSgFpombppYAcnDC/qsYW7MGU0UqHbPGtnzzyP2eJsR2e5lvk bvhgKC40exea1k8OmWXATg1LxKOouG575jpQz89oLtTc9eVQP+Fm/oxK7XktvWb+1Fzw miNR8Qmg7GKzA9cqFq+J4xvcnX/B2lg/RyH9c2D4ijWfR9Juu/t+brDdlqDhXRiBagBh 1l06CosiUV7QBFBfr7NQ9T03JDF5s9d0yLszFdxINzmOSxHFbo3PB+j6A/FAmkPjUgcw Zlkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zQmEESnjlSoQ6wiVFz0EdUVr4f3octanu8GZ1I2hj7A=; b=YvL4eBBPJXUAWFlhVM7C9lUdty46GpGFD0roITf1N1M2xBE9k/WDTWU9bszG8PmlBr vjk+49qVnYu4QX4RG7Na4qbFmeSUn1lyKThyBzxT6lCDlwW9OTe1rno3D6+r2r0CKl57 faeLL8k7YDv4O/iV829wN1hX2RlfaOV5tawoj0Vb9k8FOTydI8OPbDcwSxNqovJjnfsc haQ04ExJSVTiltnpoHizmRSsJkabUoJW1Hkq7rbe/X0N2MF8ZoT5ukfEJh2oS292bnCS nAULly5S/BcC9R31zQPx+zUvkK9Qjte5+Lh2cyquGHkopv5iWo51hvNDFRupXVhwgeKB YoDg== X-Gm-Message-State: AOAM531lSadH62LtISsQX3gXhAV9SRLNNL7Qj9ZY74BfqSedj5e5FNHL 8TfWqP0zYjs1BKR60+z0DMKtYA== X-Google-Smtp-Source: ABdhPJx18y/ZLW9TWk0doHqtxu4inrDSaXfbnH+jfGdtLSyO3S0aPQHgPgQnw9DNH2v3MpGqY7HU6w== X-Received: by 2002:a05:6402:42cd:: with SMTP id i13mr22001683edc.121.1643663513756; Mon, 31 Jan 2022 13:11:53 -0800 (PST) Received: from localhost.localdomain ([149.86.79.138]) by smtp.gmail.com with ESMTPSA id v5sm13763947ejc.40.2022.01.31.13.11.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:11:53 -0800 (PST) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next 1/3] libbpf: Add "libbpversion" make target to print version Date: Mon, 31 Jan 2022 21:11:34 +0000 Message-Id: <20220131211136.71010-2-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220131211136.71010-1-quentin@isovalent.com> References: <20220131211136.71010-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Add a target to libbpf's Makefile to print its version number, in a similar way to what running "make kernelversion" at the root of the repository does. This is to avoid re-implementing the parsing of the libbpf.map file in case some other tools want to extract the version of the libbpf sources they are using. Signed-off-by: Quentin Monnet --- tools/lib/bpf/Makefile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile index f947b61b2107..e3a1ae7efa33 100644 --- a/tools/lib/bpf/Makefile +++ b/tools/lib/bpf/Makefile @@ -108,6 +108,9 @@ MAKEOVERRIDES= all: +libbpfversion: + @echo $(LIBBPF_VERSION) + export srctree OUTPUT CC LD CFLAGS V include $(srctree)/tools/build/Makefile.include From patchwork Mon Jan 31 21:11:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12731214 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 707AEC43219 for ; Mon, 31 Jan 2022 21:11:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237297AbiAaVL5 (ORCPT ); Mon, 31 Jan 2022 16:11:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45298 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236230AbiAaVL4 (ORCPT ); Mon, 31 Jan 2022 16:11:56 -0500 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 622BCC06173B for ; Mon, 31 Jan 2022 13:11:56 -0800 (PST) Received: by mail-ed1-x52d.google.com with SMTP id n10so29420776edv.2 for ; Mon, 31 Jan 2022 13:11:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5aN4eDoviOe13XOtMTnGt5vN/B9ENLBxYuv0yoKH2XE=; b=dJOK8MRvUSE4LwLroPk1jED9OxnZ8Anseuj5VQCco3DGQQZw9iEDZ6w1uKCbsc4x7/ naSUXLy2tYrX7a0Jpel5OULIQFaU9+tx34KOvkIo2h793K15i+bAGyX6N+IuiM9HuiCo wXZubzIVlffuSX/HsOyB2nOtSODxfR/4iS+Uq6lIvkqBG0LZetPG/DQo+Dl6to0elSXB 5YtFd8DuvAX3XJZXfwjiJiKVFj8j+vCrhDz0WJBw085939lsWqLV4ZNQtgeIz6XrWBLL cwaR/XrRK+CnE3svrtb6SwjDcLm1CTPrLhPxwvrnRDf3VaO/ipsVQnh4YXYlPB51o57F cj5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5aN4eDoviOe13XOtMTnGt5vN/B9ENLBxYuv0yoKH2XE=; b=k3n6yYRRnEL5r8TPMC48gEUTEDFQMQ67Y7PEsSQvn7Emt53XxSOoSaxrK7KaS+qJK1 LQJGD4YIZCRNCN155y0ahYT7I/w2Ak3QiJ9t9zi3M9JYdTdkK7DyAreBNawuci/QX7h3 raQpv4/lEuGMdHy07cCD8KUKw6KXN9iSoeHbfXfktBIOEHTrByXvJ0OqkoDOHfKC3/B+ 5MfVLLkF0AMzGlDedj52PtM29/AavWSCjGq2Ol1Jc1c597lPfUiC+g3JRDFfYeQxdLv2 Ie3BznfbEiLBf0txu8Zb/jFsrYD2jlGSpS8895IhRP2zeGdNPjivIo0vdqy00rQ95W8q PQpA== X-Gm-Message-State: AOAM5317A6Cg2ejZIoM/phSS5pI56c2CGcvnzLKx8cmSV47HTZbVMGx/ Mhk/SkCgIpRUDq1ZbrRkQraEAA== X-Google-Smtp-Source: ABdhPJyc6AAagL3gXDaykhgbhIOuJKxdosm0X4VNtxS/FaoHnF8MUva2kuMD5zkc+Qlp3WjgrkS6Cg== X-Received: by 2002:a05:6402:2806:: with SMTP id h6mr22091955ede.223.1643663514997; Mon, 31 Jan 2022 13:11:54 -0800 (PST) Received: from localhost.localdomain ([149.86.79.138]) by smtp.gmail.com with ESMTPSA id v5sm13763947ejc.40.2022.01.31.13.11.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:11:54 -0800 (PST) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next 2/3] bpftool: Add libbpf's version number to "bpftool version" output Date: Mon, 31 Jan 2022 21:11:35 +0000 Message-Id: <20220131211136.71010-3-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220131211136.71010-1-quentin@isovalent.com> References: <20220131211136.71010-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net To help users check what version of libbpf has been used to compile bpftool, embed the version number and print it along with bpftool's own version number. Signed-off-by: Quentin Monnet --- tools/bpf/bpftool/Documentation/common_options.rst | 3 ++- tools/bpf/bpftool/Makefile | 2 ++ tools/bpf/bpftool/main.c | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/tools/bpf/bpftool/Documentation/common_options.rst b/tools/bpf/bpftool/Documentation/common_options.rst index 908487b9c2ad..24166733d3ae 100644 --- a/tools/bpf/bpftool/Documentation/common_options.rst +++ b/tools/bpf/bpftool/Documentation/common_options.rst @@ -4,7 +4,8 @@ Print short help message (similar to **bpftool help**). -V, --version - Print version number (similar to **bpftool version**), and optional + Print bpftool's version number (similar to **bpftool version**), the + version of libbpf that was used to compile the binary, and optional features that were included when bpftool was compiled. Optional features include linking against libbfd to provide the disassembler for JIT-ted programs (**bpftool prog dump jited**) and usage of BPF diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 83369f55df61..bd5a8cafac49 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -42,6 +42,7 @@ LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hash ifeq ($(BPFTOOL_VERSION),) BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) endif +LIBBPF_VERSION := $(shell make -r --no-print-directory -sC $(BPF_DIR) libbpfversion) $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR) $(LIBBPF_BOOTSTRAP_HDRS_DIR): $(QUIET_MKDIR)mkdir -p $@ @@ -84,6 +85,7 @@ CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"' +CFLAGS += -DLIBBPF_VERSION='"$(LIBBPF_VERSION)"' ifneq ($(EXTRA_CFLAGS),) CFLAGS += $(EXTRA_CFLAGS) endif diff --git a/tools/bpf/bpftool/main.c b/tools/bpf/bpftool/main.c index 9d01fa9de033..4bda73057980 100644 --- a/tools/bpf/bpftool/main.c +++ b/tools/bpf/bpftool/main.c @@ -89,6 +89,8 @@ static int do_version(int argc, char **argv) jsonw_name(json_wtr, "version"); jsonw_printf(json_wtr, "\"%s\"", BPFTOOL_VERSION); + jsonw_name(json_wtr, "libbpf_version"); + jsonw_printf(json_wtr, "\"%s\"", LIBBPF_VERSION); jsonw_name(json_wtr, "features"); jsonw_start_object(json_wtr); /* features */ @@ -102,6 +104,7 @@ static int do_version(int argc, char **argv) unsigned int nb_features = 0; printf("%s v%s\n", bin_name, BPFTOOL_VERSION); + printf("using libbpf v%s\n", LIBBPF_VERSION); printf("features:"); if (has_libbfd) { printf(" libbfd"); From patchwork Mon Jan 31 21:11:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12731215 X-Patchwork-Delegate: bpf@iogearbox.net Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 64FA0C433F5 for ; Mon, 31 Jan 2022 21:12:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344304AbiAaVMA (ORCPT ); Mon, 31 Jan 2022 16:12:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232184AbiAaVL5 (ORCPT ); Mon, 31 Jan 2022 16:11:57 -0500 Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 704E7C061714 for ; Mon, 31 Jan 2022 13:11:57 -0800 (PST) Received: by mail-ed1-x535.google.com with SMTP id b13so29662545edn.0 for ; Mon, 31 Jan 2022 13:11:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=isovalent-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=uzPneTo0JhD90wvMMv3HK1Id2oCk0Ayd+5WYzgnvdM8=; b=ZIWsKNjyMbRXti9nm2SdFOJkQs7y2R5vGzStqAdBGURn+OfggXWLuC+vcYJAIWXot5 1FAW0MGtKYvCk1rArqx3qwHbuu2cFk5b5neY9oztyX4B2lmTxVzuMU16TFbXNolmpRop Yrmj6vQ5AxCwiYDyIp3Z0UZTsHX29ggmq6Ezt6Glm+ef0f7epC1I84aSxn1sh4Wk8mJf 3syFGZmXjLAKu2zfO/6duwHlmGEB+l1P6ilBq6T+R83FakzSSD6k2SCRNzICJzPKLNmj dI5OMS78hoVIXVjXLpc7mByW1etMQlas9y7DzIVustRiqlbzQ2P+IChPhYMhnqvm4E17 AG9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uzPneTo0JhD90wvMMv3HK1Id2oCk0Ayd+5WYzgnvdM8=; b=HG/kVL34h4zhnLgbuBu/b37gMDtVa4JHPjXsLefzBlA/KpFAbEBV3TM2KGg6vK3ijQ yb517diMB+k2+Fq3obP7fMdaEFaH/QljTsNxlMGEVFooJKSvLPguzov60zqqFjhLz1aO ixyvnrJDZw3jIdcvwMQnrbSJmzC7NeYIQmKMWgd4g+u7SxQiUkKoX0OKjU7HFSOuCkd4 arvVRaIntYMzQ/Bm5kGe63SMJRDRowKnpEHWzhyeITWcg+Q7iw/WsSYFPQScyLp3phYY 48Xml86QzN1GzCdiq24lHiXNEe/dOu74F4rGJzCuVezOExCCnZRqy+feE4rHQvs15vsN b0Ew== X-Gm-Message-State: AOAM533Z6EQOs6DBzflctfK19XNo01QUK0ZL16kjFCWIoNiwIUHdlOEE xSwgZ49mW0ausQTjNDHJHVX+IQ== X-Google-Smtp-Source: ABdhPJyTHRwsjxos+vTc+S5LWZOwW4hZJnpzBfMbzeQ2WDVHC/WfavYcDs7HSreT09s2gM9FPUzlXw== X-Received: by 2002:a50:ec0d:: with SMTP id g13mr882918edr.427.1643663516110; Mon, 31 Jan 2022 13:11:56 -0800 (PST) Received: from localhost.localdomain ([149.86.79.138]) by smtp.gmail.com with ESMTPSA id v5sm13763947ejc.40.2022.01.31.13.11.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jan 2022 13:11:55 -0800 (PST) From: Quentin Monnet To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, Quentin Monnet Subject: [PATCH bpf-next 3/3] bpftool: Update versioning scheme Date: Mon, 31 Jan 2022 21:11:36 +0000 Message-Id: <20220131211136.71010-4-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220131211136.71010-1-quentin@isovalent.com> References: <20220131211136.71010-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Since the notion of versions was introduced for bpftool, it has been following the version number of the kernel (using the version number corresponding to the tree in which bpftool's sources are located). The rationale was that bpftool's features are loosely tied to BPF features in the kernel, and that we could defer versioning to the kernel repository itself. But this versioning scheme is confusing today, because a bpftool binary should be able to work with both older and newer kernels, even if some of its recent features won't be available on older systems. Furthermore, if bpftool is ported to other systems in the future, keeping a Linux-based version number is not a good option. It would make more sense to align bpftool's number on libbpf, maybe. When versioning was introduced in bpftool, libbpf was in its initial phase at v0.0.1. Now it moves faster, with regular version bumps. But there are two issues if we want to pick the same numbers. First, that would mean going backward on the numbering, and will be a huge pain for every script trying to determine which bpftool binary is the most recent (not to mention some possible overlap of the numbers in a distant future). Then, bpftool could get new features or bug fixes between two versions libbpf, so maybe we should not completely tie its versions to libbpf, either. Therefore, this commit introduces an independent versioning scheme for bpftool. The new version is v6.0.0, with its major number incremented over the current 5.16.* returned from the kernel's Makefile. The plan is to update this new number from time to time when bpftool gets new features or new bug fixes. These updates could possibly lead to new releases being tagged on the recently created out-of-tree mirror, at https://github.com/libbpf/bpftool. Version number is moved higher in the Makefile, to make it more visible. Suggested-by: Andrii Nakryiko Signed-off-by: Quentin Monnet --- tools/bpf/bpftool/Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index bd5a8cafac49..b7dbdea112d3 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -1,6 +1,8 @@ # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) include ../../scripts/Makefile.include +BPFTOOL_VERSION := 6.0.0 + ifeq ($(srctree),) srctree := $(patsubst %/,%,$(dir $(CURDIR))) srctree := $(patsubst %/,%,$(dir $(srctree))) @@ -39,9 +41,6 @@ LIBBPF_BOOTSTRAP := $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a LIBBPF_INTERNAL_HDRS := $(addprefix $(LIBBPF_HDRS_DIR)/,hashmap.h nlattr.h) LIBBPF_BOOTSTRAP_INTERNAL_HDRS := $(addprefix $(LIBBPF_BOOTSTRAP_HDRS_DIR)/,hashmap.h) -ifeq ($(BPFTOOL_VERSION),) -BPFTOOL_VERSION := $(shell make -rR --no-print-directory -sC ../../.. kernelversion) -endif LIBBPF_VERSION := $(shell make -r --no-print-directory -sC $(BPF_DIR) libbpfversion) $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT) $(LIBBPF_HDRS_DIR) $(LIBBPF_BOOTSTRAP_HDRS_DIR):