netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels
@ 2014-11-03  8:19 Steffen Klassert
  2014-11-03  8:19 ` [PATCH net 1/4] ip6_tunnel: Use ip6_tnl_dev_init as the ndo_init function Steffen Klassert
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Steffen Klassert @ 2014-11-03  8:19 UTC (permalink / raw)
  To: David Miller; +Cc: Steffen Klassert, netdev

The ipv6 tunnels do the dev->iflink setting too early, it gets
overwritten by register_netdev(). So set dev->iflink from within
a ndo_init function to keep the configured setting.

This patchset fixes this for ip6_tunnel, vti6, sit and gre6.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH net 1/4] ip6_tunnel: Use ip6_tnl_dev_init as the ndo_init function.
  2014-11-03  8:19 [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels Steffen Klassert
@ 2014-11-03  8:19 ` Steffen Klassert
  2014-11-03  8:19 ` [PATCH net 2/4] vti6: Use vti6_dev_init " Steffen Klassert
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2014-11-03  8:19 UTC (permalink / raw)
  To: David Miller; +Cc: Steffen Klassert, netdev

ip6_tnl_dev_init() sets the dev->iflink via a call to
ip6_tnl_link_config(). After that, register_netdevice()
sets dev->iflink = -1. So we loose the iflink configuration
for ipv6 tunnels. Fix this by using ip6_tnl_dev_init() as the
ndo_init function. Then ip6_tnl_dev_init() is called after
dev->iflink is set to -1 from register_netdevice().

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv6/ip6_tunnel.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 9409887..9cb94cf 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -272,9 +272,6 @@ static int ip6_tnl_create2(struct net_device *dev)
 	int err;
 
 	t = netdev_priv(dev);
-	err = ip6_tnl_dev_init(dev);
-	if (err < 0)
-		goto out;
 
 	err = register_netdevice(dev);
 	if (err < 0)
@@ -1462,6 +1459,7 @@ ip6_tnl_change_mtu(struct net_device *dev, int new_mtu)
 
 
 static const struct net_device_ops ip6_tnl_netdev_ops = {
+	.ndo_init	= ip6_tnl_dev_init,
 	.ndo_uninit	= ip6_tnl_dev_uninit,
 	.ndo_start_xmit = ip6_tnl_xmit,
 	.ndo_do_ioctl	= ip6_tnl_ioctl,
@@ -1546,16 +1544,10 @@ static int __net_init ip6_fb_tnl_dev_init(struct net_device *dev)
 	struct ip6_tnl *t = netdev_priv(dev);
 	struct net *net = dev_net(dev);
 	struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id);
-	int err = ip6_tnl_dev_init_gen(dev);
-
-	if (err)
-		return err;
 
 	t->parms.proto = IPPROTO_IPV6;
 	dev_hold(dev);
 
-	ip6_tnl_link_config(t);
-
 	rcu_assign_pointer(ip6n->tnls_wc[0], t);
 	return 0;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 2/4] vti6: Use vti6_dev_init as the ndo_init function.
  2014-11-03  8:19 [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels Steffen Klassert
  2014-11-03  8:19 ` [PATCH net 1/4] ip6_tunnel: Use ip6_tnl_dev_init as the ndo_init function Steffen Klassert
@ 2014-11-03  8:19 ` Steffen Klassert
  2014-11-03  8:19 ` [PATCH net 3/4] sit: Use ipip6_tunnel_init " Steffen Klassert
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2014-11-03  8:19 UTC (permalink / raw)
  To: David Miller; +Cc: Steffen Klassert, netdev

vti6_dev_init() sets the dev->iflink via a call to
vti6_link_config(). After that, register_netdevice()
sets dev->iflink = -1. So we loose the iflink configuration
for vti6 tunnels. Fix this by using vti6_dev_init() as the
ndo_init function. Then vti6_dev_init() is called after
dev->iflink is set to -1 from register_netdevice().

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv6/ip6_vti.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/net/ipv6/ip6_vti.c b/net/ipv6/ip6_vti.c
index d440bb5..31089d1 100644
--- a/net/ipv6/ip6_vti.c
+++ b/net/ipv6/ip6_vti.c
@@ -172,10 +172,6 @@ static int vti6_tnl_create2(struct net_device *dev)
 	struct vti6_net *ip6n = net_generic(net, vti6_net_id);
 	int err;
 
-	err = vti6_dev_init(dev);
-	if (err < 0)
-		goto out;
-
 	err = register_netdevice(dev);
 	if (err < 0)
 		goto out;
@@ -783,6 +779,7 @@ static int vti6_change_mtu(struct net_device *dev, int new_mtu)
 }
 
 static const struct net_device_ops vti6_netdev_ops = {
+	.ndo_init	= vti6_dev_init,
 	.ndo_uninit	= vti6_dev_uninit,
 	.ndo_start_xmit = vti6_tnl_xmit,
 	.ndo_do_ioctl	= vti6_ioctl,
@@ -852,16 +849,10 @@ static int __net_init vti6_fb_tnl_dev_init(struct net_device *dev)
 	struct ip6_tnl *t = netdev_priv(dev);
 	struct net *net = dev_net(dev);
 	struct vti6_net *ip6n = net_generic(net, vti6_net_id);
-	int err = vti6_dev_init_gen(dev);
-
-	if (err)
-		return err;
 
 	t->parms.proto = IPPROTO_IPV6;
 	dev_hold(dev);
 
-	vti6_link_config(t);
-
 	rcu_assign_pointer(ip6n->tnls_wc[0], t);
 	return 0;
 }
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 3/4] sit: Use ipip6_tunnel_init as the ndo_init function.
  2014-11-03  8:19 [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels Steffen Klassert
  2014-11-03  8:19 ` [PATCH net 1/4] ip6_tunnel: Use ip6_tnl_dev_init as the ndo_init function Steffen Klassert
  2014-11-03  8:19 ` [PATCH net 2/4] vti6: Use vti6_dev_init " Steffen Klassert
@ 2014-11-03  8:19 ` Steffen Klassert
  2014-11-03  8:19 ` [PATCH net 4/4] gre6: Move the setting of dev->iflink into the ndo_init functions Steffen Klassert
  2014-11-03 20:43 ` [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2014-11-03  8:19 UTC (permalink / raw)
  To: David Miller; +Cc: Steffen Klassert, netdev

ipip6_tunnel_init() sets the dev->iflink via a call to
ipip6_tunnel_bind_dev(). After that, register_netdevice()
sets dev->iflink = -1. So we loose the iflink configuration
for ipv6 tunnels. Fix this by using ipip6_tunnel_init() as the
ndo_init function. Then ipip6_tunnel_init() is called after
dev->iflink is set to -1 from register_netdevice().

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv6/sit.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
index 58e5b47..a24557a 100644
--- a/net/ipv6/sit.c
+++ b/net/ipv6/sit.c
@@ -195,10 +195,8 @@ static int ipip6_tunnel_create(struct net_device *dev)
 	struct sit_net *sitn = net_generic(net, sit_net_id);
 	int err;
 
-	err = ipip6_tunnel_init(dev);
-	if (err < 0)
-		goto out;
-	ipip6_tunnel_clone_6rd(dev, sitn);
+	memcpy(dev->dev_addr, &t->parms.iph.saddr, 4);
+	memcpy(dev->broadcast, &t->parms.iph.daddr, 4);
 
 	if ((__force u16)t->parms.i_flags & SIT_ISATAP)
 		dev->priv_flags |= IFF_ISATAP;
@@ -207,7 +205,8 @@ static int ipip6_tunnel_create(struct net_device *dev)
 	if (err < 0)
 		goto out;
 
-	strcpy(t->parms.name, dev->name);
+	ipip6_tunnel_clone_6rd(dev, sitn);
+
 	dev->rtnl_link_ops = &sit_link_ops;
 
 	dev_hold(dev);
@@ -1330,6 +1329,7 @@ static int ipip6_tunnel_change_mtu(struct net_device *dev, int new_mtu)
 }
 
 static const struct net_device_ops ipip6_netdev_ops = {
+	.ndo_init	= ipip6_tunnel_init,
 	.ndo_uninit	= ipip6_tunnel_uninit,
 	.ndo_start_xmit	= sit_tunnel_xmit,
 	.ndo_do_ioctl	= ipip6_tunnel_ioctl,
@@ -1378,9 +1378,7 @@ static int ipip6_tunnel_init(struct net_device *dev)
 
 	tunnel->dev = dev;
 	tunnel->net = dev_net(dev);
-
-	memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
-	memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
+	strcpy(tunnel->parms.name, dev->name);
 
 	ipip6_tunnel_bind_dev(dev);
 	dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats);
@@ -1405,7 +1403,6 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
 
 	tunnel->dev = dev;
 	tunnel->net = dev_net(dev);
-	strcpy(tunnel->parms.name, dev->name);
 
 	iph->version		= 4;
 	iph->protocol		= IPPROTO_IPV6;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH net 4/4] gre6: Move the setting of dev->iflink into the ndo_init functions.
  2014-11-03  8:19 [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels Steffen Klassert
                   ` (2 preceding siblings ...)
  2014-11-03  8:19 ` [PATCH net 3/4] sit: Use ipip6_tunnel_init " Steffen Klassert
@ 2014-11-03  8:19 ` Steffen Klassert
  2014-11-03 20:43 ` [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: Steffen Klassert @ 2014-11-03  8:19 UTC (permalink / raw)
  To: David Miller; +Cc: Steffen Klassert, netdev

Otherwise it gets overwritten by register_netdev().

Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com>
---
 net/ipv6/ip6_gre.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
index 12c3c8e..4564e1f 100644
--- a/net/ipv6/ip6_gre.c
+++ b/net/ipv6/ip6_gre.c
@@ -961,8 +961,6 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
 	else
 		dev->flags &= ~IFF_POINTOPOINT;
 
-	dev->iflink = p->link;
-
 	/* Precalculate GRE options length */
 	if (t->parms.o_flags&(GRE_CSUM|GRE_KEY|GRE_SEQ)) {
 		if (t->parms.o_flags&GRE_CSUM)
@@ -1272,6 +1270,7 @@ static int ip6gre_tunnel_init(struct net_device *dev)
 		u64_stats_init(&ip6gre_tunnel_stats->syncp);
 	}
 
+	dev->iflink = tunnel->parms.link;
 
 	return 0;
 }
@@ -1481,6 +1480,8 @@ static int ip6gre_tap_init(struct net_device *dev)
 	if (!dev->tstats)
 		return -ENOMEM;
 
+	dev->iflink = tunnel->parms.link;
+
 	return 0;
 }
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels
  2014-11-03  8:19 [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels Steffen Klassert
                   ` (3 preceding siblings ...)
  2014-11-03  8:19 ` [PATCH net 4/4] gre6: Move the setting of dev->iflink into the ndo_init functions Steffen Klassert
@ 2014-11-03 20:43 ` David Miller
  4 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2014-11-03 20:43 UTC (permalink / raw)
  To: steffen.klassert; +Cc: netdev

From: Steffen Klassert <steffen.klassert@secunet.com>
Date: Mon, 3 Nov 2014 09:19:26 +0100

> The ipv6 tunnels do the dev->iflink setting too early, it gets
> overwritten by register_netdev(). So set dev->iflink from within
> a ndo_init function to keep the configured setting.
> 
> This patchset fixes this for ip6_tunnel, vti6, sit and gre6.

Series applied, good catch, and thanks for checking all of the ipv6
tunnel drivers for this problem.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-11-03 20:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-03  8:19 [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels Steffen Klassert
2014-11-03  8:19 ` [PATCH net 1/4] ip6_tunnel: Use ip6_tnl_dev_init as the ndo_init function Steffen Klassert
2014-11-03  8:19 ` [PATCH net 2/4] vti6: Use vti6_dev_init " Steffen Klassert
2014-11-03  8:19 ` [PATCH net 3/4] sit: Use ipip6_tunnel_init " Steffen Klassert
2014-11-03  8:19 ` [PATCH net 4/4] gre6: Move the setting of dev->iflink into the ndo_init functions Steffen Klassert
2014-11-03 20:43 ` [PATCH net 0/4] ipv6: Fix iflink setting for ipv6 tunnels David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).