ofproto: Drop unneeded poll_immediate_wake().
[openvswitch] / lib / netdev-tunnel.c
index d0ecd98e204e7e603f6f392f570a282aebcf0292..a2383a47ee3c5c96ad141aad5596375a60b929d9 100644 (file)
@@ -39,7 +39,7 @@ struct netdev_tunnel {
     struct netdev netdev;
 };
 
-static int netdev_tunnel_create(const char *name, const char *type,
+static int netdev_tunnel_create(const struct netdev_class *, const char *name,
                                 const struct shash *args, struct netdev_dev **);
 
 static struct netdev_dev_tunnel *
@@ -62,10 +62,13 @@ parse_config(const char *name, const char *type, const struct shash *args,
              struct tnl_port_config *config)
 {
     struct shash_node *node;
+    bool ipsec_ip_set = false;
+    bool ipsec_mech_set = false;
 
     memset(config, 0, sizeof *config);
 
     config->flags |= TNL_F_PMTUD;
+    config->flags |= TNL_F_HDR_CACHE;
 
     SHASH_FOR_EACH (node, args) {
         if (!strcmp(node->name, "remote_ip")) {
@@ -121,11 +124,28 @@ parse_config(const char *name, const char *type, const struct shash *args,
             if (!strcmp(node->data, "false")) {
                 config->flags &= ~TNL_F_PMTUD;
             }
+        } else if (!strcmp(node->name, "header_cache")) {
+            if (!strcmp(node->data, "false")) {
+                config->flags &= ~TNL_F_HDR_CACHE;
+            }
+        } else if (!strcmp(node->name, "ipsec_local_ip")) {
+            ipsec_ip_set = true;
+        } else if (!strcmp(node->name, "ipsec_cert")
+                   || !strcmp(node->name, "ipsec_psk")) {
+            ipsec_mech_set = true;
         } else {
             VLOG_WARN("%s: unknown %s argument '%s'", name, type, node->name);
         }
     }
 
+    /* IPsec doesn't work when header caching is enabled.  Disable it if
+     * the IPsec local IP address and authentication mechanism have been
+     * defined. */
+    if (ipsec_ip_set && ipsec_mech_set) {
+        VLOG_INFO("%s: header caching disabled due to use of IPsec", name);
+        config->flags &= ~TNL_F_HDR_CACHE;
+    }
+
     if (!config->daddr) {
         VLOG_WARN("%s: %s type requires valid 'remote_ip' argument", name, type);
         return EINVAL;
@@ -135,7 +155,7 @@ parse_config(const char *name, const char *type, const struct shash *args,
 }
 
 static int
-netdev_tunnel_create(const char *name, const char *type,
+netdev_tunnel_create(const struct netdev_class *class, const char *name,
                      const struct shash *args, struct netdev_dev **netdev_devp)
 {
     int err;
@@ -143,11 +163,11 @@ netdev_tunnel_create(const char *name, const char *type,
     struct tnl_port_config port_config;
     struct netdev_dev_tunnel *netdev_dev;
 
-    ovs_strlcpy(ova.port_type, type, sizeof ova.port_type);
+    ovs_strlcpy(ova.port_type, class->type, sizeof ova.port_type);
     ovs_strlcpy(ova.devname, name, sizeof ova.devname);
     ova.config = &port_config;
 
-    err = parse_config(name, type, args, &port_config);
+    err = parse_config(name, class->type, args, &port_config);
     if (err) {
         return err;
     }
@@ -170,12 +190,7 @@ netdev_tunnel_create(const char *name, const char *type,
 
     netdev_dev = xmalloc(sizeof *netdev_dev);
 
-    if (!strcmp(type, "gre")) {
-        netdev_dev_init(&netdev_dev->netdev_dev, name, &netdev_gre_class);
-    } else {
-        netdev_dev_init(&netdev_dev->netdev_dev, name, &netdev_capwap_class);
-    }
-
+    netdev_dev_init(&netdev_dev->netdev_dev, name, class);
     *netdev_devp = &netdev_dev->netdev_dev;
     return 0;
 }