[ovs-dev] [netlink v5 60/61] dpif: Remove dpif_get_all_names().

Ben Pfaff blp at nicira.com
Thu Jan 27 00:23:43 UTC 2011


None of the remaining dpif implementations have more than one name per
dpif, so there's no need for this function anymore.

Suggested-by: Jesse Gross <jesse at nicira.com>
Acked-by: Jesse Gross <jesse at nicira.com>
---
 lib/dpif-linux.c    |    1 -
 lib/dpif-netdev.c   |    1 -
 lib/dpif-provider.h |   17 -----------------
 lib/dpif.c          |   27 ---------------------------
 lib/dpif.h          |    1 -
 vswitchd/bridge.c   |   32 ++++++++++----------------------
 6 files changed, 10 insertions(+), 69 deletions(-)

diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index dc59fe0..f08a258 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -912,7 +912,6 @@ const struct dpif_class dpif_linux_class = {
     dpif_linux_enumerate,
     dpif_linux_open,
     dpif_linux_close,
-    NULL,                       /* get_all_names */
     dpif_linux_destroy,
     dpif_linux_get_stats,
     dpif_linux_get_drop_frags,
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 6b2df7d..5f72208 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -1412,7 +1412,6 @@ const struct dpif_class dpif_netdev_class = {
     NULL,                       /* enumerate */
     dpif_netdev_open,
     dpif_netdev_close,
-    NULL,                       /* get_all_names */
     dpif_netdev_destroy,
     dpif_netdev_get_stats,
     dpif_netdev_get_drop_frags,
diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
index 98a890a..61bc872 100644
--- a/lib/dpif-provider.h
+++ b/lib/dpif-provider.h
@@ -102,23 +102,6 @@ struct dpif_class {
     /* Closes 'dpif' and frees associated memory. */
     void (*close)(struct dpif *dpif);
 
-    /* Enumerates all names that may be used to open 'dpif' into 'all_names'.
-     * The Linux datapath, for example, supports opening a datapath both by
-     * number, e.g. "dp0", and by the name of the datapath's local port.  For
-     * some datapaths, this might be an infinite set (e.g. in a file name,
-     * slashes may be duplicated any number of times), in which case only the
-     * names most likely to be used should be enumerated.
-     *
-     * The caller has already initialized 'all_names' and might already have
-     * added some names to it.  This function should not disturb any existing
-     * names in 'all_names'.
-     *
-     * If a datapath class does not support multiple names for a datapath, this
-     * function may be a null pointer.
-     *
-     * This is used by the vswitch at startup, */
-    int (*get_all_names)(const struct dpif *dpif, struct svec *all_names);
-
     /* Attempts to destroy the dpif underlying 'dpif'.
      *
      * If successful, 'dpif' will not be used again except as an argument for
diff --git a/lib/dpif.c b/lib/dpif.c
index 3afc992..3a705b9 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -363,33 +363,6 @@ dpif_base_name(const struct dpif *dpif)
     return dpif->base_name;
 }
 
-/* Enumerates all names that may be used to open 'dpif' into 'all_names'.  The
- * Linux datapath, for example, supports opening a datapath both by number,
- * e.g. "dp0", and by the name of the datapath's local port.  For some
- * datapaths, this might be an infinite set (e.g. in a file name, slashes may
- * be duplicated any number of times), in which case only the names most likely
- * to be used will be enumerated.
- *
- * The caller must already have initialized 'all_names'.  Any existing names in
- * 'all_names' will not be disturbed. */
-int
-dpif_get_all_names(const struct dpif *dpif, struct svec *all_names)
-{
-    if (dpif->dpif_class->get_all_names) {
-        int error = dpif->dpif_class->get_all_names(dpif, all_names);
-        if (error) {
-            VLOG_WARN_RL(&error_rl,
-                         "failed to retrieve names for datpath %s: %s",
-                         dpif_name(dpif), strerror(error));
-        }
-        return error;
-    } else {
-        svec_add(all_names, dpif_base_name(dpif));
-        return 0;
-    }
-}
-
-
 /* Destroys the datapath that 'dpif' is connected to, first removing all of its
  * ports.  After calling this function, it does not make sense to pass 'dpif'
  * to any functions other than dpif_name() or dpif_close(). */
diff --git a/lib/dpif.h b/lib/dpif.h
index d25d20f..f5b7493 100644
--- a/lib/dpif.h
+++ b/lib/dpif.h
@@ -54,7 +54,6 @@ void dpif_close(struct dpif *);
 
 const char *dpif_name(const struct dpif *);
 const char *dpif_base_name(const struct dpif *);
-int dpif_get_all_names(const struct dpif *, struct svec *);
 
 int dpif_delete(struct dpif *);
 
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index c69557b..463a8b5 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -373,34 +373,22 @@ bridge_configure_once(const struct ovsrec_open_vswitch *cfg)
     svec_init(&dpif_types);
     dp_enumerate_types(&dpif_types);
     for (i = 0; i < dpif_types.n; i++) {
-        struct dpif *dpif;
-        int retval;
         size_t j;
 
         dp_enumerate_names(dpif_types.names[i], &dpif_names);
 
-        /* For each dpif... */
+        /* Delete each dpif whose name is not in 'bridge_names'. */
         for (j = 0; j < dpif_names.n; j++) {
-            retval = dpif_open(dpif_names.names[j], dpif_types.names[i], &dpif);
-            if (!retval) {
-                struct svec all_names;
-                size_t k;
-
-                /* ...check whether any of its names is in 'bridge_names'. */
-                svec_init(&all_names);
-                dpif_get_all_names(dpif, &all_names);
-                for (k = 0; k < all_names.n; k++) {
-                    if (svec_contains(&bridge_names, all_names.names[k])) {
-                        goto found;
-                    }
+            if (!svec_contains(&bridge_names, dpif_names.names[j])) {
+                struct dpif *dpif;
+                int retval;
+
+                retval = dpif_open(dpif_names.names[j], dpif_types.names[i],
+                                   &dpif);
+                if (!retval) {
+                    dpif_delete(dpif);
+                    dpif_close(dpif);
                 }
-
-                /* No.  Delete the dpif. */
-                dpif_delete(dpif);
-
-            found:
-                svec_destroy(&all_names);
-                dpif_close(dpif);
             }
         }
     }
-- 
1.7.1





More information about the dev mailing list