From patchwork Wed Feb 14 18:13:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matteo Croce X-Patchwork-Id: 873462 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=) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3zhSGG15kzz9t1t for ; Thu, 15 Feb 2018 05:13:58 +1100 (AEDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161793AbeBNSN4 (ORCPT ); Wed, 14 Feb 2018 13:13:56 -0500 Received: from mail-wm0-f66.google.com ([74.125.82.66]:52900 "EHLO mail-wm0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161765AbeBNSNv (ORCPT ); Wed, 14 Feb 2018 13:13:51 -0500 Received: by mail-wm0-f66.google.com with SMTP id j199so12289778wmj.2 for ; Wed, 14 Feb 2018 10:13:50 -0800 (PST) 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=Y40AznS/F4pYRp+xDS5CFsTeSeDOdVPbFUj6NT4Cldw=; b=TTU59qySdx8G2yvNU8PDXkKFvaoLjJSQ/xPd05hbpAowRXYR/UtjpNdx1tfRaIv/io s3EYur2/Ei+St1raLkNo4weVcKYD3zcNJokunj00Cp7nvRdxhk1LgSVQPfBOZFoE7xrP jqbW+0bahc9GICpyh4pzcrzZPZ5sofUydr/FspufFBZQSn3ffQ7Z8XqrOL2eMSOmxrNe HmFUlFypE1XzO05yaCW1GOIYu5i/yhRo0hfAU3YH79BUwro1v1HF8XvrvzYqCPXyrfKO vaKGHjalLZO2A4B7/QHL5Unv26mT/Zydg+etMSJCI4JpM226Nb2p/rDtef9j2VttVy87 mX9w== X-Gm-Message-State: APf1xPDVdXfbA6LPRknZnT9J6knkpYuih591dqH0ykLrDKXLdqplYIHc MvQwMFn7GbLJKlObkwzRiusyZoxwHOQ= X-Google-Smtp-Source: AH8x224qHYn7soKCeW5jur0SnPcbWTvJfrBtmN2g9YfbJHUr9sWSDi9bMKuypKtr73QrrLMiM2zGLw== X-Received: by 10.28.214.67 with SMTP id n64mr60513wmg.25.1518632029712; Wed, 14 Feb 2018 10:13:49 -0800 (PST) Received: from raver.mxp.redhat.com (nat-pool-mxp-t.redhat.com. [149.6.153.186]) by smtp.gmail.com with ESMTPSA id j77sm23014800wmf.37.2018.02.14.10.13.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 14 Feb 2018 10:13:48 -0800 (PST) From: Matteo Croce To: netdev@vger.kernel.org Cc: Mahesh Bandewar Subject: [PATCH 2/3] ipvlan: drop netfilter dependency Date: Wed, 14 Feb 2018 19:13:44 +0100 Message-Id: <20180214181345.6368-3-mcroce@redhat.com> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180214181345.6368-1-mcroce@redhat.com> References: <20180214181345.6368-1-mcroce@redhat.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org IPVlan has an hard dependency on netfilter. Refactor the ipvlan code to allow compiling it with netfilter disabled. Signed-off-by: Matteo Croce --- drivers/net/Kconfig | 1 - drivers/net/ipvlan/ipvlan.h | 2 ++ drivers/net/ipvlan/ipvlan_core.c | 2 ++ drivers/net/ipvlan/ipvlan_main.c | 31 ++++++++++++++++++++++--------- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 3234c6618d75..64d3017ecd01 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -149,7 +149,6 @@ config MACVTAP config IPVLAN tristate "IP-VLAN support" depends on INET - depends on NETFILTER depends on NET_L3_MASTER_DEV ---help--- This allows one to create virtual devices off of a main interface diff --git a/drivers/net/ipvlan/ipvlan.h b/drivers/net/ipvlan/ipvlan.h index 5166575a164d..b7fa5a48a351 100644 --- a/drivers/net/ipvlan/ipvlan.h +++ b/drivers/net/ipvlan/ipvlan.h @@ -166,8 +166,10 @@ bool ipvlan_addr_busy(struct ipvl_port *port, void *iaddr, bool is_v6); void ipvlan_ht_addr_del(struct ipvl_addr *addr); struct sk_buff *ipvlan_l3_rcv(struct net_device *dev, struct sk_buff *skb, u16 proto); +#ifdef CONFIG_NETFILTER unsigned int ipvlan_nf_input(void *priv, struct sk_buff *skb, const struct nf_hook_state *state); +#endif void ipvlan_count_rx(const struct ipvl_dev *ipvlan, unsigned int len, bool success, bool mcast); int ipvlan_link_new(struct net *src_net, struct net_device *dev, diff --git a/drivers/net/ipvlan/ipvlan_core.c b/drivers/net/ipvlan/ipvlan_core.c index 653b00738616..5be846bc6d8c 100644 --- a/drivers/net/ipvlan/ipvlan_core.c +++ b/drivers/net/ipvlan/ipvlan_core.c @@ -821,6 +821,7 @@ struct sk_buff *ipvlan_l3_rcv(struct net_device *dev, struct sk_buff *skb, return skb; } +#ifdef CONFIG_NETFILTER unsigned int ipvlan_nf_input(void *priv, struct sk_buff *skb, const struct nf_hook_state *state) { @@ -837,3 +838,4 @@ unsigned int ipvlan_nf_input(void *priv, struct sk_buff *skb, out: return NF_ACCEPT; } +#endif diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c index 67c91ceda979..2e311251c27c 100644 --- a/drivers/net/ipvlan/ipvlan_main.c +++ b/drivers/net/ipvlan/ipvlan_main.c @@ -15,6 +15,16 @@ struct ipvlan_netns { unsigned int ipvl_nf_hook_refcnt; }; +static const struct l3mdev_ops ipvl_l3mdev_ops = { + .l3mdev_l3_rcv = ipvlan_l3_rcv, +}; + +static void ipvlan_adjust_mtu(struct ipvl_dev *ipvlan, struct net_device *dev) +{ + ipvlan->dev->mtu = dev->mtu; +} + +#ifdef CONFIG_NETFILTER static const struct nf_hook_ops ipvl_nfops[] = { { .hook = ipvlan_nf_input, @@ -32,15 +42,6 @@ static const struct nf_hook_ops ipvl_nfops[] = { #endif }; -static const struct l3mdev_ops ipvl_l3mdev_ops = { - .l3mdev_l3_rcv = ipvlan_l3_rcv, -}; - -static void ipvlan_adjust_mtu(struct ipvl_dev *ipvlan, struct net_device *dev) -{ - ipvlan->dev->mtu = dev->mtu; -} - static int ipvlan_register_nf_hook(struct net *net) { struct ipvlan_netns *vnet = net_generic(net, ipvlan_netid); @@ -70,6 +71,16 @@ static void ipvlan_unregister_nf_hook(struct net *net) nf_unregister_net_hooks(net, ipvl_nfops, ARRAY_SIZE(ipvl_nfops)); } +#else +static int ipvlan_register_nf_hook(struct net *net) +{ + return 0; +} + +static void ipvlan_unregister_nf_hook(struct net *net) +{ +} +#endif static int ipvlan_set_port_mode(struct ipvl_port *port, u16 nval) { @@ -1015,8 +1026,10 @@ static void ipvlan_ns_exit(struct net *net) if (WARN_ON_ONCE(vnet->ipvl_nf_hook_refcnt)) { vnet->ipvl_nf_hook_refcnt = 0; +#ifdef CONFIG_NETFILTER nf_unregister_net_hooks(net, ipvl_nfops, ARRAY_SIZE(ipvl_nfops)); +#endif } }