veth: Fix problems removing veth devices
authorJustin Pettit <jpettit@nicira.com>
Tue, 13 Apr 2010 22:53:37 +0000 (15:53 -0700)
committerJustin Pettit <jpettit@nicira.com>
Thu, 15 Apr 2010 03:53:15 +0000 (20:53 -0700)
When a user tried to delete a veth device through sysfs, the driver
wasn't properly parsing the device name.  Also, it called
dev_get_by_name(), which increments a refcount on the device, but didn't
make a dev_put() before trying to delete it.

datapath/linux-2.6/compat-2.6/veth.c

index e609c627a83b617ec4ac646919570890528ad28b..66aae0b9387cffff596a169fab489459ac80ea57 100644 (file)
@@ -454,10 +454,13 @@ static ssize_t veth_store_veth_pairs(struct class *cls, const char *buffer,
                rtnl_unlock();
                return retval ? retval : count;
        } else if (c == '-') {
+               char devname[IFNAMSIZ + 1] = "";
                struct net_device *dev;
 
+               strncat(devname, buffer,
+                       min_t(int, sizeof devname, strcspn(buffer, "\n")));
                rtnl_lock();
-               dev = dev_get_by_name(buffer);
+               dev = __dev_get_by_name(devname);
                if (!dev)
                        retval = -ENODEV;
                else if (dev->init != veth_dev_init)