struct netdev *base_dev = netdev_from_name(change->ifname);
if (base_dev && is_netdev_linux_class(netdev_get_class(base_dev))) {
netdev_linux_update(netdev_linux_cast(base_dev), change);
+ netdev_close(base_dev);
}
} else {
struct shash device_shash;
/* Returns the netdev with 'name' or NULL if there is none.
*
- * The caller must not free the returned value. */
+ * The caller must free the returned netdev with netdev_close(). */
struct netdev *
netdev_from_name(const char *name)
{
- return shash_find_data(&netdev_shash, name);
+ struct netdev *netdev;
+
+ netdev = shash_find_data(&netdev_shash, name);
+ if (netdev) {
+ netdev_ref(netdev);
+ }
+
+ return netdev;
}
/* Fills 'device_list' with devices that match 'netdev_class'.
const char *
netdev_get_type_from_name(const char *name)
{
- const struct netdev *dev = netdev_from_name(name);
- return dev ? netdev_get_type(dev) : NULL;
+ struct netdev *dev = netdev_from_name(name);
+ const char *type = dev ? netdev_get_type(dev) : NULL;
+ netdev_close(dev);
+ return type;
}
\f
void