X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fnetdev.c;h=d5a51fa0ea90b91b4524c47859cf8105776bac73;hb=7aaeab4df24b7e9460705b1dad1010eef0354c50;hp=25615380f4febd7cbc5e35ac6f60e0549d12e91e;hpb=2f980d741737fd3296d8063d800753a2d77bd730;p=sliver-openvswitch.git diff --git a/lib/netdev.c b/lib/netdev.c index 25615380f..d5a51fa0e 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -89,6 +89,8 @@ netdev_initialize(void) netdev_register_provider(&netdev_tap_class); netdev_register_provider(&netdev_bsd_class); #endif + netdev_register_provider(&netdev_tunnel_class); + netdev_register_provider(&netdev_pltap_class); } } @@ -1386,11 +1388,18 @@ netdev_get_class(const struct netdev *netdev) /* 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'. @@ -1415,8 +1424,10 @@ netdev_get_devices(const struct netdev_class *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; } void