Current out-of-tree ovs vxlan module has included vxlangpe code, but
it can't create vxlangpe port, this patch enables out-of-tree ovs vxlan
module to create vxlangpe port without Linux kernel v4.7 or above needed,
this can ensure we can create vxlangpe port on any Linux system as long
as Linux kernel isn't older than 3.10.

When you run the cmd

    sudo ovs-vsctl add-port br-int vxlan_gpe1 -- set interface vxlan_gpe1 
type=vxlan options:remote_ip=flow options:key=flow options:dst_port=4790 
options:exts=gpe

in current ovs, you will see the below warning

    netdev_vport|WARN|vxlan_gpe1: unknown extension 'gpe'

, and you will see a vxlan port but not vxlangpe port

vxlan_sys_4790 Link encap:Ethernet  HWaddr 6a:f6:6e:cb:75:fc
          inet6 addr: fe80::68f6:6eff:fecb:75fc/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:65485  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:8 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

But after you apply this patch, you won't see any warning, and
a vxlangpe port will be created successfully.

vxlan_sys_4790 Link encap:UNSPEC  HWaddr 
00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
          UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:65485  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

$ sudo ovs-vsctl show
fc8eaac4-e16e-47e0-a5bb-9fc8475ada0a
    Bridge br-int
        Port br-int
            Interface br-int
                type: internal
        Port "vxlan_gpe1"
            Interface "vxlan_gpe1"
                type: vxlan
                options: {dst_port="4790", exts=gpe, key=flow, remote_ip=flow}

Signed-off-by: Yi Yang <yi.y.y...@intel.com>
---
 datapath/linux/compat/include/linux/openvswitch.h |  1 +
 datapath/vport-vxlan.c                            | 15 +++++++++++++++
 lib/netdev-vport.c                                |  2 ++
 3 files changed, 18 insertions(+)

diff --git a/datapath/linux/compat/include/linux/openvswitch.h 
b/datapath/linux/compat/include/linux/openvswitch.h
index 5631bb5..66fac8d 100644
--- a/datapath/linux/compat/include/linux/openvswitch.h
+++ b/datapath/linux/compat/include/linux/openvswitch.h
@@ -291,6 +291,7 @@ enum ovs_vport_attr {
 enum {
        OVS_VXLAN_EXT_UNSPEC,
        OVS_VXLAN_EXT_GBP,      /* Flag or __u32 */
+       OVS_VXLAN_EXT_GPE = 8,  /* Flag or __u32 */
        __OVS_VXLAN_EXT_MAX,
 };
 
diff --git a/datapath/vport-vxlan.c b/datapath/vport-vxlan.c
index 11965c0..9e8db09 100644
--- a/datapath/vport-vxlan.c
+++ b/datapath/vport-vxlan.c
@@ -52,6 +52,18 @@ static int vxlan_get_options(const struct vport *vport, 
struct sk_buff *skb)
                        return -EMSGSIZE;
 
                nla_nest_end(skb, exts);
+       } else if (vxlan->flags & VXLAN_F_GPE) {
+               struct nlattr *exts;
+
+               exts = nla_nest_start(skb, OVS_TUNNEL_ATTR_EXTENSION);
+               if (!exts)
+                       return -EMSGSIZE;
+
+               if (vxlan->flags & VXLAN_F_GPE &&
+                   nla_put_flag(skb, OVS_VXLAN_EXT_GPE))
+                       return -EMSGSIZE;
+
+               nla_nest_end(skb, exts);
        }
 
        return 0;
@@ -59,6 +71,7 @@ static int vxlan_get_options(const struct vport *vport, 
struct sk_buff *skb)
 
 static const struct nla_policy exts_policy[OVS_VXLAN_EXT_MAX + 1] = {
        [OVS_VXLAN_EXT_GBP]     = { .type = NLA_FLAG, },
+       [OVS_VXLAN_EXT_GPE]     = { .type = NLA_FLAG, },
 };
 
 static int vxlan_configure_exts(struct vport *vport, struct nlattr *attr,
@@ -76,6 +89,8 @@ static int vxlan_configure_exts(struct vport *vport, struct 
nlattr *attr,
 
        if (exts[OVS_VXLAN_EXT_GBP])
                conf->flags |= VXLAN_F_GBP;
+       else if (exts[OVS_VXLAN_EXT_GPE])
+               conf->flags |= VXLAN_F_GPE;
 
        return 0;
 }
diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 8653e96..842f1c0 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -508,6 +508,8 @@ set_tunnel_config(struct netdev *dev_, const struct smap 
*args, char **errp)
             while (ext) {
                 if (!strcmp(type, "vxlan") && !strcmp(ext, "gbp")) {
                     tnl_cfg.exts |= (1 << OVS_VXLAN_EXT_GBP);
+                } else if (!strcmp(type, "vxlan") && !strcmp(ext, "gpe")) {
+                    tnl_cfg.exts |= (1 << OVS_VXLAN_EXT_GPE);
                 } else {
                     ds_put_format(&errors, "%s: unknown extension '%s'\n",
                                   name, ext);
-- 
2.1.0

_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to