proper destruction of netdev datapaths
[sliver-openvswitch.git] / lib / dpif-netdev.c
index c71bd6e..fb23fa3 100644 (file)
@@ -165,6 +165,17 @@ get_dp_netdev(const struct dpif *dpif)
     return dpif_netdev_cast(dpif)->dp;
 }
 
+static int
+dpif_netdev_enumerate(struct sset *all_dps)
+{
+    struct shash_node *node;
+
+    SHASH_FOR_EACH(node, &dp_netdevs) {
+        sset_add(all_dps, node->name);        
+    }
+    return 0;    
+}
+
 static struct dpif *
 create_dpif_netdev(struct dp_netdev *dp)
 {
@@ -306,6 +317,8 @@ static const char* internal_port_type(const struct dp_netdev* dp)
 {
        if (dp->class == &dpif_netdev_class)
                return "tap";
+       if (dp->class == &dpif_planetlab_class)
+               return "tap_pl";
        return "dummy";
 }
 
@@ -367,7 +380,9 @@ choose_port(struct dpif *dpif, struct netdev *netdev)
     struct dp_netdev *dp = get_dp_netdev(dpif);
     int port_no;
 
-    if (dpif->dpif_class != &dpif_netdev_class) {
+    if (dpif->dpif_class != &dpif_netdev_class &&
+        dpif->dpif_class != &dpif_planetlab_class)
+    {
         /* If the port name contains a number, try to assign that port number.
          * This can make writing unit tests easier because port numbers are
          * predictable. */
@@ -1245,7 +1260,7 @@ dp_netdev_execute_actions(struct dp_netdev *dp,
 }
 
 #define DPIF_NETDEV_CLASS_FUNCTIONS                    \
-    NULL,                       /* enumerate */                \
+    dpif_netdev_enumerate,                             \
     dpif_netdev_open,                                  \
     dpif_netdev_close,                                 \
     dpif_netdev_destroy,                               \
@@ -1283,6 +1298,11 @@ const struct dpif_class dpif_netdev_class = {
     DPIF_NETDEV_CLASS_FUNCTIONS
 };
 
+const struct dpif_class dpif_planetlab_class = {
+    "planetlab",
+    DPIF_NETDEV_CLASS_FUNCTIONS
+};
+
 static void
 dpif_dummy_register__(const char *type)
 {