mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 21:44:06 +08:00
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: David S. Miller <davem@davemloft.net>
This commit is contained in:
commit
c495d64836
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user