netdev-vport: Build on all platforms.
[sliver-openvswitch.git] / lib / dpif-linux.c
index c7a0746..b6eba39 100644 (file)
@@ -455,6 +455,28 @@ get_vport_type(const struct dpif_linux_vport *vport)
     return "unknown";
 }
 
+static enum ovs_vport_type
+netdev_to_ovs_vport_type(const struct netdev *netdev)
+{
+    const char *type = netdev_get_type(netdev);
+
+    if (!strcmp(type, "tap") || !strcmp(type, "system")) {
+        return OVS_VPORT_TYPE_NETDEV;
+    } else if (!strcmp(type, "internal")) {
+        return OVS_VPORT_TYPE_INTERNAL;
+    } else if (strstr(type, "gre64")) {
+        return OVS_VPORT_TYPE_GRE64;
+    } else if (strstr(type, "gre")) {
+        return OVS_VPORT_TYPE_GRE;
+    } else if (!strcmp(type, "capwap")) {
+        return OVS_VPORT_TYPE_CAPWAP;
+    } else if (!strcmp(type, "vxlan")) {
+        return OVS_VPORT_TYPE_VXLAN;
+    } else {
+        return OVS_VPORT_TYPE_UNSPEC;
+    }
+}
+
 static int
 dpif_linux_port_add(struct dpif *dpif_, struct netdev *netdev,
                     uint32_t *port_nop)
@@ -478,7 +500,7 @@ dpif_linux_port_add(struct dpif *dpif_, struct netdev *netdev,
     dpif_linux_vport_init(&request);
     request.cmd = OVS_VPORT_CMD_NEW;
     request.dp_ifindex = dpif->dp_ifindex;
-    request.type = netdev_vport_get_vport_type(netdev);
+    request.type = netdev_to_ovs_vport_type(netdev);
     if (request.type == OVS_VPORT_TYPE_UNSPEC) {
         VLOG_WARN_RL(&error_rl, "%s: cannot create port `%s' because it has "
                      "unsupported type `%s'",