]> bbs.cooldavid.org Git - net-next-2.6.git/blobdiff - net/ipv6/addrconf.c
[IPV4/IPV6]: Fail registration if inet device construction fails
[net-next-2.6.git] / net / ipv6 / addrconf.c
index 24424c3b7dc0e5918bb0b35295db8f73d0ee7591..91ef3be5abadeab0b778dfaba86cce6b440c3362 100644 (file)
@@ -2256,14 +2256,14 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
        struct net_device *dev = (struct net_device *) data;
        struct inet6_dev *idev = __in6_dev_get(dev);
        int run_pending = 0;
+       int err;
 
        switch(event) {
        case NETDEV_REGISTER:
                if (!idev && dev->mtu >= IPV6_MIN_MTU) {
                        idev = ipv6_add_dev(dev);
                        if (!idev)
-                               printk(KERN_WARNING "IPv6: add_dev failed for %s\n",
-                                       dev->name);
+                               return notifier_from_errno(-ENOMEM);
                }
                break;
        case NETDEV_UP:
@@ -2373,7 +2373,9 @@ static int addrconf_notify(struct notifier_block *this, unsigned long event,
                                              NULL);
                        addrconf_sysctl_register(idev, &idev->cnf);
 #endif
-                       snmp6_register_dev(idev);
+                       err = snmp6_register_dev(idev);
+                       if (err)
+                               return notifier_from_errno(err);
                }
                break;
        }
@@ -2475,6 +2477,7 @@ static int addrconf_ifdown(struct net_device *dev, int how)
                write_unlock_bh(&idev->lock);
 
                __ipv6_ifa_notify(RTM_DELADDR, ifa);
+               atomic_notifier_call_chain(&inet6addr_chain, NETDEV_DOWN, ifa);
                in6_ifa_put(ifa);
 
                write_lock_bh(&idev->lock);