Skip to contentSkip to conversation

Remove IPVlan module dependencies on IPv6 and Netfilter

PATCH Superseded Matteo Croce 3 participants 8 messages Feb 14, 2018 – Feb 16, 2018

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover Remove IPVlan module dependencies on IPv6 and Netfilter

The IPVlan module currently depends on IPv6 and Netfilter. Refactor the code to allow building IPVlan module regardless of the value of CONFIG_IPV6 and CONFIG_NETFILTER.
Also change the dependency to CONFIG_NET_L3_MASTER_DEV into a select, as compiling L3 Master device alone has no sense.

$ grep -wE 'CONFIG_(IPV6|NETFILTER|IPVLAN)' .config
CONFIG_IPV6=y
CONFIG_NETFILTER=y
CONFIG_IPVLAN=m
$ ll drivers/net/ipvlan/ipvlan.ko
48K drivers/net/ipvlan/ipvlan.ko
$ grep -wE 'CONFIG_(IPV6|NETFILTER|IPVLAN)' .config
# CONFIG_IPV6 is not set
CONFIG_NETFILTER=y
CONFIG_IPVLAN=m
$ ll drivers/net/ipvlan/ipvlan.ko
44K drivers/net/ipvlan/ipvlan.ko
$ grep -wE 'CONFIG_(IPV6|NETFILTER|IPVLAN)' .config
CONFIG_IPV6=m
# CONFIG_NETFILTER is not set
CONFIG_IPVLAN=m
$ ll drivers/net/ipvlan/ipvlan.ko
46K drivers/net/ipvlan/ipvlan.ko
$ grep -wE 'CONFIG_(IPV6|NETFILTER|IPVLAN)' .config
# CONFIG_IPV6 is not set
# CONFIG_NETFILTER is not set
CONFIG_IPVLAN=m
$ ll drivers/net/ipvlan/ipvlan.ko
43K drivers/net/ipvlan/ipvlan.ko

Matteo Croce (3):
ipvlan: drop ipv6 dependency
ipvlan: drop netfilter dependency
ipvlan: selects master_l3 device instead of depending on it

 drivers/net/Kconfig              |  4 +-
 drivers/net/ipvlan/ipvlan.h      |  2 +
 drivers/net/ipvlan/ipvlan_core.c | 73 ++++++++++++++++++++++++++++---------
 drivers/net/ipvlan/ipvlan_main.c | 79 +++++++++++++++++++++++++++-------------
 4 files changed, 111 insertions(+), 47 deletions(-)
Signature · 1 line
2.14.3
#1 lore raw

PATCH 1/3 ipvlan: drop ipv6 dependency

IPVlan has an hard dependency on IPv6.
Refactor the ipvlan code to allow compiling it with IPv6 disabled.

---
 drivers/net/Kconfig              |  1 -
 drivers/net/ipvlan/ipvlan_core.c | 71 ++++++++++++++++++++++++++++++----------
 drivers/net/ipvlan/ipvlan_main.c | 48 +++++++++++++++++----------
 3 files changed, 84 insertions(+), 36 deletions(-)
drivers/net/Kconfig +0 -1
index 944ec3c9282c..3234c6618d75 100644
@@ -149,7 +149,6 @@ config MACVTAP
 config IPVLAN
     tristate "IP-VLAN support"
     depends on INET
-    depends on IPV6
     depends on NETFILTER
     depends on NET_L3_MASTER_DEV
     ---help---
drivers/net/ipvlan/ipvlan_core.c +53 -18

169 lines not on this page · raw message

drivers/net/ipvlan/ipvlan_main.c +31 -17

125 lines not on this page · raw message

Signature · 1 line
2.14.3
#2 lore raw

PATCH 2/3 ipvlan: drop netfilter dependency

In reply to Matteo Croce

IPVlan has an hard dependency on netfilter.
Refactor the ipvlan code to allow compiling it with netfilter disabled.

---
 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(-)
drivers/net/Kconfig +0 -1
index 3234c6618d75..64d3017ecd01 100644
@@ -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
drivers/net/ipvlan/ipvlan.h +2 -0
index 5166575a164d..b7fa5a48a351 100644
@@ -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,
drivers/net/ipvlan/ipvlan_core.c +2 -0
index 653b00738616..5be846bc6d8c 100644
@@ -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
drivers/net/ipvlan/ipvlan_main.c +22 -9
index 67c91ceda979..2e311251c27c 100644
@@ -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
 	}
 }
 
Signature · 1 line
2.14.3
#3 lore raw

PATCH 3/3 ipvlan: selects master_l3 device instead of depending on it

In reply to Matteo Croce

The L3 Master device is just a glue between the core networking code and device drivers, so it should be selected automatically rather than requiring to be enabled explicitly.

---
 drivers/net/Kconfig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/Kconfig +1 -1
index 64d3017ecd01..3dd8a6a6a336 100644
@@ -149,7 +149,7 @@ config MACVTAP
 config IPVLAN
     tristate "IP-VLAN support"
     depends on INET
-    depends on NET_L3_MASTER_DEV
+    select NET_L3_MASTER_DEV
     ---help---
       This allows one to create virtual devices off of a main interface
       and packets will be delivered based on the dest L3 (IPv6/IPv4 addr)
Signature · 1 line
2.14.3
#4 lore raw
In reply to Matteo Croce
Quoted 5 lines · Matteo Croce

The IPVlan module currently depends on IPv6 and Netfilter. Refactor the code to allow building IPVlan module regardless of the value of CONFIG_IPV6 and CONFIG_NETFILTER.
Also change the dependency to CONFIG_NET_L3_MASTER_DEV into a select, as compiling L3 Master device alone has no sense.

4fbae7d83c98c30efc implies that both netfilter and l3mdev are needed for l3s mode, yet I see no option of that in changelog or a change that rejects this mode.

Am I missing anything?

maintainer
#5 lore raw
In reply to Matteo Croce

From: Matteo Croce <[email protected]>
Date: Wed, 14 Feb 2018 19:13:42 +0100

Quoted 5 lines

The IPVlan module currently depends on IPv6 and Netfilter. Refactor the code to allow building IPVlan module regardless of the value of CONFIG_IPV6 and CONFIG_NETFILTER.
Also change the dependency to CONFIG_NET_L3_MASTER_DEV into a select, as compiling L3 Master device alone has no sense.

As stated, the L3 master and netfilter are hard depenencies when using ipvlan in some modes.

You can't just ifdef the driver like this, it changes fundamental pieces of functionality.

I would say leave things as they are right now.

#6 lore raw
Quoted 9 lines · David Miller

From: Matteo Croce <[email protected]>
Date: Wed, 14 Feb 2018 19:13:42 +0100

Quoted 5 lines

The IPVlan module currently depends on IPv6 and Netfilter. Refactor the code to allow building IPVlan module regardless of the value of CONFIG_IPV6 and CONFIG_NETFILTER.
Also change the dependency to CONFIG_NET_L3_MASTER_DEV into a select, as compiling L3 Master device alone has no sense.

Quoted 7 lines

As stated, the L3 master and netfilter are hard depenencies when using ipvlan in some modes.

You can't just ifdef the driver like this, it changes fundamental pieces of functionality.

I would say leave things as they are right now.

Hi David,

yes, I noticed that L3 master and netfilter are really needed in l3s mode, so let's drop patch 2/3.

What about the other two, removing IPv6 and change the Kconfig? Other devices like VXLan, Geneve and VRF uses the same architecture to allow conditional compilation of the IPv6 module,
I think that IPVlan should do the same.

Regards,

Signature · 2 lines
Matteo Croce
per aspera ad upstream
maintainer
#7 lore raw

From: Matteo Croce <[email protected]>
Date: Thu, 15 Feb 2018 15:04:52 +0100

Quoted 4 lines

What about the other two, removing IPv6 and change the Kconfig? Other devices like VXLan, Geneve and VRF uses the same architecture to allow conditional compilation of the IPv6 module, I think that IPVlan should do the same.

Ok, those parts should be reasonable, please respin.