ipv6: Fix iflink setting for ipv6 tunnels
Subsystems (4)
Steffen Klassert
maintainerPATCH 2/4 vti6: Use vti6_dev_init as the ndo_init function.
In reply to Steffen Klassertvti6_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().
--- net/ipv6/ip6_vti.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
net/ipv6/ip6_vti.c +1 -10
@@ -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 ; }
Signature · 1 line
1.9.1
Steffen Klassert
maintainerPATCH 3/4 sit: Use ipip6_tunnel_init as the ndo_init function.
In reply to Steffen Klassertipip6_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().
--- net/ipv6/sit.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-)
net/ipv6/sit.c +6 -9
@@ -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 ;
Signature · 1 line
1.9.1
Steffen Klassert
maintainerPATCH 1/4 ip6_tunnel: Use ip6_tnl_dev_init as the ndo_init function.
In reply to Steffen Klassertip6_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().
--- net/ipv6/ip6_tunnel.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-)
net/ipv6/ip6_tunnel.c +1 -9
@@ -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 ; }
Signature · 1 line
1.9.1
Steffen Klassert
maintainercover ipv6: Fix iflink setting for ipv6 tunnels
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.
Steffen Klassert
maintainerPATCH 4/4 gre6: Move the setting of dev->iflink into the ndo_init functions.
Otherwise it gets overwritten by register_netdev().
--- net/ipv6/ip6_gre.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
net/ipv6/ip6_gre.c +3 -2
@@ -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 ; }
Signature · 1 line
1.9.1
David Miller
maintainerFrom: Steffen Klassert <[email protected]>
Date: Mon, 3 Nov 2014 09:19:26 +0100
Quoted 5 lines
The ipv6 tunnels do the
dev->iflinksetting too early, it gets overwritten byregister_netdev(). So setdev->iflinkfrom within ando_initfunction 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.