Commit c495d648 authored by David S. Miller's avatar David S. Miller

Merge branch 'ipv6_tunnel_iflink_init'

Steffen Klassert says:

====================
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.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 3ce9b20f f03eb128
...@@ -961,8 +961,6 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu) ...@@ -961,8 +961,6 @@ static void ip6gre_tnl_link_config(struct ip6_tnl *t, int set_mtu)
else else
dev->flags &= ~IFF_POINTOPOINT; dev->flags &= ~IFF_POINTOPOINT;
dev->iflink = p->link;
/* Precalculate GRE options length */ /* Precalculate GRE options length */
if (t->parms.o_flags&(GRE_CSUM|GRE_KEY|GRE_SEQ)) { if (t->parms.o_flags&(GRE_CSUM|GRE_KEY|GRE_SEQ)) {
if (t->parms.o_flags&GRE_CSUM) if (t->parms.o_flags&GRE_CSUM)
...@@ -1272,6 +1270,7 @@ static int ip6gre_tunnel_init(struct net_device *dev) ...@@ -1272,6 +1270,7 @@ static int ip6gre_tunnel_init(struct net_device *dev)
u64_stats_init(&ip6gre_tunnel_stats->syncp); u64_stats_init(&ip6gre_tunnel_stats->syncp);
} }
dev->iflink = tunnel->parms.link;
return 0; return 0;
} }
...@@ -1481,6 +1480,8 @@ static int ip6gre_tap_init(struct net_device *dev) ...@@ -1481,6 +1480,8 @@ static int ip6gre_tap_init(struct net_device *dev)
if (!dev->tstats) if (!dev->tstats)
return -ENOMEM; return -ENOMEM;
dev->iflink = tunnel->parms.link;
return 0; return 0;
} }
......
...@@ -272,9 +272,6 @@ static int ip6_tnl_create2(struct net_device *dev) ...@@ -272,9 +272,6 @@ static int ip6_tnl_create2(struct net_device *dev)
int err; int err;
t = netdev_priv(dev); t = netdev_priv(dev);
err = ip6_tnl_dev_init(dev);
if (err < 0)
goto out;
err = register_netdevice(dev); err = register_netdevice(dev);
if (err < 0) if (err < 0)
...@@ -1462,6 +1459,7 @@ ip6_tnl_change_mtu(struct net_device *dev, int new_mtu) ...@@ -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 = { static const struct net_device_ops ip6_tnl_netdev_ops = {
.ndo_init = ip6_tnl_dev_init,
.ndo_uninit = ip6_tnl_dev_uninit, .ndo_uninit = ip6_tnl_dev_uninit,
.ndo_start_xmit = ip6_tnl_xmit, .ndo_start_xmit = ip6_tnl_xmit,
.ndo_do_ioctl = ip6_tnl_ioctl, .ndo_do_ioctl = ip6_tnl_ioctl,
...@@ -1546,16 +1544,10 @@ static int __net_init ip6_fb_tnl_dev_init(struct net_device *dev) ...@@ -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 ip6_tnl *t = netdev_priv(dev);
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
struct ip6_tnl_net *ip6n = net_generic(net, ip6_tnl_net_id); 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; t->parms.proto = IPPROTO_IPV6;
dev_hold(dev); dev_hold(dev);
ip6_tnl_link_config(t);
rcu_assign_pointer(ip6n->tnls_wc[0], t); rcu_assign_pointer(ip6n->tnls_wc[0], t);
return 0; return 0;
} }
......
...@@ -172,10 +172,6 @@ static int vti6_tnl_create2(struct net_device *dev) ...@@ -172,10 +172,6 @@ static int vti6_tnl_create2(struct net_device *dev)
struct vti6_net *ip6n = net_generic(net, vti6_net_id); struct vti6_net *ip6n = net_generic(net, vti6_net_id);
int err; int err;
err = vti6_dev_init(dev);
if (err < 0)
goto out;
err = register_netdevice(dev); err = register_netdevice(dev);
if (err < 0) if (err < 0)
goto out; goto out;
...@@ -783,6 +779,7 @@ static int vti6_change_mtu(struct net_device *dev, int new_mtu) ...@@ -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 = { static const struct net_device_ops vti6_netdev_ops = {
.ndo_init = vti6_dev_init,
.ndo_uninit = vti6_dev_uninit, .ndo_uninit = vti6_dev_uninit,
.ndo_start_xmit = vti6_tnl_xmit, .ndo_start_xmit = vti6_tnl_xmit,
.ndo_do_ioctl = vti6_ioctl, .ndo_do_ioctl = vti6_ioctl,
...@@ -852,16 +849,10 @@ static int __net_init vti6_fb_tnl_dev_init(struct net_device *dev) ...@@ -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 ip6_tnl *t = netdev_priv(dev);
struct net *net = dev_net(dev); struct net *net = dev_net(dev);
struct vti6_net *ip6n = net_generic(net, vti6_net_id); 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; t->parms.proto = IPPROTO_IPV6;
dev_hold(dev); dev_hold(dev);
vti6_link_config(t);
rcu_assign_pointer(ip6n->tnls_wc[0], t); rcu_assign_pointer(ip6n->tnls_wc[0], t);
return 0; return 0;
} }
......
...@@ -195,10 +195,8 @@ static int ipip6_tunnel_create(struct net_device *dev) ...@@ -195,10 +195,8 @@ static int ipip6_tunnel_create(struct net_device *dev)
struct sit_net *sitn = net_generic(net, sit_net_id); struct sit_net *sitn = net_generic(net, sit_net_id);
int err; int err;
err = ipip6_tunnel_init(dev); memcpy(dev->dev_addr, &t->parms.iph.saddr, 4);
if (err < 0) memcpy(dev->broadcast, &t->parms.iph.daddr, 4);
goto out;
ipip6_tunnel_clone_6rd(dev, sitn);
if ((__force u16)t->parms.i_flags & SIT_ISATAP) if ((__force u16)t->parms.i_flags & SIT_ISATAP)
dev->priv_flags |= IFF_ISATAP; dev->priv_flags |= IFF_ISATAP;
...@@ -207,7 +205,8 @@ static int ipip6_tunnel_create(struct net_device *dev) ...@@ -207,7 +205,8 @@ static int ipip6_tunnel_create(struct net_device *dev)
if (err < 0) if (err < 0)
goto out; goto out;
strcpy(t->parms.name, dev->name); ipip6_tunnel_clone_6rd(dev, sitn);
dev->rtnl_link_ops = &sit_link_ops; dev->rtnl_link_ops = &sit_link_ops;
dev_hold(dev); dev_hold(dev);
...@@ -1330,6 +1329,7 @@ static int ipip6_tunnel_change_mtu(struct net_device *dev, int new_mtu) ...@@ -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 = { static const struct net_device_ops ipip6_netdev_ops = {
.ndo_init = ipip6_tunnel_init,
.ndo_uninit = ipip6_tunnel_uninit, .ndo_uninit = ipip6_tunnel_uninit,
.ndo_start_xmit = sit_tunnel_xmit, .ndo_start_xmit = sit_tunnel_xmit,
.ndo_do_ioctl = ipip6_tunnel_ioctl, .ndo_do_ioctl = ipip6_tunnel_ioctl,
...@@ -1378,9 +1378,7 @@ static int ipip6_tunnel_init(struct net_device *dev) ...@@ -1378,9 +1378,7 @@ static int ipip6_tunnel_init(struct net_device *dev)
tunnel->dev = dev; tunnel->dev = dev;
tunnel->net = dev_net(dev); tunnel->net = dev_net(dev);
strcpy(tunnel->parms.name, dev->name);
memcpy(dev->dev_addr, &tunnel->parms.iph.saddr, 4);
memcpy(dev->broadcast, &tunnel->parms.iph.daddr, 4);
ipip6_tunnel_bind_dev(dev); ipip6_tunnel_bind_dev(dev);
dev->tstats = netdev_alloc_pcpu_stats(struct pcpu_sw_netstats); 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) ...@@ -1405,7 +1403,6 @@ static int __net_init ipip6_fb_tunnel_init(struct net_device *dev)
tunnel->dev = dev; tunnel->dev = dev;
tunnel->net = dev_net(dev); tunnel->net = dev_net(dev);
strcpy(tunnel->parms.name, dev->name);
iph->version = 4; iph->version = 4;
iph->protocol = IPPROTO_IPV6; iph->protocol = IPPROTO_IPV6;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment