datapath: Add Upstream id for GRE type.
[openvswitch] / datapath / vport-gre.c
index a25da0263d61c9c6ba6fa14858cd5983034728d5..e810173ff95e29cec03f302f377c57a1b54e921c 100644 (file)
@@ -45,7 +45,7 @@ struct gre_base_hdr {
        __be16 protocol;
 };
 
-static int get_gre_param(const struct tnl_mutable_config *mutable,
+static void get_gre_param(const struct tnl_mutable_config *mutable,
                        const struct ovs_key_ipv4_tunnel *tun_key,
                        u32 *flags, u32 *tunnel_type, __be64 *out_key)
 {
@@ -61,18 +61,12 @@ static int get_gre_param(const struct tnl_mutable_config *mutable,
        } else {
                *flags = mutable->flags;
                *tunnel_type = mutable->key.tunnel_type;
-               if (mutable->flags & TNL_F_OUT_KEY_ACTION) {
-                       if (likely(tun_key->tun_flags & OVS_FLOW_TNL_F_KEY)) {
-                               *out_key = tun_key->tun_id;
-                       } else {
-                               *out_key = 0;
-                               return -EINVAL;
-                       }
-               } else
+               if (mutable->flags & TNL_F_OUT_KEY_ACTION)
+                       *out_key = tun_key->tun_id;
+               else
                        *out_key = mutable->out_key;
 
        }
-       return 0;
 }
 
 static int gre_hdr_len(const struct tnl_mutable_config *mutable,
@@ -82,12 +76,8 @@ static int gre_hdr_len(const struct tnl_mutable_config *mutable,
        u32 flags;
        u32 tunnel_type;
        __be64 out_key;
-       int err;
-
-       err = get_gre_param(mutable, tun_key, &flags, &tunnel_type, &out_key);
-       if (err)
-               return err;
 
+       get_gre_param(mutable, tun_key, &flags, &tunnel_type, &out_key);
        len = GRE_HEADER_SECTION;
 
        if (flags & TNL_F_CSUM)
@@ -177,10 +167,7 @@ static struct sk_buff *gre_update_header(const struct vport *vport,
        __be32 *options = (__be32 *)(skb_network_header(skb) + tunnel_hlen
                                               - GRE_HEADER_SECTION);
 
-       if (get_gre_param(mutable, tun_key, &flags, &tunnel_type, &out_key)) {
-               kfree_skb(skb);
-               return NULL;
-       }
+       get_gre_param(mutable, tun_key, &flags, &tunnel_type, &out_key);
 
        /* Work backwards over the options so the checksum is last. */
        if (flags & TNL_F_OUT_KEY_ACTION) {
@@ -501,6 +488,11 @@ static struct vport *gre_create(const struct vport_parms *parms)
        return ovs_tnl_create(parms, &ovs_gre_vport_ops, &gre_tnl_ops);
 }
 
+static struct vport *gre_create_ft(const struct vport_parms *parms)
+{
+       return ovs_tnl_create(parms, &ovs_gre_ft_vport_ops, &gre_tnl_ops);
+}
+
 static const struct tnl_ops gre64_tnl_ops = {
        .tunnel_type    = TNL_T_PROTO_GRE64,
        .ipproto        = IPPROTO_GRE,
@@ -549,6 +541,24 @@ static void gre_exit(void)
        inet_del_protocol(&gre_protocol_handlers, IPPROTO_GRE);
 }
 
+const struct vport_ops ovs_gre_ft_vport_ops = {
+       .type           = OVS_VPORT_TYPE_FT_GRE,
+       .flags          = VPORT_F_TUN_ID,
+       .init           = gre_init,
+       .exit           = gre_exit,
+       .create         = gre_create_ft,
+       .destroy        = ovs_tnl_destroy,
+       .set_addr       = ovs_tnl_set_addr,
+       .get_name       = ovs_tnl_get_name,
+       .get_addr       = ovs_tnl_get_addr,
+       .get_options    = ovs_tnl_get_options,
+       .set_options    = ovs_tnl_set_options,
+       .get_dev_flags  = ovs_vport_gen_get_dev_flags,
+       .is_running     = ovs_vport_gen_is_running,
+       .get_operstate  = ovs_vport_gen_get_operstate,
+       .send           = ovs_tnl_send,
+};
+
 const struct vport_ops ovs_gre_vport_ops = {
        .type           = OVS_VPORT_TYPE_GRE,
        .flags          = VPORT_F_TUN_ID,