netdev: Add function netdev_is_open().
authorJesse Gross <jesse@nicira.com>
Tue, 13 Apr 2010 17:57:40 +0000 (13:57 -0400)
committerJesse Gross <jesse@nicira.com>
Mon, 19 Apr 2010 13:11:57 +0000 (09:11 -0400)
Add netdev_is_open(), which checks to see if a given netdev is
currently open.  It will be used to assist in cleaning up old ports
that are no longer in use.

lib/netdev.c
lib/netdev.h

index af2382d..d8fd7e4 100644 (file)
@@ -435,6 +435,14 @@ netdev_exists(const char *name)
     }
 }
 
+/* Returns true if a network device named 'name' is currently opened,
+ * otherwise false. */
+bool
+netdev_is_open(const char *name)
+{
+    return !!shash_find_data(&netdev_dev_shash, name);
+}
+
 /*  Clears 'svec' and enumerates the names of all known network devices. */
 int
 netdev_enumerate(struct svec *svec)
index 27eb82e..63414ae 100644 (file)
@@ -105,6 +105,7 @@ int netdev_reconfigure(struct netdev *, const struct shash *args);
 void netdev_close(struct netdev *);
 
 bool netdev_exists(const char *name);
+bool netdev_is_open(const char *name);
 
 int netdev_enumerate(struct svec *);