[ovs-dev] [PATCH 04/10] dpif-netlink-rtnl: Support layer3 GRE

Eric Garver e at erig.me
Mon Jul 10 19:39:54 UTC 2017


Add support for creating layer3 GRE.

Signed-off-by: Eric Garver <e at erig.me>
---
 lib/dpif-netlink-rtnl.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c
index f02fe37e9a6a..32e220fc135c 100644
--- a/lib/dpif-netlink-rtnl.c
+++ b/lib/dpif-netlink-rtnl.c
@@ -82,13 +82,20 @@ static const struct nl_policy geneve_policy[] = {
 };
 
 static const char *
-vport_type_to_kind(enum ovs_vport_type type)
+vport_type_to_kind(enum ovs_vport_type type,
+                   const struct netdev_tunnel_config *tnl_cfg)
 {
     switch (type) {
     case OVS_VPORT_TYPE_VXLAN:
         return "vxlan";
     case OVS_VPORT_TYPE_GRE:
-        return "gretap";
+        if (tnl_cfg->pt_mode == NETDEV_PT_LEGACY_L3) {
+            return "gre";
+        } else if (tnl_cfg->pt_mode == NETDEV_PT_LEGACY_L2) {
+            return "gretap";
+        } else {
+            return NULL;
+        }
     case OVS_VPORT_TYPE_GENEVE:
         return "geneve";
     case OVS_VPORT_TYPE_NETDEV:
@@ -232,7 +239,7 @@ dpif_netlink_rtnl_verify(const struct netdev_tunnel_config *tnl_cfg,
     const char *kind;
     int err;
 
-    kind = vport_type_to_kind(type);
+    kind = vport_type_to_kind(type, tnl_cfg);
     if (!kind) {
         return EOPNOTSUPP;
     }
@@ -342,16 +349,16 @@ dpif_netlink_rtnl_port_create(struct netdev *netdev)
     int err;
 
     type = netdev_to_ovs_vport_type(netdev_get_type(netdev));
-    kind = vport_type_to_kind(type);
-    if (!kind) {
-        return EOPNOTSUPP;
-    }
-
     tnl_cfg = netdev_get_tunnel_config(netdev);
     if (!tnl_cfg) {
         return EINVAL;
     }
 
+    kind = vport_type_to_kind(type, tnl_cfg);
+    if (!kind) {
+        return EOPNOTSUPP;
+    }
+
     name = netdev_vport_get_dpif_port(netdev, namebuf, sizeof namebuf);
     flags = NLM_F_REQUEST | NLM_F_ACK | NLM_F_CREATE | NLM_F_EXCL;
 
-- 
2.12.0



More information about the dev mailing list