diff mbox series

[ovs-dev,28/41] ip6gre: Add ip6gre vport type

Message ID 1526591733-4450-29-git-send-email-gvrose8192@gmail.com
State Superseded
Headers show
Series Add ERSPAN support | expand

Commit Message

Gregory Rose May 17, 2018, 9:15 p.m. UTC
Add handlers for OVS_VPORT_TYPE_IP6GRE

Signed-off-by: Greg Rose <gvrose8192@gmail.com>
---
 lib/dpif-netlink-rtnl.c | 4 +++-
 lib/dpif-netlink.c      | 7 +++++--
 lib/netdev-native-tnl.c | 5 ++++-
 lib/netdev-vport.c      | 4 ++++
 lib/odp-util.c          | 9 +++++++--
 lib/tnl-ports.c         | 2 +-
 6 files changed, 24 insertions(+), 7 deletions(-)

Comments

Ben Pfaff May 17, 2018, 11:22 p.m. UTC | #1
On Thu, May 17, 2018 at 02:15:20PM -0700, Greg Rose wrote:
> Add handlers for OVS_VPORT_TYPE_IP6GRE
> 
> Signed-off-by: Greg Rose <gvrose8192@gmail.com>

I suggest folding in the following incremental:

--8<--------------------------cut here-------------------------->8--

diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index eea5997026b4..c70811eaff21 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -513,10 +513,11 @@ netdev_gre_build_header(const struct netdev *netdev,
     hlen = (uint8_t *) options - (uint8_t *) greh;
 
     data->header_len += hlen;
-    if (!params->is_ipv6)
+    if (!params->is_ipv6) {
         data->tnl_type = OVS_VPORT_TYPE_GRE;
-    else
+    } else {
         data->tnl_type = OVS_VPORT_TYPE_IP6GRE;
+    }
     return 0;
 }
 
@@ -555,7 +556,7 @@ netdev_erspan_pop_header(struct dp_packet *packet)
     }
 
     ersh = ERSPAN_HDR(greh);
-    tnl->tun_id = be32_to_be64(be16_to_be32(htons(get_sid(ersh))));
+    tnl->tun_id = be16_to_be64(htons(get_sid(ersh)));
     tnl->erspan_ver = ersh->ver;
 
     if (ersh->ver == 1) {
diff mbox series

Patch

diff --git a/lib/dpif-netlink-rtnl.c b/lib/dpif-netlink-rtnl.c
index 817e544..bec3fce 100644
--- a/lib/dpif-netlink-rtnl.c
+++ b/lib/dpif-netlink-rtnl.c
@@ -104,6 +104,7 @@  vport_type_to_kind(enum ovs_vport_type type,
     case OVS_VPORT_TYPE_IP6ERSPAN:
         return "ip6erspan";
     case OVS_VPORT_TYPE_IP6GRE:
+        return "ip6gre";
     case OVS_VPORT_TYPE_NETDEV:
     case OVS_VPORT_TYPE_INTERNAL:
     case OVS_VPORT_TYPE_LISP:
@@ -349,7 +350,8 @@  dpif_netlink_rtnl_create(const struct netdev_tunnel_config *tnl_cfg,
     nl_msg_end_nested(&request, linkinfo_off);
 
     err = nl_transact(NETLINK_ROUTE, &request, NULL);
-    if (!err && type == OVS_VPORT_TYPE_GRE) {
+    if (!err && (type == OVS_VPORT_TYPE_GRE ||
+                 type == OVS_VPORT_TYPE_IP6GRE)) {
         /* Work around a bug in kernel GRE driver, which ignores IFLA_MTU in
          * RTM_NEWLINK, by setting the MTU again.  See
          * https://bugzilla.redhat.com/show_bug.cgi?id=1488484. */
diff --git a/lib/dpif-netlink.c b/lib/dpif-netlink.c
index f5ae21e..607b497 100644
--- a/lib/dpif-netlink.c
+++ b/lib/dpif-netlink.c
@@ -791,9 +791,10 @@  get_vport_type(const struct dpif_netlink_vport *vport)
         return "erspan";
 
     case OVS_VPORT_TYPE_IP6ERSPAN:
-        return "ip6erspan";
+        return "ip6erspan"; 
+
     case OVS_VPORT_TYPE_IP6GRE:
-	return "";
+        return "ip6gre";
 
     case OVS_VPORT_TYPE_UNSPEC:
     case __OVS_VPORT_TYPE_MAX:
@@ -826,6 +827,8 @@  netdev_to_ovs_vport_type(const char *type)
         return OVS_VPORT_TYPE_ERSPAN;
     } else if (!strcmp(type, "ip6erspan")) {
         return OVS_VPORT_TYPE_IP6ERSPAN;
+    } else if (!strcmp(type, "ip6gre")) {
+        return OVS_VPORT_TYPE_IP6GRE;
     } else {
         return OVS_VPORT_TYPE_UNSPEC;
     }
diff --git a/lib/netdev-native-tnl.c b/lib/netdev-native-tnl.c
index 7152f3e..fe36ea9 100644
--- a/lib/netdev-native-tnl.c
+++ b/lib/netdev-native-tnl.c
@@ -513,7 +513,10 @@  netdev_gre_build_header(const struct netdev *netdev,
     hlen = (uint8_t *) options - (uint8_t *) greh;
 
     data->header_len += hlen;
-    data->tnl_type = OVS_VPORT_TYPE_GRE;
+    if (!params->is_ipv6)
+        data->tnl_type = OVS_VPORT_TYPE_GRE;
+    else
+        data->tnl_type = OVS_VPORT_TYPE_IP6GRE;
     return 0;
 }
 
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 4311d2b..805f130 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -1042,6 +1042,10 @@  netdev_vport_tunnel_register(void)
                                                    netdev_erspan_push_header,
                                                    netdev_erspan_pop_header,
                                                    NULL),
+        TUNNEL_CLASS("ip6gre", "ip6gre_sys", netdev_gre_build_header,
+                                             netdev_gre_push_header,
+                                             netdev_gre_pop_header,
+                                             NULL),
     };
     static struct ovsthread_once once = OVSTHREAD_ONCE_INITIALIZER;
 
diff --git a/lib/odp-util.c b/lib/odp-util.c
index ed11c22..29b5fb8 100644
--- a/lib/odp-util.c
+++ b/lib/odp-util.c
@@ -690,7 +690,8 @@  format_odp_tnl_push_header(struct ds *ds, struct ovs_action_push_tnl *data)
         }
 
         ds_put_char(ds, ')');
-    } else if (data->tnl_type == OVS_VPORT_TYPE_GRE) {
+    } else if (data->tnl_type == OVS_VPORT_TYPE_GRE ||
+               data->tnl_type == OVS_VPORT_TYPE_IP6GRE) {
         const struct gre_base_hdr *greh;
         ovs_16aligned_be32 *options;
 
@@ -1561,7 +1562,11 @@  ovs_parse_tnl_push(const char *s, struct ovs_action_push_tnl *data)
     } else if (ovs_scan_len(s, &n, "gre((flags=0x%"SCNx16",proto=0x%"SCNx16")",
                             &gre_flags, &gre_proto)){
 
-        tnl_type = OVS_VPORT_TYPE_GRE;
+        if (eth->eth_type == htons(ETH_TYPE_IP)) {
+            tnl_type = OVS_VPORT_TYPE_GRE;
+        } else {
+            tnl_type = OVS_VPORT_TYPE_IP6GRE;
+        }
         greh->flags = htons(gre_flags);
         greh->protocol = htons(gre_proto);
         ovs_16aligned_be32 *options = (ovs_16aligned_be32 *) (greh + 1);
diff --git a/lib/tnl-ports.c b/lib/tnl-ports.c
index 5753179..1735304 100644
--- a/lib/tnl-ports.c
+++ b/lib/tnl-ports.c
@@ -172,7 +172,7 @@  tnl_type_to_nw_proto(const char type[])
         return IPPROTO_TCP;
     }
     if (!strcmp(type, "gre") || !strcmp(type, "erspan") ||
-        !strcmp(type, "ip6erspan")) {
+        !strcmp(type, "ip6erspan") || !strcmp(type, "ip6gre")) {
         return IPPROTO_GRE;
     }
     if (!strcmp(type, "vxlan")) {