[IPV4/IPV6]: Fix inet{,6} device initialization order.
It is important that we only assign dev->ip{,6}_ptr only after all portions of the inet{,6} are setup. Otherwise we can receive packets before the multicast spinlocks et al. are initialized. Signed-off-by: David L Stevens <dlstevens@us.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
0d630cc0a6
commit
30c4cf577f
2 changed files with 5 additions and 4 deletions
|
@ -165,9 +165,8 @@ struct in_device *inetdev_init(struct net_device *dev)
|
||||||
NET_IPV4_NEIGH, "ipv4", NULL, NULL);
|
NET_IPV4_NEIGH, "ipv4", NULL, NULL);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Account for reference dev->ip_ptr */
|
/* Account for reference dev->ip_ptr (below) */
|
||||||
in_dev_hold(in_dev);
|
in_dev_hold(in_dev);
|
||||||
rcu_assign_pointer(dev->ip_ptr, in_dev);
|
|
||||||
|
|
||||||
#ifdef CONFIG_SYSCTL
|
#ifdef CONFIG_SYSCTL
|
||||||
devinet_sysctl_register(in_dev, &in_dev->cnf);
|
devinet_sysctl_register(in_dev, &in_dev->cnf);
|
||||||
|
@ -176,6 +175,8 @@ struct in_device *inetdev_init(struct net_device *dev)
|
||||||
if (dev->flags & IFF_UP)
|
if (dev->flags & IFF_UP)
|
||||||
ip_mc_up(in_dev);
|
ip_mc_up(in_dev);
|
||||||
out:
|
out:
|
||||||
|
/* we can receive as soon as ip_ptr is set -- do this last */
|
||||||
|
rcu_assign_pointer(dev->ip_ptr, in_dev);
|
||||||
return in_dev;
|
return in_dev;
|
||||||
out_kfree:
|
out_kfree:
|
||||||
kfree(in_dev);
|
kfree(in_dev);
|
||||||
|
|
|
@ -413,8 +413,6 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
|
||||||
if (netif_carrier_ok(dev))
|
if (netif_carrier_ok(dev))
|
||||||
ndev->if_flags |= IF_READY;
|
ndev->if_flags |= IF_READY;
|
||||||
|
|
||||||
/* protected by rtnl_lock */
|
|
||||||
rcu_assign_pointer(dev->ip6_ptr, ndev);
|
|
||||||
|
|
||||||
ipv6_mc_init_dev(ndev);
|
ipv6_mc_init_dev(ndev);
|
||||||
ndev->tstamp = jiffies;
|
ndev->tstamp = jiffies;
|
||||||
|
@ -425,6 +423,8 @@ static struct inet6_dev * ipv6_add_dev(struct net_device *dev)
|
||||||
NULL);
|
NULL);
|
||||||
addrconf_sysctl_register(ndev, &ndev->cnf);
|
addrconf_sysctl_register(ndev, &ndev->cnf);
|
||||||
#endif
|
#endif
|
||||||
|
/* protected by rtnl_lock */
|
||||||
|
rcu_assign_pointer(dev->ip6_ptr, ndev);
|
||||||
return ndev;
|
return ndev;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue