From patchwork Tue Jan 23 19:22:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Kicinski X-Patchwork-Id: 864973 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=netdev-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=netronome-com.20150623.gappssmtp.com header.i=@netronome-com.20150623.gappssmtp.com header.b="u+zAlCGk"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zQyrr5gQTz9s4s for ; Wed, 24 Jan 2018 06:23:40 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752382AbeAWTXi (ORCPT ); Tue, 23 Jan 2018 14:23:38 -0500 Received: from mail-pf0-f193.google.com ([209.85.192.193]:35448 "EHLO mail-pf0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752158AbeAWTXI (ORCPT ); Tue, 23 Jan 2018 14:23:08 -0500 Received: by mail-pf0-f193.google.com with SMTP id t12so1094202pfg.2 for ; Tue, 23 Jan 2018 11:23:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=netronome-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=VZAYgJYhLVUtaBCfl5Vhs8IpnelRqFxGWq/grVnIE1A=; b=u+zAlCGkiLIR4fIMAkJJCFn1MXM4wPiiSiUoMsQt9eVFb6Q/8j91Trav3uF/S/4IrG erWePbTuUz1+y1WQKrkPbLbwVWgUBdb4fd5x4GPKNHthzK47iCwho4eYmGqZfyYmN+Xm 4Hb81Mpwd4LWhl6Bt+XI+86q3l8WhAzecFkaBKgQ75SQupDBkWd8BYAq0E8vL+FoSqes ZBW4pkNGHJE8rkSILrlYfg5qa8nI4zg+UqSTbHqyxLVAS31dS+JGqIJ4w9fKE7Qdg6O3 g7FgbHoRO06VJsBjCKPq6ZsUj7YJ2HMqikoMihuDgeBzl1aO3epYWiyk7XNrYCNgJzuE e8ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=VZAYgJYhLVUtaBCfl5Vhs8IpnelRqFxGWq/grVnIE1A=; b=EagIXlY/w4QJfjNg9p+UEDttuwJkgoPdwWfCjt3WylWpTsX8q4uP8OBXu9LJ4gwkQ9 tf0PRjl5KRAK+mU2S/qtUpz6bQqjeWIEgxj2U64JI/Hnv0TgfPtmW9vkwnguzbQVJ8SC zAtrSkmk8vnwhVY4RDvK5WpcnyYwP+/TKJZLdALaRzZmXYXqNlNi+pWNz1/f3OEtjwoL YHKKLkQFZjKLQTV6aJ5zAvzwKf+BULiw5vU3CHCAml3/Y2lOwM8YsGOr9IAQnZjHkPtn wdNSi3EhWBU1CoveLm1lacSTuSsHxbie0QXx4OhiEyDAR7e/tF6qQkzzbeNZmV8n6OLP Qatg== X-Gm-Message-State: AKwxytfOo8FcZ2JofkmV1+dCSlTQh1YuZEnsw7PjCd/TLdRkKwYHrWUH 4GQ+SBgkX7AjvSxVUg0Pz2I/qg== X-Google-Smtp-Source: AH8x2259exMH9XFGqTZE+xsJCRrF585XvcZjiMxqgkPwBOZkX5oBV7ZH6/sFi1djS+aroQTK96o1zg== X-Received: by 2002:a17:902:8a91:: with SMTP id p17-v6mr6164106plo.375.1516735388018; Tue, 23 Jan 2018 11:23:08 -0800 (PST) Received: from jkicinski-Precision-T1700.netronome.com ([75.53.12.129]) by smtp.gmail.com with ESMTPSA id o135sm6530472pfg.161.2018.01.23.11.23.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Jan 2018 11:23:07 -0800 (PST) From: Jakub Kicinski To: davem@davemloft.net, alexei.starovoitov@gmail.com, daniel@iogearbox.net Cc: netdev@vger.kernel.org, oss-drivers@netronome.com, Jakub Kicinski Subject: [PATCH net-next 3/5] netdevsim: don't compile BPF code if syscall not enabled Date: Tue, 23 Jan 2018 11:22:54 -0800 Message-Id: <20180123192256.16106-4-jakub.kicinski@netronome.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180123192256.16106-1-jakub.kicinski@netronome.com> References: <20180123192256.16106-1-jakub.kicinski@netronome.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org We should not compile netdevsim/bpf.c if BPF syscall is not enabled. Otherwise bpf core would have to provide wrappers for all functions offload drivers may call, even though system will never see a BPF object. Signed-off-by: Jakub Kicinski Reviewed-by: Quentin Monnet --- drivers/net/netdevsim/Makefile | 6 +++++- drivers/net/netdevsim/netdevsim.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/drivers/net/netdevsim/Makefile b/drivers/net/netdevsim/Makefile index 074ddebbc41d..09388c06171d 100644 --- a/drivers/net/netdevsim/Makefile +++ b/drivers/net/netdevsim/Makefile @@ -4,4 +4,8 @@ obj-$(CONFIG_NETDEVSIM) += netdevsim.o netdevsim-objs := \ netdev.o \ - bpf.o \ + +ifeq ($(CONFIG_BPF_SYSCALL),y) +netdevsim-objs += \ + bpf.o +endif diff --git a/drivers/net/netdevsim/netdevsim.h b/drivers/net/netdevsim/netdevsim.h index b80361200302..ea081c10efb8 100644 --- a/drivers/net/netdevsim/netdevsim.h +++ b/drivers/net/netdevsim/netdevsim.h @@ -68,12 +68,40 @@ struct netdevsim { extern struct dentry *nsim_ddir; +#ifdef CONFIG_BPF_SYSCALL int nsim_bpf_init(struct netdevsim *ns); void nsim_bpf_uninit(struct netdevsim *ns); int nsim_bpf(struct net_device *dev, struct netdev_bpf *bpf); int nsim_bpf_disable_tc(struct netdevsim *ns); int nsim_bpf_setup_tc_block_cb(enum tc_setup_type type, void *type_data, void *cb_priv); +#else +static inline int nsim_bpf_init(struct netdevsim *ns) +{ + return 0; +} + +static inline void nsim_bpf_uninit(struct netdevsim *ns) +{ +} + +static inline int nsim_bpf(struct net_device *dev, struct netdev_bpf *bpf) +{ + return bpf->command == XDP_QUERY_PROG ? 0 : -EOPNOTSUPP; +} + +static inline int nsim_bpf_disable_tc(struct netdevsim *ns) +{ + return 0; +} + +static inline int +nsim_bpf_setup_tc_block_cb(enum tc_setup_type type, void *type_data, + void *cb_priv) +{ + return -EOPNOTSUPP; +} +#endif static inline struct netdevsim *to_nsim(struct device *ptr) {