From patchwork Thu Sep 30 11:32:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12528043 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4DC8C433F5 for ; Thu, 30 Sep 2021 11:34:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD38F60F70 for ; Thu, 30 Sep 2021 11:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350514AbhI3Lfr (ORCPT ); Thu, 30 Sep 2021 07:35:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350453AbhI3Lfp (ORCPT ); Thu, 30 Sep 2021 07:35:45 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B49CC06176C for ; Thu, 30 Sep 2021 04:34:02 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id t8so9529884wrq.4 for ; Thu, 30 Sep 2021 04:34:02 -0700 (PDT) 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=C6sdHrUdi9BDM1rYxYocEEgrTC9SSamTyBYNfJp2XuY=; b=HQQJsRvkgb6Nho7VlDDEr0s/2xa9K4xns8qQGU8nQ0Z3fndm/vijX+UfgYkzYxPO7Y AGJOkxnxIgeA+0hr7wGgWLE3ZGsQSHaBDDc3bGbaB23AFZpVWnA2Ob1Y/P+0kpm079e8 uZq2CEafCecf1t3bJpvJ/yn9VcparKPneN6Bd8LncVRMcMABowLwn4AHx59buN1ea4KE 9Ugv6oCMHA+Yx89j+D5wIw+FhIlV/fPpdWwXtFy+6aOEwyC3oFjHdZf8HJfqzuWfzwfY cPpoL8d7xHiiYsy/77CWt7fY7rT6JMsWaXYyYm3FwxgTZD9HCdcnWwZO0HlPgFEoTwlH I3gA== 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=C6sdHrUdi9BDM1rYxYocEEgrTC9SSamTyBYNfJp2XuY=; b=vDE3E0dVPZ/fn4iwDq08Q4SERr1TlmOCMzN5mxOlrxRlfY5HKLsCCWAZKNjb+dFFvg bmYxMeqqjjVnChUEAKRnMjCE5ciuxN1ihddcXW8rvaaBHOV2cIRsxqrgc6beaNYbaodl gjbrqVdLhaOsIXWGEmGhcZLk2b2OPVIR0qebZxzsD5A6nsGbZ0t17fXMsTRYZF89AJZh awd0SfQRr6LLOcZlUAuWPQNRSfWqmwK+nBl19n5qi0anGLtnXG4IIUdFLd0augYoaUY8 IAI+XAbH+3RTfQTuCaHiAbY3kTOgJPkOp7HaU7EGbpKQSUhEyvc5qkHYP6Mphmo7Aq7f 59TA== X-Gm-Message-State: AOAM532sBFfAZJBUbh8k0zI6NV+ZOyKYA93l7WuQmSVwzG4JN0zmahdd a0rQelajxJHiZ7TJ1pTMvc1VFg== X-Google-Smtp-Source: ABdhPJzlRCuX9U4Yk5LIsQEyE1nFTW9uM2c1M9gGK1wgIP5H1uHE7MoWWH1Wfn6wmR87yBt6JqYnXg== X-Received: by 2002:adf:a745:: with SMTP id e5mr5476842wrd.406.1633001641176; Thu, 30 Sep 2021 04:34:01 -0700 (PDT) Received: from localhost.localdomain ([149.86.91.95]) by smtp.gmail.com with ESMTPSA id v10sm2904660wrm.71.2021.09.30.04.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 04:34:00 -0700 (PDT) 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/9] tools: bpftool: remove unused includes to Date: Thu, 30 Sep 2021 12:32:58 +0100 Message-Id: <20210930113306.14950-2-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930113306.14950-1-quentin@isovalent.com> References: <20210930113306.14950-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 It seems that the header file was never necessary to compile bpftool, and it is not part of the headers exported from libbpf. Let's remove the includes from prog.c and gen.c. Fixes: d510296d331a ("bpftool: Use syscall/loader program in "prog load" and "gen skeleton" command.") Signed-off-by: Quentin Monnet --- tools/bpf/bpftool/gen.c | 1 - tools/bpf/bpftool/prog.c | 1 - 2 files changed, 2 deletions(-) diff --git a/tools/bpf/bpftool/gen.c b/tools/bpf/bpftool/gen.c index cc835859465b..b2ffc18eafc1 100644 --- a/tools/bpf/bpftool/gen.c +++ b/tools/bpf/bpftool/gen.c @@ -18,7 +18,6 @@ #include #include #include -#include #include "json_writer.h" #include "main.h" diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index 9c3e343b7d87..7323dd490873 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -25,7 +25,6 @@ #include #include #include -#include #include #include "cfg.h" From patchwork Thu Sep 30 11:32:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12528047 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EAAD9C4332F for ; Thu, 30 Sep 2021 11:34:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D640E619A6 for ; Thu, 30 Sep 2021 11:34:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350513AbhI3Lfr (ORCPT ); Thu, 30 Sep 2021 07:35:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350499AbhI3Lfq (ORCPT ); Thu, 30 Sep 2021 07:35:46 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FEB1C06176A for ; Thu, 30 Sep 2021 04:34:03 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id d6so9463109wrc.11 for ; Thu, 30 Sep 2021 04:34:03 -0700 (PDT) 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=xF0wnid+jjLXYUJTQzy67G/Ce+wFFV52s66ZLdkw4oM=; b=LQN8qagpzhCuMYG2ceyPeiA8RuYWtBYOvzcHv0vAqDNSU52mYJ+zGSDYq2ED2d6c1B 4TtBWvMazfrsgs9gA5W8y6RhY/n5Etq1p7umGViFk2cDjQW3Ras9EkklAPeFpHyjZ7z0 ESRqB3TAmAwkvmFF8v7y+oJlnts8bndEnfW3Gco+SC2cNJUlCNOyK7gG9yNM8Vbr9JyK GvwzZhgZfxZMZGQwkgahil1lFdEI/qw90mRzIjD1+OEpBSn45AtaIuY6ZzJaFs2xGc0i AV0JjXjwlAuhJWHGiADmelH/ciqLdux05iD4Cebzc5WXtJJ1pg4B5mD4kqtJOVtfPT5Z PSqw== 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=xF0wnid+jjLXYUJTQzy67G/Ce+wFFV52s66ZLdkw4oM=; b=Ir4/CEukLyrfCnxbNsD7rPGkDDLrrGOi62VQgGaaAB1ZHlcjvxnaQxWwYKSS/THvwF ZQ4wu4f6D2UovX0GoXuHhDjUBwGiRxbgsaKRSUpVhVtoUOGMwwLIkOogiudztG+n/SXN mINAfBKLaTT7unwf/tHKudiQrqEBb5Kxngz8ZC6w/mDRr6feABN0ulFN6OF8Qgs/2qhk TcWq7kRZY6blPJELoss/G8O8qTJPh/4M2iuvImm2meLbP9c9V3ftcg6Ai40aSzKwpFvR rU2cQtzeI3RH2AZqT4lBujpv0eK0ExrSZLDCXnP3BoMO2xKWsLyJlq2Os3NZMhGg/Y+i y2aw== X-Gm-Message-State: AOAM530V+KXJ5muEfNGUIOXv7I7wZ9fjPxt8+LtfIPKgOE3fpLWbO9zi /0xjAR+744zsqer3QVhc8mL8vGEsViLX9Tjm X-Google-Smtp-Source: ABdhPJzeA2JnxiiwDKz5UcmCmmuCJKK57WOEuFUDG/rU294sJcQGZSRK1gaLuyEGUp6sJYyTr3aKug== X-Received: by 2002:a5d:5683:: with SMTP id f3mr5428675wrv.349.1633001642146; Thu, 30 Sep 2021 04:34:02 -0700 (PDT) Received: from localhost.localdomain ([149.86.91.95]) by smtp.gmail.com with ESMTPSA id v10sm2904660wrm.71.2021.09.30.04.34.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 04:34:01 -0700 (PDT) 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/9] tools: bpftool: install libbpf headers instead of including the dir Date: Thu, 30 Sep 2021 12:32:59 +0100 Message-Id: <20210930113306.14950-3-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930113306.14950-1-quentin@isovalent.com> References: <20210930113306.14950-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Bpftool relies on libbpf, therefore it relies on a number of headers from the library and must be linked against the library. The Makefile for bpftool exposes these objects by adding tools/lib as an include directory ("-I$(srctree)/tools/lib"). This is a working solution, but this is not the cleanest one. The risk is to involuntarily include objects that are not intended to be exposed by the libbpf. The headers needed to compile bpftool should in fact be "installed" from libbpf, with its "install_headers" Makefile target. In addition, there is one header which is internal to the library and not supposed to be used by external applications, but that bpftool uses anyway. Adjust the Makefile in order to install the header files properly before compiling bpftool. Also copy the additional internal header file (nlattr.h), but call it out explicitly. Build (and install headers) in a subdirectory under bpftool/ instead of tools/lib/bpf/. When descending from a parent Makefile, this is configurable by setting the OUTPUT, LIBBPF_OUTPUT and LIBBPF_DESTDIR variables. Also adjust the Makefile for BPF selftests, so as to reuse the (host) libbpf compiled earlier and to avoid compiling a separate version of the library just for bpftool. Signed-off-by: Quentin Monnet --- tools/bpf/bpftool/Makefile | 27 ++++++++++++++++----------- tools/testing/selftests/bpf/Makefile | 2 ++ 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/tools/bpf/bpftool/Makefile b/tools/bpf/bpftool/Makefile index 1fcf5b01a193..78e42963535a 100644 --- a/tools/bpf/bpftool/Makefile +++ b/tools/bpf/bpftool/Makefile @@ -17,16 +17,16 @@ endif BPF_DIR = $(srctree)/tools/lib/bpf/ ifneq ($(OUTPUT),) - LIBBPF_OUTPUT = $(OUTPUT)/libbpf/ - LIBBPF_PATH = $(LIBBPF_OUTPUT) - BOOTSTRAP_OUTPUT = $(OUTPUT)/bootstrap/ + _OUTPUT := $(OUTPUT) else - LIBBPF_OUTPUT = - LIBBPF_PATH = $(BPF_DIR) - BOOTSTRAP_OUTPUT = $(CURDIR)/bootstrap/ + _OUTPUT := $(CURDIR) endif +BOOTSTRAP_OUTPUT := $(_OUTPUT)/bootstrap/ +LIBBPF_OUTPUT := $(_OUTPUT)/libbpf/ +LIBBPF_DESTDIR := $(LIBBPF_OUTPUT) +LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)/include -LIBBPF = $(LIBBPF_PATH)libbpf.a +LIBBPF = $(LIBBPF_OUTPUT)libbpf.a LIBBPF_BOOTSTRAP_OUTPUT = $(BOOTSTRAP_OUTPUT)libbpf/ LIBBPF_BOOTSTRAP = $(LIBBPF_BOOTSTRAP_OUTPUT)libbpf.a @@ -37,8 +37,14 @@ endif $(LIBBPF_OUTPUT) $(BOOTSTRAP_OUTPUT) $(LIBBPF_BOOTSTRAP_OUTPUT): $(QUIET_MKDIR)mkdir -p $@ +# We need to copy nlattr.h which is not otherwise exported by libbpf, but still +# required by bpftool. $(LIBBPF): FORCE | $(LIBBPF_OUTPUT) - $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) $(LIBBPF_OUTPUT)libbpf.a + $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_OUTPUT) \ + DESTDIR=$(LIBBPF_DESTDIR) prefix= \ + $(LIBBPF_OUTPUT)libbpf.a install_headers + $(call QUIET_INSTALL, bpf/nlattr.h) + $(Q)install -m 644 -t $(LIBBPF_INCLUDE)/bpf/ $(BPF_DIR)nlattr.h $(LIBBPF_BOOTSTRAP): FORCE | $(LIBBPF_BOOTSTRAP_OUTPUT) $(Q)$(MAKE) -C $(BPF_DIR) OUTPUT=$(LIBBPF_BOOTSTRAP_OUTPUT) \ @@ -60,10 +66,10 @@ CFLAGS += -W -Wall -Wextra -Wno-unused-parameter -Wno-missing-field-initializers CFLAGS += $(filter-out -Wswitch-enum -Wnested-externs,$(EXTRA_WARNINGS)) CFLAGS += -DPACKAGE='"bpftool"' -D__EXPORTED_HEADERS__ \ -I$(if $(OUTPUT),$(OUTPUT),.) \ + -I$(LIBBPF_INCLUDE) \ -I$(srctree)/kernel/bpf/ \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ - -I$(srctree)/tools/lib \ -I$(srctree)/tools/perf CFLAGS += -DBPFTOOL_VERSION='"$(BPFTOOL_VERSION)"' ifneq ($(EXTRA_CFLAGS),) @@ -167,8 +173,7 @@ $(OUTPUT)%.bpf.o: skeleton/%.bpf.c $(OUTPUT)vmlinux.h $(LIBBPF) $(QUIET_CLANG)$(CLANG) \ -I$(if $(OUTPUT),$(OUTPUT),.) \ -I$(srctree)/tools/include/uapi/ \ - -I$(LIBBPF_PATH) \ - -I$(srctree)/tools/lib \ + -I$(LIBBPF_INCLUDE) \ -g -O2 -Wall -target bpf -c $< -o $@ && $(LLVM_STRIP) -g $@ $(OUTPUT)%.skel.h: $(OUTPUT)%.bpf.o $(BPFTOOL_BOOTSTRAP) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 326ea75ce99e..5432bfc99740 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -209,6 +209,8 @@ $(DEFAULT_BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ CC=$(HOSTCC) LD=$(HOSTLD) \ EXTRA_CFLAGS='-g -O0' \ OUTPUT=$(HOST_BUILD_DIR)/bpftool/ \ + LIBBPF_OUTPUT=$(HOST_BUILD_DIR)/libbpf/ \ + LIBBPF_DESTDIR=$(HOST_SCRATCH_DIR)/ \ prefix= DESTDIR=$(HOST_SCRATCH_DIR)/ install all: docs From patchwork Thu Sep 30 11:33:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12528049 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80142C433F5 for ; Thu, 30 Sep 2021 11:34:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6A46F619A6 for ; Thu, 30 Sep 2021 11:34:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350527AbhI3Lft (ORCPT ); Thu, 30 Sep 2021 07:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350509AbhI3Lfr (ORCPT ); Thu, 30 Sep 2021 07:35:47 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97B4CC06176D for ; Thu, 30 Sep 2021 04:34:04 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id s21so9485255wra.7 for ; Thu, 30 Sep 2021 04:34:04 -0700 (PDT) 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=ZVRI1vsPtM4IE1gmBFSEqqg+MaNx9NW4FiCNSSzSPSc=; b=aJwwi3uvqzzLrCL4j7JafXjdO1sguBBVDhOHbm6VdmRRb0TRj/CGi31emCt44nCd8S jV3SiM6wbM38CJSwDUz3TYCvUGrT+6je56pCLejmyEbmqTdVlSFhq1iD/zZjOV/YND6Z mJsyKtSSoJjnZ6CZGwSwtffqhwMEKGe/enRzukrDmQRl1dCegk9VV26oX6PpeuN2rQnP FUD34wnr8apE1YoX6gUrwkiy8uLk9MYGozp4ZAHYqcz9sUP2dfyXuPLkmofIGmw+Mss4 tWtsJvWb36EaARoii7B0E4jieb9KWIemS4xbCBTReYWwoZ8cu3fMMC6qteVjbCq7v6ki NMDA== 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=ZVRI1vsPtM4IE1gmBFSEqqg+MaNx9NW4FiCNSSzSPSc=; b=Qb3nQTssCOsuKITRrNAGEmFNm8h4tX5nKz0990SlmAdxm7cP+OjHb4ZNLR/jc+UowM Cyt9PNDID5izvW0Ol9p2k2E8q5qxMmy+G5m6hpRqcxMZpHLEwDTsdRRx2rO7tLPcgYyh 3fUk/GlnGTCmlHSOSk6E3PBa5isjA78D5e6GhFO7qQhA8KEkssS1HX4ntsWod4nDN3E2 VQzrg+i3WJ3mxwLA0ge6AX3o66vopLyIMvfNPwI8n6fcQfd00CqfXmELBTiZl9rt/Wft j7WZNEkuw/vfuIGLfVoBmKkFhM8IuaAIQNqkx+tLZtqhuoBKi+yV8ucRsbDJhrXIfiPW lUKA== X-Gm-Message-State: AOAM531w6HUSIwf2wtpH6Ea91g2Rn3EFL8dLTZMEzjCwuMkAEiWHO+Vw UVR+fgPKyHqN/fcuqLKkmv5wdg== X-Google-Smtp-Source: ABdhPJxFslTAdxkH3ZFp0Gyn4Gn1atrAD+r3vTHGp1OI6ROrnFco+7HLkSd1n+7qfVCLp0JKrd0JSg== X-Received: by 2002:a5d:5104:: with SMTP id s4mr5689517wrt.16.1633001643198; Thu, 30 Sep 2021 04:34:03 -0700 (PDT) Received: from localhost.localdomain ([149.86.91.95]) by smtp.gmail.com with ESMTPSA id v10sm2904660wrm.71.2021.09.30.04.34.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 04:34:02 -0700 (PDT) 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/9] tools: resolve_btfids: install libbpf headers when building Date: Thu, 30 Sep 2021 12:33:00 +0100 Message-Id: <20210930113306.14950-4-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930113306.14950-1-quentin@isovalent.com> References: <20210930113306.14950-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's make sure that resolve_btfids installs the headers properly when building. When descending from a parent Makefile, the specific output directories for building the library and exporting the headers are configurable with LIBBPF_OUT and LIBBPF_DESTDIR, respectively. This is in addition to OUTPUT, on top of which those variables are constructed by default. Also adjust the Makefile for the BPF selftests in order to point to the (target) libbpf shared with other tools, instead of building a version specific to resolve_btfids. Signed-off-by: Quentin Monnet --- tools/bpf/resolve_btfids/Makefile | 17 ++++++++++++----- tools/bpf/resolve_btfids/main.c | 4 ++-- tools/testing/selftests/bpf/Makefile | 7 +++++-- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/tools/bpf/resolve_btfids/Makefile b/tools/bpf/resolve_btfids/Makefile index 08b75e314ae7..89a46d4d0768 100644 --- a/tools/bpf/resolve_btfids/Makefile +++ b/tools/bpf/resolve_btfids/Makefile @@ -29,25 +29,31 @@ BPFOBJ := $(OUTPUT)/libbpf/libbpf.a LIBBPF_OUT := $(abspath $(dir $(BPFOBJ)))/ SUBCMDOBJ := $(OUTPUT)/libsubcmd/libsubcmd.a +LIBBPF_DESTDIR := $(LIBBPF_OUT) +LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)include + BINARY := $(OUTPUT)/resolve_btfids BINARY_IN := $(BINARY)-in.o all: $(BINARY) -$(OUTPUT) $(OUTPUT)/libbpf $(OUTPUT)/libsubcmd: +$(OUTPUT) $(OUTPUT)/libsubcmd $(LIBBPF_OUT) $(LIBBPF_INCLUDE): $(call msg,MKDIR,,$@) $(Q)mkdir -p $(@) $(SUBCMDOBJ): fixdep FORCE | $(OUTPUT)/libsubcmd $(Q)$(MAKE) -C $(SUBCMD_SRC) OUTPUT=$(abspath $(dir $@))/ $(abspath $@) -$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT)/libbpf - $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) $(abspath $@) +$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) \ + | $(LIBBPF_OUT) $(LIBBPF_INCLUDE) + $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(LIBBPF_OUT) \ + DESTDIR=$(LIBBPF_DESTDIR) prefix= \ + $(abspath $@) install_headers CFLAGS := -g \ -I$(srctree)/tools/include \ -I$(srctree)/tools/include/uapi \ - -I$(LIBBPF_SRC) \ + -I$(LIBBPF_INCLUDE) \ -I$(SUBCMD_SRC) LIBS = -lelf -lz @@ -65,7 +71,8 @@ $(BINARY): $(BPFOBJ) $(SUBCMDOBJ) $(BINARY_IN) clean_objects := $(wildcard $(OUTPUT)/*.o \ $(OUTPUT)/.*.o.cmd \ $(OUTPUT)/.*.o.d \ - $(OUTPUT)/libbpf \ + $(LIBBPF_OUT) \ + $(LIBBPF_DESTDIR) \ $(OUTPUT)/libsubcmd \ $(OUTPUT)/resolve_btfids) diff --git a/tools/bpf/resolve_btfids/main.c b/tools/bpf/resolve_btfids/main.c index de6365b53c9c..91af785e6de5 100644 --- a/tools/bpf/resolve_btfids/main.c +++ b/tools/bpf/resolve_btfids/main.c @@ -60,8 +60,8 @@ #include #include #include -#include -#include +#include +#include #include #define BTF_IDS_SECTION ".BTF_ids" diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 5432bfc99740..0167514ccaa2 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -122,9 +122,11 @@ BPFOBJ := $(BUILD_DIR)/libbpf/libbpf.a ifneq ($(CROSS_COMPILE),) HOST_BUILD_DIR := $(BUILD_DIR)/host HOST_SCRATCH_DIR := $(OUTPUT)/host-tools +HOST_INCLUDE_DIR := $(HOST_SCRATCH_DIR)/include else HOST_BUILD_DIR := $(BUILD_DIR) HOST_SCRATCH_DIR := $(SCRATCH_DIR) +HOST_INCLUDE_DIR := $(INCLUDE_DIR) endif HOST_BPFOBJ := $(HOST_BUILD_DIR)/libbpf/libbpf.a RESOLVE_BTFIDS := $(HOST_BUILD_DIR)/resolve_btfids/resolve_btfids @@ -152,7 +154,7 @@ $(notdir $(TEST_GEN_PROGS) \ # sort removes libbpf duplicates when not cross-building MAKE_DIRS := $(sort $(BUILD_DIR)/libbpf $(HOST_BUILD_DIR)/libbpf \ $(HOST_BUILD_DIR)/bpftool $(HOST_BUILD_DIR)/resolve_btfids \ - $(INCLUDE_DIR)) + $(INCLUDE_DIR) $(HOST_INCLUDE_DIR)) $(MAKE_DIRS): $(call msg,MKDIR,,$@) $(Q)mkdir -p $@ @@ -235,7 +237,7 @@ $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ ifneq ($(BPFOBJ),$(HOST_BPFOBJ)) $(HOST_BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ ../../../include/uapi/linux/bpf.h \ - | $(INCLUDE_DIR) $(HOST_BUILD_DIR)/libbpf + | $(HOST_INCLUDE_DIR) $(HOST_BUILD_DIR)/libbpf $(Q)$(MAKE) $(submake_extras) -C $(BPFDIR) \ EXTRA_CFLAGS='-g -O0' \ OUTPUT=$(HOST_BUILD_DIR)/libbpf/ CC=$(HOSTCC) LD=$(HOSTLD) \ @@ -260,6 +262,7 @@ $(RESOLVE_BTFIDS): $(HOST_BPFOBJ) | $(HOST_BUILD_DIR)/resolve_btfids \ $(TOOLSDIR)/lib/str_error_r.c $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/resolve_btfids \ CC=$(HOSTCC) LD=$(HOSTLD) AR=$(HOSTAR) \ + LIBBPF_INCLUDE=$(HOST_INCLUDE_DIR) \ OUTPUT=$(HOST_BUILD_DIR)/resolve_btfids/ BPFOBJ=$(HOST_BPFOBJ) # Get Clang's default includes on this system, as opposed to those seen by From patchwork Thu Sep 30 11:33:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12528053 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31547C4332F for ; Thu, 30 Sep 2021 11:34:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 17F1B619E1 for ; Thu, 30 Sep 2021 11:34:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350509AbhI3Lft (ORCPT ); Thu, 30 Sep 2021 07:35:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350499AbhI3Lfs (ORCPT ); Thu, 30 Sep 2021 07:35:48 -0400 Received: from mail-wr1-x435.google.com (mail-wr1-x435.google.com [IPv6:2a00:1450:4864:20::435]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 773BDC06176F for ; Thu, 30 Sep 2021 04:34:05 -0700 (PDT) Received: by mail-wr1-x435.google.com with SMTP id h15so7901293wrc.3 for ; Thu, 30 Sep 2021 04:34:05 -0700 (PDT) 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=vDMYaD1JQIEcaKLhoWMfZURyxvr/UbAgBoCgqHBl9W4=; b=pZk0/Pftt1lwwaRxixwcDnCmjcnFP8REDJPTeLzR4jx8e4oRTBIAStCQwN6zUs4FM5 hNJhpLj116YdrSmkAc7LUgdAwwBydvSf611IijTaqljlKg07wc+KQOwaks0My4xvLbjJ ne5N+/3n0IXN5TaxBmL5BRjmcJfVWzyK3xOa+7B8dfzv7e7HQMeEpGHnSnjYAqQAzcpY BPikHVFXfa0uzmRdb7F0Sr/a+NAo39s44LDNFuZp6whh7SIs6jEkwhszPRVMJH/ytuv7 WBLXm9GNQDoExk6traB6VF1RfYcLsnpW7IUdK9CowxVQ8eFy5nNdj30BZbdrt1tXpQ2R qlog== 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=vDMYaD1JQIEcaKLhoWMfZURyxvr/UbAgBoCgqHBl9W4=; b=lidxVer18cmWgGPyKgG00sSRSHADpln23UYvwOhX8jSALsR/NufdgoLYVih7ATJ0Dc zFkqo9FdMPFyl8JRLt9SylcIDnV0UaE6s9DxFZ2QjqbLsdfDTfPcOULt6Bl14ibmABhW +5fTYVpfvI4I6qGg1oBOUCoCKIHuLwAYloDBxL2iE/nbJNC3jBTsYmqmlc33CwYjOW7D VTgoUDyIGwnc8Um9RI53yrjgXkfxwsFEKma7yD+SfENYB5JL07ulVhCAlL9KbXrWVN7y tx+zqAHny1o/WeLVMuI2u2G4F29SL4H8Anha8GcqaO5aJoDT+vhczkqnx8I7sdJdlUMr py3Q== X-Gm-Message-State: AOAM533FXEdvk7jiG6jRbJt5z9dj5e4sfbYWXgkQjTPgWvTlPV/w7qD6 h2XUyactE4KtCrZiC2H5NcPsMw== X-Google-Smtp-Source: ABdhPJynECUvj04F01uCoEB8FiUXwgBjOSB4folmPRsl2QwXJfP0O6MUyC/DlibiSzEHnTyA+L409g== X-Received: by 2002:a5d:4a46:: with SMTP id v6mr5553380wrs.262.1633001644066; Thu, 30 Sep 2021 04:34:04 -0700 (PDT) Received: from localhost.localdomain ([149.86.91.95]) by smtp.gmail.com with ESMTPSA id v10sm2904660wrm.71.2021.09.30.04.34.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 04:34:03 -0700 (PDT) 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 4/9] tools: runqslower: install libbpf headers when building Date: Thu, 30 Sep 2021 12:33:01 +0100 Message-Id: <20210930113306.14950-5-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930113306.14950-1-quentin@isovalent.com> References: <20210930113306.14950-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's make sure that runqslower installs the headers properly when building. When descending from a parent Makefile, the specific output directories for building the library and exporting the headers are configurable with BPFOBJ_OUTPUT and BPF_DESTDIR, respectively. This is in addition to OUTPUT, on top of which those variables are constructed by default. Also adjust the Makefile for the BPF selftests. We pass a number of variables to the "make" invocation, because we want to point runqslower to the (target) libbpf shared with other tools, instead of building its own version. In addition, runqslower relies on (target) bpftool, and we also want to pass the proper variables to its Makefile so that bpftool itself reuses the same libbpf. Signed-off-by: Quentin Monnet --- tools/bpf/runqslower/Makefile | 12 +++++++----- tools/testing/selftests/bpf/Makefile | 15 +++++++++------ 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/tools/bpf/runqslower/Makefile b/tools/bpf/runqslower/Makefile index 3818ec511fd2..73ae8569878d 100644 --- a/tools/bpf/runqslower/Makefile +++ b/tools/bpf/runqslower/Makefile @@ -9,9 +9,9 @@ BPFTOOL ?= $(DEFAULT_BPFTOOL) LIBBPF_SRC := $(abspath ../../lib/bpf) BPFOBJ_OUTPUT := $(OUTPUT)libbpf/ BPFOBJ := $(BPFOBJ_OUTPUT)libbpf.a -BPF_INCLUDE := $(BPFOBJ_OUTPUT) -INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../lib) \ - -I$(abspath ../../include/uapi) +BPF_DESTDIR := $(BPFOBJ_OUTPUT) +BPF_INCLUDE := $(BPF_DESTDIR)/include +INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../include/uapi) CFLAGS := -g -Wall # Try to detect best kernel BTF source @@ -81,8 +81,10 @@ else endif $(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(BPFOBJ_OUTPUT) - $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(BPFOBJ_OUTPUT) $@ + $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) OUTPUT=$(BPFOBJ_OUTPUT) \ + DESTDIR=$(BPFOBJ_OUTPUT) prefix= $(abspath $@) install_headers $(DEFAULT_BPFTOOL): | $(BPFTOOL_OUTPUT) $(Q)$(MAKE) $(submake_extras) -C ../bpftool OUTPUT=$(BPFTOOL_OUTPUT) \ - CC=$(HOSTCC) LD=$(HOSTLD) + LIBBPF_OUTPUT=$(BPFOBJ_OUTPUT) \ + LIBBPF_DESTDIR=$(BPF_DESTDIR) CC=$(HOSTCC) LD=$(HOSTLD) diff --git a/tools/testing/selftests/bpf/Makefile b/tools/testing/selftests/bpf/Makefile index 0167514ccaa2..6e7be0a0d79a 100644 --- a/tools/testing/selftests/bpf/Makefile +++ b/tools/testing/selftests/bpf/Makefile @@ -130,6 +130,7 @@ HOST_INCLUDE_DIR := $(INCLUDE_DIR) endif HOST_BPFOBJ := $(HOST_BUILD_DIR)/libbpf/libbpf.a RESOLVE_BTFIDS := $(HOST_BUILD_DIR)/resolve_btfids/resolve_btfids +RUNQSLOWER_OUTPUT := $(BUILD_DIR)/runqslower/ VMLINUX_BTF_PATHS ?= $(if $(O),$(O)/vmlinux) \ $(if $(KBUILD_OUTPUT),$(KBUILD_OUTPUT)/vmlinux) \ @@ -154,7 +155,7 @@ $(notdir $(TEST_GEN_PROGS) \ # sort removes libbpf duplicates when not cross-building MAKE_DIRS := $(sort $(BUILD_DIR)/libbpf $(HOST_BUILD_DIR)/libbpf \ $(HOST_BUILD_DIR)/bpftool $(HOST_BUILD_DIR)/resolve_btfids \ - $(INCLUDE_DIR) $(HOST_INCLUDE_DIR)) + $(RUNQSLOWER_OUTPUT) $(INCLUDE_DIR) $(HOST_INCLUDE_DIR)) $(MAKE_DIRS): $(call msg,MKDIR,,$@) $(Q)mkdir -p $@ @@ -183,11 +184,13 @@ $(OUTPUT)/test_stub.o: test_stub.c $(BPFOBJ) DEFAULT_BPFTOOL := $(HOST_SCRATCH_DIR)/sbin/bpftool -$(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL) - $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower \ - OUTPUT=$(SCRATCH_DIR)/ VMLINUX_BTF=$(VMLINUX_BTF) \ - BPFOBJ=$(BPFOBJ) BPF_INCLUDE=$(INCLUDE_DIR) && \ - cp $(SCRATCH_DIR)/runqslower $@ +$(OUTPUT)/runqslower: $(BPFOBJ) | $(DEFAULT_BPFTOOL) $(RUNQSLOWER_OUTPUT) + $(Q)$(MAKE) $(submake_extras) -C $(TOOLSDIR)/bpf/runqslower \ + OUTPUT=$(RUNQSLOWER_OUTPUT) VMLINUX_BTF=$(VMLINUX_BTF) \ + BPFTOOL_OUTPUT=$(BUILD_DIR)/bpftool/ \ + BPFOBJ_OUTPUT=$(BUILD_DIR)/libbpf \ + BPFOBJ=$(BPFOBJ) BPF_INCLUDE=$(INCLUDE_DIR) && \ + cp $(RUNQSLOWER_OUTPUT)runqslower $@ TEST_GEN_PROGS_EXTENDED += $(DEFAULT_BPFTOOL) From patchwork Thu Sep 30 11:33:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12528055 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 896F2C43219 for ; Thu, 30 Sep 2021 11:34:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 73DDA615E2 for ; Thu, 30 Sep 2021 11:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350499AbhI3Lfv (ORCPT ); Thu, 30 Sep 2021 07:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350528AbhI3Lft (ORCPT ); Thu, 30 Sep 2021 07:35:49 -0400 Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6F9AC06176D for ; Thu, 30 Sep 2021 04:34:06 -0700 (PDT) Received: by mail-wr1-x429.google.com with SMTP id u18so9519144wrg.5 for ; Thu, 30 Sep 2021 04:34:06 -0700 (PDT) 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=1ohEWFIw0gYyuvZVDbecSO6WgVKzNHomVIL1cNaawDg=; b=WEsEGhEQqVOOewcHHyRFPeKT3TjHWlIQr+5FqUZWKsIfYMVffw984mqie3NjFS0lf7 xqiP9IRd5AMR7Eopq8rn9FkbxQjb9g9iIZ5sSl6d6S/JzXvlTkn8gx/zdHPmddSAM942 6iGWb+2YvJp81Sf/nK+ufWJrTSepIL67HVQFDs8RoI8xgBpyjC/TavILbFjNcfuEJYkG RjhFApP+GRQfNp3xqv2eImPofM+dm6rLKjiJRuzrrBBIe6gezq9HLymZqNstDSRIAOqY rcgodN41D90zmFpkI5iKO28w6uXH00CeeBv8hyvvHiVR/urXhJ94la9gjBS8W5R66jDs vLqA== 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=1ohEWFIw0gYyuvZVDbecSO6WgVKzNHomVIL1cNaawDg=; b=4v/qyIxMNsdHzjGzwZfVLIQ1BI44Y1toAwsaMZe4EPHnXnnFpX+tHKBoE/T3Nqnzs5 GnzPbEyze0LHTiZ25Ch1i9FGEvJXq4uGSynTiBJhm8Vc7Nq/vVTNRUFTUI/P/OldwRJp 0xMJKi+5KtRIHehAOM70sidyOAkYH0TK+oTyHFhuG6nY6033JHD/pZp6R5OwePS7pV2O MRsLbgIOJZvI0oUCBiK5xmzPXvqQNzKllFnLrDTyrelwvsQfbGXHtZACxDa+Mdr1ffwu eO7y06OQ8vx9fx+hEh88Le0JxP5SaCQbdjhKGMIDu6jnxtz7aCWzpH8yOf4RcY7Aujh4 f2fQ== X-Gm-Message-State: AOAM530zsaViboW/JEMdzOMO/zFUjC9mp2AuMpzlH6XWMqJzutx8A992 KeZTIPcsoMdiSQrvszkwXQW+SA== X-Google-Smtp-Source: ABdhPJy5H8pfNbZf1zrQx5LnMdoExDVflbxGTPvim2lQeZWrmAUzltCSz25M/39ZHLfP7slISCCkWQ== X-Received: by 2002:a5d:648f:: with SMTP id o15mr5618877wri.338.1633001645407; Thu, 30 Sep 2021 04:34:05 -0700 (PDT) Received: from localhost.localdomain ([149.86.91.95]) by smtp.gmail.com with ESMTPSA id v10sm2904660wrm.71.2021.09.30.04.34.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 04:34:04 -0700 (PDT) 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 5/9] bpf: preload: install libbpf headers when building Date: Thu, 30 Sep 2021 12:33:02 +0100 Message-Id: <20210930113306.14950-6-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930113306.14950-1-quentin@isovalent.com> References: <20210930113306.14950-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's make sure that bpf/preload/Makefile installs the headers properly when building. Signed-off-by: Quentin Monnet --- kernel/bpf/preload/Makefile | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/kernel/bpf/preload/Makefile b/kernel/bpf/preload/Makefile index 1951332dd15f..b04d8e61e5ad 100644 --- a/kernel/bpf/preload/Makefile +++ b/kernel/bpf/preload/Makefile @@ -1,21 +1,30 @@ # SPDX-License-Identifier: GPL-2.0 LIBBPF_SRCS = $(srctree)/tools/lib/bpf/ -LIBBPF_A = $(obj)/libbpf.a -LIBBPF_OUT = $(abspath $(obj)) +LIBBPF_A = $(obj)/libbpf/libbpf.a +LIBBPF_OUT = $(abspath $(obj))/libbpf +LIBBPF_DESTDIR = $(LIBBPF_OUT) +LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include # Although not in use by libbpf's Makefile, set $(O) so that the "dummy" test # in tools/scripts/Makefile.include always succeeds when building the kernel # with $(O) pointing to a relative path, as in "make O=build bindeb-pkg". -$(LIBBPF_A): - $(Q)$(MAKE) -C $(LIBBPF_SRCS) O=$(LIBBPF_OUT)/ OUTPUT=$(LIBBPF_OUT)/ $(LIBBPF_OUT)/libbpf.a +$(LIBBPF_A): | $(LIBBPF_OUT) $(LIBBPF_INCLUDE) + $(Q)$(MAKE) -C $(LIBBPF_SRCS) O=$(LIBBPF_OUT)/ OUTPUT=$(LIBBPF_OUT)/ \ + DESTDIR=$(LIBBPF_DESTDIR) prefix= \ + $(LIBBPF_OUT)/libbpf.a install_headers + +$(LIBBPF_OUT) $(LIBBPF_INCLUDE): + $(call msg,MKDIR,$@) + $(Q)mkdir -p $@ userccflags += -I $(srctree)/tools/include/ -I $(srctree)/tools/include/uapi \ - -I $(srctree)/tools/lib/ -Wno-unused-result + -I $(LIBBPF_INCLUDE) -Wno-unused-result userprogs := bpf_preload_umd clean-files := $(userprogs) bpf_helper_defs.h FEATURE-DUMP.libbpf staticobjs/ feature/ +clean-files += $(LIBBPF_OUT) $(LIBBPF_DESTDIR) bpf_preload_umd-objs := iterators/iterators.o bpf_preload_umd-userldlibs := $(LIBBPF_A) -lelf -lz From patchwork Thu Sep 30 11:33:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12528051 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9EFEFC43217 for ; Thu, 30 Sep 2021 11:34:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86A8E619A6 for ; Thu, 30 Sep 2021 11:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350534AbhI3Lfv (ORCPT ); Thu, 30 Sep 2021 07:35:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350533AbhI3Lfu (ORCPT ); Thu, 30 Sep 2021 07:35:50 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA971C061770 for ; Thu, 30 Sep 2021 04:34:07 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id d6so9463363wrc.11 for ; Thu, 30 Sep 2021 04:34:07 -0700 (PDT) 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=6G1NPylBOR/ww+hDOMCQFvHQVyGOy8KdOupILpftMKg=; b=kpV1autVa2E0Ief9wVAQqL5K7HLT9trRbeMj6PgYMLuhPr5DC0lRElikLdZSvHd4mO pFxrGCYkbpUaeIm7WqqAx1Y9ROP+Icbhu3l8RLvr2dqKd2ceTxfPhC+woaLOS8+JmhrW KAcGKAz9AQkqlSg5lMd+DEg5L/o+3EPQ0w8aZxHAAt5aKsoiJYiwvJ5776u6hYGRjxCj vy1BKFF8sSsNkbVqbtD2xekBZrx3F+bvQi7qPgMaYSR+qqWHy0T9RktETl2lXF/YHwx6 NVV7KzC4zVw4959mQFyon+wXYfcOZwkZl3nWjZg9CiBePfT32bds0GcJyCOhv98NUAuA KPyw== 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=6G1NPylBOR/ww+hDOMCQFvHQVyGOy8KdOupILpftMKg=; b=4c8mNb3MImF5JZVHG7sjXIDRzUH81qxnoihH/KVKYmiRxau7GLRS6q96uvD1jd3wDs rdz2sTZ4TgiR/dINWJ2/vUm87zpNP8qC0KwnjUw9R+tXwmlONzY99S9A8wzNFGoKaRdV 6AAjXmbxTWQXY/HJAAQBD8kh/ATB/SkDv8uMrhl1o6LdeQUn7rcEdIl7f+MOvkyCF8Fa FuicbSIBJdl+P+zOQwYDmBgnC9l2OY4KX1q2zR898vbCPGp8HaHBEChX7V3UOlPNP6G4 JG7QaQSwOrIYfVUGGWCtKX8Km0pv9i0sYPIYdFKO4KbT0wwJ/CK/SikeCL+7J9vuN9SO iTEw== X-Gm-Message-State: AOAM5300ZPapv1+eHryyWSD6OGB/GNyAHwhRGNgjvk+nynPWpykoGahm 2UUlwnb8pEIzaBmwEoybPfnvqQ== X-Google-Smtp-Source: ABdhPJy9TILGrseKztGLzOKWyVsdXh4NoWKLUdV+GEtnN3oCHlsZXqIsB1Kfe2HBXWmjzLDQdPCz/A== X-Received: by 2002:adf:f946:: with SMTP id q6mr5508000wrr.437.1633001646344; Thu, 30 Sep 2021 04:34:06 -0700 (PDT) Received: from localhost.localdomain ([149.86.91.95]) by smtp.gmail.com with ESMTPSA id v10sm2904660wrm.71.2021.09.30.04.34.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 04:34:05 -0700 (PDT) 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 6/9] bpf: iterators: install libbpf headers when building Date: Thu, 30 Sep 2021 12:33:03 +0100 Message-Id: <20210930113306.14950-7-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930113306.14950-1-quentin@isovalent.com> References: <20210930113306.14950-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the library's source directory. Instead, they should be exported with "make install_headers". Let's make sure that bpf/preload/iterators/Makefile installs the headers properly when building. Signed-off-by: Quentin Monnet --- kernel/bpf/preload/iterators/Makefile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/kernel/bpf/preload/iterators/Makefile b/kernel/bpf/preload/iterators/Makefile index 28fa8c1440f4..cf549dab3e20 100644 --- a/kernel/bpf/preload/iterators/Makefile +++ b/kernel/bpf/preload/iterators/Makefile @@ -6,9 +6,11 @@ LLVM_STRIP ?= llvm-strip DEFAULT_BPFTOOL := $(OUTPUT)/sbin/bpftool BPFTOOL ?= $(DEFAULT_BPFTOOL) LIBBPF_SRC := $(abspath ../../../../tools/lib/bpf) -BPFOBJ := $(OUTPUT)/libbpf.a -BPF_INCLUDE := $(OUTPUT) -INCLUDES := -I$(OUTPUT) -I$(BPF_INCLUDE) -I$(abspath ../../../../tools/lib) \ +LIBBPF_OUTPUT := $(abspath $(OUTPUT))/libbpf +LIBBPF_DESTDIR := $(LIBBPF_OUTPUT) +LIBBPF_INCLUDE := $(LIBBPF_DESTDIR)/include +BPFOBJ := $(LIBBPF_OUTPUT)/libbpf.a +INCLUDES := -I$(OUTPUT) -I$(LIBBPF_INCLUDE) \ -I$(abspath ../../../../tools/include/uapi) CFLAGS := -g -Wall @@ -44,13 +46,15 @@ $(OUTPUT)/iterators.bpf.o: iterators.bpf.c $(BPFOBJ) | $(OUTPUT) -c $(filter %.c,$^) -o $@ && \ $(LLVM_STRIP) -g $@ -$(OUTPUT): +$(OUTPUT) $(LIBBPF_OUTPUT) $(LIBBPF_INCLUDE): $(call msg,MKDIR,$@) - $(Q)mkdir -p $(OUTPUT) + $(Q)mkdir -p $@ -$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPUT) +$(BPFOBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) \ + | $(LIBBPF_OUTPUT) $(LIBBPF_INCLUDE) $(Q)$(MAKE) $(submake_extras) -C $(LIBBPF_SRC) \ - OUTPUT=$(abspath $(dir $@))/ $(abspath $@) + OUTPUT=$(abspath $(dir $@))/ prefix= \ + DESTDIR=$(LIBBPF_DESTDIR) $(abspath $@) install_headers $(DEFAULT_BPFTOOL): $(Q)$(MAKE) $(submake_extras) -C ../../../../tools/bpf/bpftool \ From patchwork Thu Sep 30 11:33:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12528057 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC29BC433FE for ; Thu, 30 Sep 2021 11:34:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 978006162E for ; Thu, 30 Sep 2021 11:34:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350539AbhI3Lfw (ORCPT ); Thu, 30 Sep 2021 07:35:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350524AbhI3Lfv (ORCPT ); Thu, 30 Sep 2021 07:35:51 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B29EDC06176C for ; Thu, 30 Sep 2021 04:34:08 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id w29so9499770wra.8 for ; Thu, 30 Sep 2021 04:34:08 -0700 (PDT) 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=RpjwrVd2fRDSeptVCei7DoM+TRRc5Wynujd2MS0EFUo=; b=Kq2WSrQLVxGal8tY+haI+piz4KUU5c7ERynLxtWPBvIfhiNab/dZpC02IJ+aF32HJ8 KA+Ge6ts2s6nVALyqVN0gOujaE3dR/Lasg3lUbkstaC3xhtRIWV3/l/YNtz5bEU4e0pe NdBQRDryVuRnEYlhr3PBKc4gvobWUblPPewQB+3CEhZDgenRhdNfBRvaPPYA3a0v3crC D4tfUvOTKW6gfTZa7PWFqJgmt7Yi/UglzkFgJuc88uHnYmbRDhLFwrayMJzjEwCTbyBz 5UnzMzMAhM4J4OQueHXcG30loWJ2ITnXnlQbnGl072vaRIxvhka2tAIdm0soaFkaE4X+ zCvw== 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=RpjwrVd2fRDSeptVCei7DoM+TRRc5Wynujd2MS0EFUo=; b=lidY4FS7nD7YoJgnJCYex39gFSHUQ5xghpeYTjswiW1sKmLx+Yg3YaWNcmEWsk90MF 8qYKMkk88EKiDCO0V9MJNG2dcGmgU1WgMlLlw8rjrdgoByjQorzmfl3C9twbZighxhYR b2Rj3hMS6glH/1vHrr0HsMjZj/+opNVWWX5RFtJHl763zrAyjLcuva8TepcZESkaHzoV W+B5PXp9Ovy6mM0AjhhRtwT+ZeqQ4WzSIuG6CFyWDGPGRiopc1Al1+rUFmhVXO5ezjkW DABAgLSbsnd+Iog9p/2RJJ4YAYS3nVKxBsbJzPsa6UqedS/qpbH2Ts5k5u5X8xiKYtxJ yPsg== X-Gm-Message-State: AOAM5314nMmSEJUu3/lhxrWZtMxje1rqDW++piEf1vY+ZjiZJts9oxli CBz8uz3h2i9VjYd1Xji1QVsfOw== X-Google-Smtp-Source: ABdhPJx0vwfuRohg6SW51M23f+6XKI6ynuPzCrRXr5VWMpEqUZdWJUlyIDdnB/XdYCnlXjzx5DfAKg== X-Received: by 2002:a05:6000:2c2:: with SMTP id o2mr5399261wry.311.1633001647331; Thu, 30 Sep 2021 04:34:07 -0700 (PDT) Received: from localhost.localdomain ([149.86.91.95]) by smtp.gmail.com with ESMTPSA id v10sm2904660wrm.71.2021.09.30.04.34.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 04:34:06 -0700 (PDT) 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 7/9] samples/bpf: install libbpf headers when building Date: Thu, 30 Sep 2021 12:33:04 +0100 Message-Id: <20210930113306.14950-8-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930113306.14950-1-quentin@isovalent.com> References: <20210930113306.14950-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net API headers from libbpf should not be accessed directly from the source directory. Instead, they should be exported with "make install_headers". Make sure that samples/bpf/Makefile installs the headers properly when building. The object compiled from and exported by libbpf are now placed into a subdirectory of sample/bpf/ instead of remaining in tools/lib/bpf/. We attempt to remove this directory on "make clean". However, the "clean" target re-enters the samples/bpf/ directory from the root of the repository ("$(MAKE) -C ../../ M=$(CURDIR) clean"), in such a way that $(srctree) and $(src) are not defined, making it impossible to use $(LIBBPF_OUTPUT) and $(LIBBPF_DESTDIR) in the recipe. So we only attempt to clean $(CURDIR)/libbpf, which is the default value. We also change the output directory for bpftool, to place the generated objects under samples/bpf/bpftool/ instead of building in bpftool's directory directly. Doing so, we make sure bpftool reuses the libbpf library previously compiled and installed. Signed-off-by: Quentin Monnet --- samples/bpf/Makefile | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/samples/bpf/Makefile b/samples/bpf/Makefile index 4dc20be5fb96..7de602c2c705 100644 --- a/samples/bpf/Makefile +++ b/samples/bpf/Makefile @@ -59,7 +59,11 @@ tprogs-y += xdp_redirect tprogs-y += xdp_monitor # Libbpf dependencies -LIBBPF = $(TOOLS_PATH)/lib/bpf/libbpf.a +LIBBPF_SRC = $(TOOLS_PATH)/lib/bpf +LIBBPF_OUTPUT = $(abspath $(BPF_SAMPLES_PATH))/libbpf +LIBBPF_DESTDIR = $(LIBBPF_OUTPUT) +LIBBPF_INCLUDE = $(LIBBPF_DESTDIR)/include +LIBBPF = $(LIBBPF_OUTPUT)/libbpf.a CGROUP_HELPERS := ../../tools/testing/selftests/bpf/cgroup_helpers.o TRACE_HELPERS := ../../tools/testing/selftests/bpf/trace_helpers.o @@ -198,7 +202,7 @@ TPROGS_CFLAGS += -Wstrict-prototypes TPROGS_CFLAGS += -I$(objtree)/usr/include TPROGS_CFLAGS += -I$(srctree)/tools/testing/selftests/bpf/ -TPROGS_CFLAGS += -I$(srctree)/tools/lib/ +TPROGS_CFLAGS += -I$(LIBBPF_INCLUDE) TPROGS_CFLAGS += -I$(srctree)/tools/include TPROGS_CFLAGS += -I$(srctree)/tools/perf TPROGS_CFLAGS += -DHAVE_ATTR_TEST=0 @@ -268,16 +272,28 @@ all: clean: $(MAKE) -C ../../ M=$(CURDIR) clean @find $(CURDIR) -type f -name '*~' -delete + @/bin/rm -rf $(CURDIR)/libbpf $(CURDIR)/bpftool -$(LIBBPF): FORCE +$(LIBBPF): FORCE | $(LIBBPF_OUTPUT) $(LIBBPF_INCLUDE) # Fix up variables inherited from Kbuild that tools/ build system won't like - $(MAKE) -C $(dir $@) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \ - LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(BPF_SAMPLES_PATH)/../../ O= + $(MAKE) -C $(LIBBPF_SRC) RM='rm -rf' EXTRA_CFLAGS="$(TPROGS_CFLAGS)" \ + LDFLAGS=$(TPROGS_LDFLAGS) srctree=$(BPF_SAMPLES_PATH)/../../ \ + O= OUTPUT=$(LIBBPF_OUTPUT)/ DESTDIR=$(LIBBPF_DESTDIR) prefix= \ + $@ install_headers BPFTOOLDIR := $(TOOLS_PATH)/bpf/bpftool -BPFTOOL := $(BPFTOOLDIR)/bpftool -$(BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) - $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ +BPFTOOL_OUTPUT := $(abspath $(BPF_SAMPLES_PATH))/bpftool +BPFTOOL := $(BPFTOOL_OUTPUT)/bpftool +$(BPFTOOL): $(wildcard $(BPFTOOLDIR)/*.[ch] $(BPFTOOLDIR)/Makefile) \ + | $(BPFTOOL_OUTPUT) + $(MAKE) -C $(BPFTOOLDIR) srctree=$(BPF_SAMPLES_PATH)/../../ \ + OUTPUT=$(BPFTOOL_OUTPUT)/ \ + LIBBPF_OUTPUT=$(LIBBPF_OUTPUT) \ + LIBBPF_DESTDIR=$(LIBBPF_DESTDIR) + +$(LIBBPF_OUTPUT) $(LIBBPF_INCLUDE) $(BPFTOOL_OUTPUT): + $(call msg,MKDIR,$@) + $(Q)mkdir -p $@ $(obj)/syscall_nrs.h: $(obj)/syscall_nrs.s FORCE $(call filechk,offsets,__SYSCALL_NRS_H__) @@ -367,7 +383,7 @@ $(obj)/%.bpf.o: $(src)/%.bpf.c $(obj)/vmlinux.h $(src)/xdp_sample.bpf.h $(src)/x $(Q)$(CLANG) -g -O2 -target bpf -D__TARGET_ARCH_$(SRCARCH) \ -Wno-compare-distinct-pointer-types -I$(srctree)/include \ -I$(srctree)/samples/bpf -I$(srctree)/tools/include \ - -I$(srctree)/tools/lib $(CLANG_SYS_INCLUDES) \ + -I$(LIBBPF_INCLUDE) $(CLANG_SYS_INCLUDES) \ -c $(filter %.bpf.c,$^) -o $@ LINKED_SKELS := xdp_redirect_cpu.skel.h xdp_redirect_map_multi.skel.h \ @@ -404,7 +420,7 @@ $(obj)/%.o: $(src)/%.c @echo " CLANG-bpf " $@ $(Q)$(CLANG) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(BPF_EXTRA_CFLAGS) \ -I$(obj) -I$(srctree)/tools/testing/selftests/bpf/ \ - -I$(srctree)/tools/lib/ \ + -I$(LIBBPF_INCLUDE) \ -D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign \ -D__TARGET_ARCH_$(SRCARCH) -Wno-compare-distinct-pointer-types \ -Wno-gnu-variable-sized-type-not-at-end \ From patchwork Thu Sep 30 11:33:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12528059 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 812E9C4332F for ; Thu, 30 Sep 2021 11:34:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6281B6162E for ; Thu, 30 Sep 2021 11:34:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350547AbhI3Lfx (ORCPT ); Thu, 30 Sep 2021 07:35:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350531AbhI3Lfw (ORCPT ); Thu, 30 Sep 2021 07:35:52 -0400 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 821B4C06176A for ; Thu, 30 Sep 2021 04:34:09 -0700 (PDT) Received: by mail-wr1-x434.google.com with SMTP id u18so9519341wrg.5 for ; Thu, 30 Sep 2021 04:34:09 -0700 (PDT) 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=LZNCtgJESuuBglLRSxSP+yMWbcKos3toNZIRMOdvxc4=; b=AXtmHBiglxP2sf0bb8bFRuOONwWeS0JUyZOEZkgTqNNo7Z0jdwvgNHdftkKjihGTe2 /Rj/Sq7XVO+4PYPsfNZMMjDZO066LF+hkUPgX/AwHw228HovYxLs+fKv8Q5wU1jED0be +FF7uyk24TUguJKtyUU2PxQtCUQDrzwd3Rx0Bi3kJUzDfVuqveKi5E8i0qUL/ghOaNb+ 8aVhdvfgzYjTb0JiGdZm+vtRRrZjlY0CgLtKaFwrT6RBl1u+6i8d5ZRrTr3AKsDEdgrd +1msvA3L44KPciyF7nuD27GCjbswH1xNC3VmkkRRLswnlU2cNRf6EkOO447/FQAT4eHH I26A== 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=LZNCtgJESuuBglLRSxSP+yMWbcKos3toNZIRMOdvxc4=; b=xYSdavmrheUilRy6HgQetyuZAjoOnGtRQsaqg5GXneyYLXBolZrNsqNTge8Hq8g4wb AE5cAc430+mRZukWnADF8NLzJEqWQC+44cNdiEKaJE1IkKnRQVYGNEPiAf0Zxuy3WLzn 5pZXKBqCyTgda0wbTJ+3XVB/4TmbYnULYOLVHTeW/MyRI80NyTk2c1Z1LGmtD6hlPMrK OqxOjvcRGljuLUGG9So6ItUdUWhwZ1s8qu4pzCSQc0BJbZcZ0BEICLGBQc1GlotkZewu R35IdqYrafiL5VPfl4jkoyJZX7OuSuLwfoOJN0VEzBv+aF9my8OWC4BCUps5Ct0AAZCr 8Jbw== X-Gm-Message-State: AOAM531lD+a+UwEOoKtAFKItmIcTw7uADAcNNz1TbUpXSx5HWIoFxKFl X4gOW8yFYChcuwBE6x9oVRaCEQ== X-Google-Smtp-Source: ABdhPJx6HpQ6sHYF3ffSwyDP+oQd6oZ9o1JfsYvbPEOzhMCKP0wYlXbvH+Ig7FjxAfDDj9mu4zHYSw== X-Received: by 2002:a05:6000:2af:: with SMTP id l15mr5527470wry.129.1633001648184; Thu, 30 Sep 2021 04:34:08 -0700 (PDT) Received: from localhost.localdomain ([149.86.91.95]) by smtp.gmail.com with ESMTPSA id v10sm2904660wrm.71.2021.09.30.04.34.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 04:34:07 -0700 (PDT) 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 8/9] samples/bpf: update .gitignore Date: Thu, 30 Sep 2021 12:33:05 +0100 Message-Id: <20210930113306.14950-9-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930113306.14950-1-quentin@isovalent.com> References: <20210930113306.14950-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net Update samples/bpf/.gitignore to ignore files generated when building the samples. Add: - vmlinux.h - the generated skeleton files (*.skel.h) - the samples/bpf/libbpf/ directory, recently introduced as an output directory for building libbpf and installing its headers. Signed-off-by: Quentin Monnet --- samples/bpf/.gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/samples/bpf/.gitignore b/samples/bpf/.gitignore index fcba217f0ae2..01f94ce79df8 100644 --- a/samples/bpf/.gitignore +++ b/samples/bpf/.gitignore @@ -57,3 +57,6 @@ testfile.img hbm_out.log iperf.* *.out +*.skel.h +vmlinux.h +libbpf/ From patchwork Thu Sep 30 11:33:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Monnet X-Patchwork-Id: 12528061 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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 099D0C433F5 for ; Thu, 30 Sep 2021 11:34:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E9F4F619A6 for ; Thu, 30 Sep 2021 11:34:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350559AbhI3Lf4 (ORCPT ); Thu, 30 Sep 2021 07:35:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350524AbhI3Lfw (ORCPT ); Thu, 30 Sep 2021 07:35:52 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B9E8C06176A for ; Thu, 30 Sep 2021 04:34:10 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id x20so9491987wrg.10 for ; Thu, 30 Sep 2021 04:34:10 -0700 (PDT) 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=6qPlM6MAUchBkbCWCD/H91DQxecPf+FzubhRu6ucuSs=; b=ngoQMemrzIewdd3+IzesJcp06Wm6Qo2mJJj4JtXI83Ie4+j3CnMKPemhFtRk370aYB At51Lvv1n7GMQVGDu8x4ocfwd+TfhooeLe7QrX1VUp5eM4Fzx+FkhpWdRY4ExI/WG8tw 3hiVBKB/xefgKpOMhL3Gp6C5Y3nkmm0sjKa5FSChj/n3dHZzddS/xRepLtRVPY6vfwOr 3f1p5WcFy/qrHKBumoB/AOJ9QSaq0BUPqlau6XaA4odR9Hy6knvewR4kvf2HJdDC0AwE 5SJZP4CZdhAvKwAdIE4ONcbfE7U87ejPTr30jDBL69v1VROCmNX+/eFitdRfepsF5x3C DmEQ== 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=6qPlM6MAUchBkbCWCD/H91DQxecPf+FzubhRu6ucuSs=; b=wcVZd6+3AuyymHS7Z++pBqc7hOrDg/N1QHP6F+M9lMJuj+zxag0qv0yfG8QQA0JoLM x6J2AK8CNsWdOtB39dLwpGB7YmJASSypKPD27VteMM4fMG93jb/kXKn+NpJBBMiIVlL2 e9mcWZjes9cZP7ybAZG8Z2v8zjQiO9h2YOCY7zTVXKDBlt/9BfMvedSjZuAMgr7w+2IW HVc8h5J1lKTiDVWhQfxlxvim0AUjlaj8f0digu3HJ9B0WFR+4i2Kug6orP6Y6cuYbhgU 4ZvA4K8T6oYF9A8SGvCPPJGLVMzNosgFLXPuBVXe9DRYZpH5gbI0/kCAD+9IboefeJSI X0nA== X-Gm-Message-State: AOAM533youmO+jLZ64lHYAjiwRUHykCUDD6tslVoBBJewdIKCbnoljZr lhZO7hyx8EUQPSBmP6eJxnvSHQ== X-Google-Smtp-Source: ABdhPJz9dIovrgp2dDGP6xv6Y83kaTlcPNC+pb+jjtkJNXRphLp/ODWzSocZaAvxA9DAFqQlXgEDww== X-Received: by 2002:a5d:4a46:: with SMTP id v6mr5553856wrs.262.1633001649001; Thu, 30 Sep 2021 04:34:09 -0700 (PDT) Received: from localhost.localdomain ([149.86.91.95]) by smtp.gmail.com with ESMTPSA id v10sm2904660wrm.71.2021.09.30.04.34.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Sep 2021 04:34:08 -0700 (PDT) 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 9/9] selftests/bpf: better clean up for runqslower in test_bpftool_build.sh Date: Thu, 30 Sep 2021 12:33:06 +0100 Message-Id: <20210930113306.14950-10-quentin@isovalent.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210930113306.14950-1-quentin@isovalent.com> References: <20210930113306.14950-1-quentin@isovalent.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net The script test_bpftool_build.sh attempts to build bpftool in the various supported ways, to make sure nothing breaks. One of those ways is to run "make tools/bpf" from the root of the kernel repository. This command builds bpftool, along with the other tools under tools/bpf, and runqslower in particular. After running the command and upon a successful bpftool build, the script attempts to cleanup the generated objects. However, after building with this target and in the case of runqslower, the files are not cleaned up as expected. This is because the "tools/bpf" target sets $(OUTPUT) to .../tools/bpf/runqslower/ when building the tool, causing the object files to be placed directly under the runqslower directory. But when running "cd tools/bpf; make clean", the value for $(OUTPUT) is set to ".output" (relative to the runqslower directory) by runqslower's Makefile, and this is where the Makefile looks for files to clean up. We cannot easily fix in the root Makefile (where "tools/bpf" is defined) or in tools/scripts/Makefile.include (setting $(OUTPUT)), where changing the way the output variables are passed would likely have consequences elsewhere. We could change runqslower's Makefile to build in the repository instead of in a dedicated ".output/", but doing so just to accommodate a test script doesn't sound great. Instead, let's just make sure that we clean up runqslower properly by adding the correct command to the script. This will attempt to clean runqslower twice: the first try with command "cd tools/bpf; make clean" will search for tools/bpf/runqslower/.output and fail to clean it (but will still clean the other tools, in particular bpftool), the second one (added in this commit) sets the $(OUTPUT) variable like for building with the "tool/bpf" target and should succeed. Signed-off-by: Quentin Monnet --- tools/testing/selftests/bpf/test_bpftool_build.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/testing/selftests/bpf/test_bpftool_build.sh b/tools/testing/selftests/bpf/test_bpftool_build.sh index b03a87571592..1453a53ed547 100755 --- a/tools/testing/selftests/bpf/test_bpftool_build.sh +++ b/tools/testing/selftests/bpf/test_bpftool_build.sh @@ -90,6 +90,10 @@ echo -e "... through kbuild\n" if [ -f ".config" ] ; then make_and_clean tools/bpf + ## "make tools/bpf" sets $(OUTPUT) to ...tools/bpf/runqslower for + ## runqslower, but the default (used for the "clean" target) is .output. + ## Let's make sure we clean runqslower's directory properly. + make -C tools/bpf/runqslower OUTPUT=${KDIR_ROOT_DIR}/tools/bpf/runqslower/ clean ## $OUTPUT is overwritten in kbuild Makefile, and thus cannot be passed ## down from toplevel Makefile to bpftool's Makefile.