Since dpif_netdev_enumerate() is used for "netdev" and "dummy" class, it
incorrectly lists dpif-netdevs as "dummy" and vice versa.
This patches address the issue by changing the dpif-provider interface: a
dpif_class parameter is passed to the 'enumerate' call to match the right class.

Signed-off-by: Daniele Di Proietto <ddiproie...@vmware.com>
---
 lib/dpif-linux.c    | 3 ++-
 lib/dpif-netdev.c   | 8 +++++++-
 lib/dpif-provider.h | 9 +++++----
 lib/dpif.c          | 4 +++-
 4 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/lib/dpif-linux.c b/lib/dpif-linux.c
index 63e66f3..afe9340 100644
--- a/lib/dpif-linux.c
+++ b/lib/dpif-linux.c
@@ -195,7 +195,8 @@ dpif_linux_cast(const struct dpif *dpif)
 }
 
 static int
-dpif_linux_enumerate(struct sset *all_dps)
+dpif_linux_enumerate(struct sset *all_dps,
+                     const struct dpif_class *dpif_class OVS_UNUSED)
 {
     struct nl_dump dump;
     uint64_t reply_stub[NL_DUMP_BUFSIZE / 8];
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 27fe4fc..6cd2c14 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -360,12 +360,18 @@ get_dp_netdev(const struct dpif *dpif)
 }
 
 static int
-dpif_netdev_enumerate(struct sset *all_dps)
+dpif_netdev_enumerate(struct sset *all_dps, const struct dpif_class 
*dpif_class)
 {
     struct shash_node *node;
 
     ovs_mutex_lock(&dp_netdev_mutex);
     SHASH_FOR_EACH(node, &dp_netdevs) {
+        struct dp_netdev *dp = node->data;
+        if (dpif_class != dp->class) {
+            /* 'dp_netdevs' contains both "netdev" and "dummy" dpifs.
+             * if the class doesn't match, skip this dpif */
+             continue;
+        }
         sset_add(all_dps, node->name);
     }
     ovs_mutex_unlock(&dp_netdev_mutex);
diff --git a/lib/dpif-provider.h b/lib/dpif-provider.h
index d0b2eaf..b762ac0 100644
--- a/lib/dpif-provider.h
+++ b/lib/dpif-provider.h
@@ -89,16 +89,17 @@ struct dpif_class {
      * the type assumed if no type is specified when opening a dpif. */
     const char *type;
 
-    /* Enumerates the names of all known created datapaths, if possible, into
-     * 'all_dps'.  The caller has already initialized 'all_dps' and other dpif
-     * classes might already have added names to it.
+    /* Enumerates the names of all known created datapaths (of class
+     * 'dpif_class'), if possible, into 'all_dps'.  The caller has already
+     * initialized 'all_dps' and other dpif classes might already have added
+     * names to it.
      *
      * This is used by the vswitch at startup, so that it can delete any
      * datapaths that are not configured.
      *
      * Some kinds of datapaths might not be practically enumerable, in which
      * case this function may be a null pointer. */
-    int (*enumerate)(struct sset *all_dps);
+    int (*enumerate)(struct sset *all_dps, const struct dpif_class 
*dpif_class);
 
     /* Returns the type to pass to netdev_open() when a dpif of class
      * 'dpif_class' has a port of type 'type', for a few special cases
diff --git a/lib/dpif.c b/lib/dpif.c
index ac73be1..c5d31f6 100644
--- a/lib/dpif.c
+++ b/lib/dpif.c
@@ -272,7 +272,9 @@ dp_enumerate_names(const char *type, struct sset *names)
     }
 
     dpif_class = registered_class->dpif_class;
-    error = dpif_class->enumerate ? dpif_class->enumerate(names) : 0;
+    error = dpif_class->enumerate
+            ? dpif_class->enumerate(names, dpif_class)
+            : 0;
     if (error) {
         VLOG_WARN("failed to enumerate %s datapaths: %s", dpif_class->type,
                    ovs_strerror(error));
-- 
2.0.0

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to