netns: fix addrconf_ifdown kernel panic

When a network namespace is destroyed the network interfaces are
all unregistered, making addrconf_ifdown called by the netdevice
notifier. 
In the other hand, the addrconf exit method does a loop on the network
devices and does addrconf_ifdown on each of them. But the ordering of 
the netns subsystem is not right because it uses the register_pernet_device
instead of register_pernet_subsys. If we handle the loopback as
any network device, we can safely use register_pernet_subsys.

But if we use register_pernet_subsys, the addrconf exit method will do
exactly what was already done with the unregistering of the network
devices. So in definitive, this code is pointless.

I removed the netns addrconf exit method and moved the code to the
addrconf cleanup function.

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Daniel Lezcano 2009-03-03 01:06:45 -08:00 committed by David S. Miller
parent b325fddb7f
commit 176c39af29

View file

@ -2611,9 +2611,6 @@ static int addrconf_ifdown(struct net_device *dev, int how)
ASSERT_RTNL();
if ((dev->flags & IFF_LOOPBACK) && how == 1)
how = 0;
rt6_ifdown(net, dev);
neigh_ifdown(&nd_tbl, dev);
@ -4448,25 +4445,6 @@ int unregister_inet6addr_notifier(struct notifier_block *nb)
EXPORT_SYMBOL(unregister_inet6addr_notifier);
static void addrconf_net_exit(struct net *net)
{
struct net_device *dev;
rtnl_lock();
/* clean dev list */
for_each_netdev(net, dev) {
if (__in6_dev_get(dev) == NULL)
continue;
addrconf_ifdown(dev, 1);
}
addrconf_ifdown(net->loopback_dev, 2);
rtnl_unlock();
}
static struct pernet_operations addrconf_net_ops = {
.exit = addrconf_net_exit,
};
/*
* Init / cleanup code
*/
@ -4508,10 +4486,6 @@ int __init addrconf_init(void)
if (err)
goto errlo;
err = register_pernet_device(&addrconf_net_ops);
if (err)
return err;
register_netdevice_notifier(&ipv6_dev_notf);
addrconf_verify(0);
@ -4541,15 +4515,22 @@ errlo:
void addrconf_cleanup(void)
{
struct inet6_ifaddr *ifa;
struct net_device *dev;
int i;
unregister_netdevice_notifier(&ipv6_dev_notf);
unregister_pernet_device(&addrconf_net_ops);
unregister_pernet_subsys(&addrconf_ops);
rtnl_lock();
/* clean dev list */
for_each_netdev(&init_net, dev) {
if (__in6_dev_get(dev) == NULL)
continue;
addrconf_ifdown(dev, 1);
}
addrconf_ifdown(init_net.loopback_dev, 2);
/*
* Check hash table.
*/
@ -4570,6 +4551,4 @@ void addrconf_cleanup(void)
del_timer(&addr_chk_timer);
rtnl_unlock();
unregister_pernet_subsys(&addrconf_net_ops);
}