[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>

authored by David L Stevens and committed by David S. Miller 30c4cf57 0d630cc0

+5 -4
+3 -2
net/ipv4/devinet.c
··· 165 NET_IPV4_NEIGH, "ipv4", NULL, NULL); 166 #endif 167 168 - /* Account for reference dev->ip_ptr */ 169 in_dev_hold(in_dev); 170 - rcu_assign_pointer(dev->ip_ptr, in_dev); 171 172 #ifdef CONFIG_SYSCTL 173 devinet_sysctl_register(in_dev, &in_dev->cnf); ··· 175 if (dev->flags & IFF_UP) 176 ip_mc_up(in_dev); 177 out: 178 return in_dev; 179 out_kfree: 180 kfree(in_dev);
··· 165 NET_IPV4_NEIGH, "ipv4", NULL, NULL); 166 #endif 167 168 + /* Account for reference dev->ip_ptr (below) */ 169 in_dev_hold(in_dev); 170 171 #ifdef CONFIG_SYSCTL 172 devinet_sysctl_register(in_dev, &in_dev->cnf); ··· 176 if (dev->flags & IFF_UP) 177 ip_mc_up(in_dev); 178 out: 179 + /* we can receive as soon as ip_ptr is set -- do this last */ 180 + rcu_assign_pointer(dev->ip_ptr, in_dev); 181 return in_dev; 182 out_kfree: 183 kfree(in_dev);
+2 -2
net/ipv6/addrconf.c
··· 413 if (netif_carrier_ok(dev)) 414 ndev->if_flags |= IF_READY; 415 416 - /* protected by rtnl_lock */ 417 - rcu_assign_pointer(dev->ip6_ptr, ndev); 418 419 ipv6_mc_init_dev(ndev); 420 ndev->tstamp = jiffies; ··· 423 NULL); 424 addrconf_sysctl_register(ndev, &ndev->cnf); 425 #endif 426 return ndev; 427 } 428
··· 413 if (netif_carrier_ok(dev)) 414 ndev->if_flags |= IF_READY; 415 416 417 ipv6_mc_init_dev(ndev); 418 ndev->tstamp = jiffies; ··· 425 NULL); 426 addrconf_sysctl_register(ndev, &ndev->cnf); 427 #endif 428 + /* protected by rtnl_lock */ 429 + rcu_assign_pointer(dev->ip6_ptr, ndev); 430 return ndev; 431 } 432