From fdd8224884cbc92dd6e42f617018625f6a6d4c96 Mon Sep 17 00:00:00 2001 From: Jesse Gross Date: Tue, 13 Apr 2010 13:57:40 -0400 Subject: [PATCH] netdev: Add function netdev_is_open(). 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 | 8 ++++++++ lib/netdev.h | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/netdev.c b/lib/netdev.c index af2382d3..d8fd7e44 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -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) diff --git a/lib/netdev.h b/lib/netdev.h index 27eb82e5..63414aee 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -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 *); -- 2.30.2