Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp7560828imm; Thu, 28 Jun 2018 05:56:54 -0700 (PDT) X-Google-Smtp-Source: AAOMgpe7BvrViAfhVT/eYUN6NCPrf0P5CDu/YHyAyQ65KwWoKnJMNZ/H4QCvQRbDgfNDxZr173oa X-Received: by 2002:a65:630e:: with SMTP id g14-v6mr7258881pgv.153.1530190614153; Thu, 28 Jun 2018 05:56:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530190614; cv=none; d=google.com; s=arc-20160816; b=sCiy373S9pZAHH8xkewH9/tbv1+z3ParopSyAKfSdZpYZj5WqKSN5TwTR7Ehmo9NQU 6Z4uB/60mYwu8LLVIZcWZqXlktFbRqsxKfN7+ouq9HPhRbhB6gvMDFR63e3HaDVixPpz 0vcyhBCJuaXMf9C5YNOYSaJSylNsnbkBnnJ8/kJrSE9rSrhgJZq9qLDXc1U6XKBjTrju K9a+H9utL5QBR3OuGs24DStbGxkD8F8COMgou50EUnWhogN3UkEp/Y214Sn5vE2FxCsJ ag/v2dAiKCmJu21zo60XehlO9RJxrITPb1MfXK1Fx90+xx9h3KnNsFwkSA1XAQWMicCj /DjQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=3LKZ5vsfMK9CTPi4WQ5DWJFT9uksAdxw/C700phFkGQ=; b=UCs3NmtrZW3Aa59WZQ0n4HrlGYazUtyWpsXCsgLo+jDd8pm0LQGvD8Zc7lR5nlO4Sd aFN79J2qmceboZRiW7pOeZdLnCjlja1hT7nIOzzFcIe8JBNsOz0tqX8CMWt6tbIam8dQ XLt95XDZt8Eg9VsvW16RJtm2TR9iSZZOcJd4kEc98TDLRHYV3RvFOVeznxnepRp45qZ7 qTOh1G9ndEAXpg7wiFNdF4LtN3iJtlWZuzdZSZD+GoVUzlEMN22ItdmlxxIXOtuOGhbc xiZHLXsndXfW/7inlA/+yIk1JLB4NhZw1WN2t0fSb91O79VrMgu2U8cN1e2wpbScwtW/ f4Ig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=tMiTIbor; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s36-v6si6358692pld.278.2018.06.28.05.56.38; Thu, 28 Jun 2018 05:56:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.de header.s=amazon201209 header.b=tMiTIbor; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966061AbeF1MsV (ORCPT + 99 others); Thu, 28 Jun 2018 08:48:21 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:19832 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966044AbeF1MsS (ORCPT ); Thu, 28 Jun 2018 08:48:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.de; i=@amazon.de; q=dns/txt; s=amazon201209; t=1530190098; x=1561726098; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=3LKZ5vsfMK9CTPi4WQ5DWJFT9uksAdxw/C700phFkGQ=; b=tMiTIborvH43ApHlfoJq7ppATL6wfTdPuI4MLY24D5+M/HYP+2PJxkfU 7Wb7hRY/JzZJlrGw4Wo+YzoMb5DUwtwnaKIUhHvi/HB4CeQyzWvrMwVGU auOhlLD1pPrSEyXu3lyFPS4y2wdXYwEDdTWOw/Ypw+hnqqUhq7ITKd68t A=; X-IronPort-AV: E=Sophos;i="5.51,283,1526342400"; d="scan'208";a="740115893" Received: from sea3-co-svc-lb6-vlan2.sea.amazon.com (HELO email-inbound-relay-2a-53356bf6.us-west-2.amazon.com) ([10.47.22.34]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 28 Jun 2018 12:48:17 +0000 Received: from EX13MTAUEA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2a-53356bf6.us-west-2.amazon.com (8.14.7/8.14.7) with ESMTP id w5SCl2Nt075338 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=FAIL); Thu, 28 Jun 2018 12:47:02 GMT Received: from EX13D02EUB002.ant.amazon.com (10.43.166.170) by EX13MTAUEA001.ant.amazon.com (10.43.61.243) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 28 Jun 2018 12:46:52 +0000 Received: from EX13MTAUEE001.ant.amazon.com (10.43.62.200) by EX13D02EUB002.ant.amazon.com (10.43.166.170) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Thu, 28 Jun 2018 12:46:51 +0000 Received: from uc1a35a69ae4659.ant.amazon.com (10.28.85.80) by mail-relay.amazon.com (10.43.62.226) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Thu, 28 Jun 2018 12:46:50 +0000 From: Norbert Manthey To: Norbert Manthey , CC: Alexei Starovoitov , Daniel Borkmann , Subject: [less-CONFIG_NET v2 6/8] bpf: avoid duplicate definitions Date: Thu, 28 Jun 2018 14:45:34 +0200 Message-ID: <1530189936-25780-7-git-send-email-nmanthey@amazon.de> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1530189936-25780-1-git-send-email-nmanthey@amazon.de> References: <1530189936-25780-1-git-send-email-nmanthey@amazon.de> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the aim of making CONFIG_SECCOMP_FILTER independent of CONFIG_NET, some bpf functions are not required to provide net functionality, as already implemented in the header include/linux/bpf.h. However, the source files assumed to be only included if CONFIG_NET is activated. To be able to include the source files while CONFIG_NET is disabled, make sure the functions defined in the header include/linux/bpf.h are not included in the source file. To reduce the amount of #ifdef CONFIG_NET guards, the position of the functions __bpf_map_offload_destroy and bpf_map_offload_map_alloc has been swapped. Signed-off-by: Norbert Manthey --- kernel/bpf/offload.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/kernel/bpf/offload.c b/kernel/bpf/offload.c index ac747d5..7042dbe 100644 --- a/kernel/bpf/offload.c +++ b/kernel/bpf/offload.c @@ -32,6 +32,7 @@ static DECLARE_RWSEM(bpf_devs_lock); static LIST_HEAD(bpf_prog_offload_devs); static LIST_HEAD(bpf_map_offload_devs); +#ifdef CONFIG_NET static int bpf_dev_offload_check(struct net_device *netdev) { if (!netdev) @@ -84,6 +85,7 @@ int bpf_prog_offload_init(struct bpf_prog *prog, union bpf_attr *attr) kfree(offload); return err; } +#endif // CONFIG_NET static int __bpf_offload_ndo(struct bpf_prog *prog, enum bpf_netdev_command cmd, struct netdev_bpf *data) @@ -291,6 +293,16 @@ static int bpf_map_offload_ndo(struct bpf_offloaded_map *offmap, return netdev->netdev_ops->ndo_bpf(netdev, &data); } +static void __bpf_map_offload_destroy(struct bpf_offloaded_map *offmap) +{ + WARN_ON(bpf_map_offload_ndo(offmap, BPF_OFFLOAD_MAP_FREE)); + /* Make sure BPF_MAP_GET_NEXT_ID can't find this dead map */ + bpf_map_free_id(&offmap->map, true); + list_del_init(&offmap->offloads); + offmap->netdev = NULL; +} + +#ifdef CONFIG_NET struct bpf_map *bpf_map_offload_map_alloc(union bpf_attr *attr) { struct net *net = current->nsproxy->net_ns; @@ -333,15 +345,6 @@ struct bpf_map *bpf_map_offload_map_alloc(union bpf_attr *attr) return ERR_PTR(err); } -static void __bpf_map_offload_destroy(struct bpf_offloaded_map *offmap) -{ - WARN_ON(bpf_map_offload_ndo(offmap, BPF_OFFLOAD_MAP_FREE)); - /* Make sure BPF_MAP_GET_NEXT_ID can't find this dead map */ - bpf_map_free_id(&offmap->map, true); - list_del_init(&offmap->offloads); - offmap->netdev = NULL; -} - void bpf_map_offload_map_free(struct bpf_map *map) { struct bpf_offloaded_map *offmap = map_to_offmap(map); @@ -355,6 +358,7 @@ void bpf_map_offload_map_free(struct bpf_map *map) kfree(offmap); } +#endif // CONFIG_NET int bpf_map_offload_lookup_elem(struct bpf_map *map, void *key, void *value) { -- 2.7.4 Amazon Development Center Germany GmbH Berlin - Dresden - Aachen main office: Krausenstr. 38, 10117 Berlin Geschaeftsfuehrer: Dr. Ralf Herbrich, Christian Schlaeger Ust-ID: DE289237879 Eingetragen am Amtsgericht Charlottenburg HRB 149173 B