]> err.no Git - linux-2.6/blobdiff - drivers/net/bonding/bond_sysfs.c
bonding: Relax unneeded _safe lists iterations.
[linux-2.6] / drivers / net / bonding / bond_sysfs.c
index 90a1f31e8e637bd104a09490b8d05db80b0b5acc..1f028579e53bd8d1da2db99be549734d0577f396 100644 (file)
@@ -111,7 +111,6 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
        char *ifname;
        int rv, res = count;
        struct bonding *bond;
-       struct bonding *nxt;
 
        sscanf(buffer, "%16s", command); /* IFNAMSIZ*/
        ifname = command + 1;
@@ -122,7 +121,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
        if (command[0] == '+') {
                printk(KERN_INFO DRV_NAME
                        ": %s is being created...\n", ifname);
-               rv = bond_create(ifname, &bonding_defaults, &bond);
+               rv = bond_create(ifname, &bonding_defaults);
                if (rv) {
                        printk(KERN_INFO DRV_NAME ": Bond creation failed.\n");
                        res = rv;
@@ -134,7 +133,7 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
                rtnl_lock();
                down_write(&bonding_rwsem);
 
-               list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list)
+               list_for_each_entry(bond, &bond_dev_list, bond_list)
                        if (strnicmp(bond->dev->name, ifname, IFNAMSIZ) == 0) {
                                /* check the ref count on the bond's kobject.
                                 * If it's > expected, then there's a file open,
@@ -146,29 +145,29 @@ static ssize_t bonding_store_bonds(struct class *cls, const char *buffer, size_t
                                                ": Unable remove bond %s due to open references.\n",
                                                ifname);
                                        res = -EPERM;
-                                       goto out;
+                                       goto out_unlock;
                                }
                                printk(KERN_INFO DRV_NAME
                                        ": %s is being deleted...\n",
                                        bond->dev->name);
                                bond_destroy(bond);
-                               up_write(&bonding_rwsem);
-                               rtnl_unlock();
-                               goto out;
+                               goto out_unlock;
                        }
 
                printk(KERN_ERR DRV_NAME
                        ": unable to delete non-existent bond %s\n", ifname);
                res = -ENODEV;
-               up_write(&bonding_rwsem);
-               rtnl_unlock();
-               goto out;
+               goto out_unlock;
        }
 
 err_no_cmd:
        printk(KERN_ERR DRV_NAME
                ": no command found in bonding_masters. Use +ifname or -ifname.\n");
-       res = -EPERM;
+       return -EPERM;
+
+out_unlock:
+       up_write(&bonding_rwsem);
+       rtnl_unlock();
 
        /* Always return either count or an error.  If you return 0, you'll
         * get called forever, which is bad.
@@ -341,6 +340,7 @@ static ssize_t bonding_store_slaves(struct device *d,
 
        if (command[0] == '-') {
                dev = NULL;
+               original_mtu = 0;
                bond_for_each_slave(bond, slave, i)
                        if (strnicmp(slave->dev->name, ifname, IFNAMSIZ) == 0) {
                                dev = slave->dev;
@@ -1436,8 +1436,16 @@ int bond_create_sysfs(void)
         * configure multiple bonding devices.
         */
        if (ret == -EEXIST) {
-               netdev_class = NULL;
-               return 0;
+               /* Is someone being kinky and naming a device bonding_master? */
+               if (__dev_get_by_name(&init_net,
+                                     class_attr_bonding_masters.attr.name))
+                       printk(KERN_ERR
+                              "network device named %s already exists in sysfs",
+                              class_attr_bonding_masters.attr.name);
+               else {
+                       netdev_class = NULL;
+                       return 0;
+               }
        }
 
        return ret;