datapath: Provide compatibility for kernels up to 3.17
[cascardo/ovs.git] / datapath / vport-gre.c
index f30f090..41c025d 100644 (file)
@@ -66,9 +66,10 @@ static struct sk_buff *__build_header(struct sk_buff *skb,
                                      int tunnel_hlen,
                                      __be32 seq, __be16 gre64_flag)
 {
-       const struct ovs_key_ipv4_tunnel *tun_key = &OVS_CB(skb)->tun_info->tunnel;
+       const struct ovs_key_ipv4_tunnel *tun_key;
        struct tnl_ptk_info tpi;
 
+       tun_key = &OVS_CB(skb)->egress_tun_info->tunnel;
        skb = gre_handle_offloads(skb, !!(tun_key->tun_flags & TUNNEL_CSUM));
        if (IS_ERR(skb))
                return NULL;
@@ -110,8 +111,8 @@ static int gre_rcv(struct sk_buff *skb,
                return PACKET_REJECT;
 
        key = key_to_tunnel_id(tpi->key, tpi->seq);
-       ovs_flow_tun_info_init(&tun_info, ip_hdr(skb), key,
-                              filter_tnl_flags(tpi->flags));
+       ovs_flow_tun_info_init(&tun_info, ip_hdr(skb), 0, 0, key,
+                              filter_tnl_flags(tpi->flags), NULL, 0);
 
        ovs_vport_receive(vport, skb, &tun_info);
        return PACKET_RCVD;
@@ -140,7 +141,7 @@ static int __send(struct vport *vport, struct sk_buff *skb,
                  int tunnel_hlen,
                  __be32 seq, __be16 gre64_flag)
 {
-       struct ovs_key_ipv4_tunnel *tun_key = &OVS_CB(skb)->tun_info->tunnel;
+       struct ovs_key_ipv4_tunnel *tun_key;
        struct rtable *rt;
        int min_headroom;
        __be16 df;
@@ -148,6 +149,7 @@ static int __send(struct vport *vport, struct sk_buff *skb,
        int err;
 
        /* Route lookup */
+       tun_key = &OVS_CB(skb)->egress_tun_info->tunnel;
        saddr = tun_key->ipv4_src;
        rt = find_route(ovs_dp_get_net(vport->dp),
                        &saddr, tun_key->ipv4_dst,
@@ -190,9 +192,9 @@ static int __send(struct vport *vport, struct sk_buff *skb,
        }
 
        df = tun_key->tun_flags & TUNNEL_DONT_FRAGMENT ? htons(IP_DF) : 0;
-       skb->local_df = 1;
+       skb->ignore_df = 1;
 
-       return iptunnel_xmit(rt, skb, saddr,
+       return iptunnel_xmit(skb->sk, rt, skb, saddr,
                             tun_key->ipv4_dst, IPPROTO_GRE,
                             tun_key->ipv4_tos,
                             tun_key->ipv4_ttl, df, false);
@@ -284,20 +286,30 @@ static int gre_send(struct vport *vport, struct sk_buff *skb)
 {
        int hlen;
 
-       if (unlikely(!OVS_CB(skb)->tun_info))
+       if (unlikely(!OVS_CB(skb)->egress_tun_info))
                return -EINVAL;
 
-       hlen = ip_gre_calc_hlen(OVS_CB(skb)->tun_info->tunnel.tun_flags);
+       hlen = ip_gre_calc_hlen(OVS_CB(skb)->egress_tun_info->tunnel.tun_flags);
 
        return __send(vport, skb, hlen, 0, 0);
 }
 
+static int gre_get_egress_tun_info(struct vport *vport, struct sk_buff *skb,
+                                  struct ovs_tunnel_info *egress_tun_info)
+{
+       return ovs_tunnel_get_egress_info(egress_tun_info,
+                                         ovs_dp_get_net(vport->dp),
+                                         OVS_CB(skb)->egress_tun_info,
+                                         IPPROTO_GRE, skb->mark, 0, 0);
+}
+
 const struct vport_ops ovs_gre_vport_ops = {
-       .type           = OVS_VPORT_TYPE_GRE,
-       .create         = gre_create,
-       .destroy        = gre_tnl_destroy,
-       .get_name       = gre_get_name,
-       .send           = gre_send,
+       .type                   = OVS_VPORT_TYPE_GRE,
+       .create                 = gre_create,
+       .destroy                = gre_tnl_destroy,
+       .get_name               = gre_get_name,
+       .send                   = gre_send,
+       .get_egress_tun_info    = gre_get_egress_tun_info,
 };
 
 /* GRE64 vport. */
@@ -358,21 +370,22 @@ static int gre64_send(struct vport *vport, struct sk_buff *skb)
                   GRE_HEADER_SECTION;          /* GRE SEQ */
        __be32 seq;
 
-       if (unlikely(!OVS_CB(skb)->tun_info))
+       if (unlikely(!OVS_CB(skb)->egress_tun_info))
                return -EINVAL;
 
-       if (OVS_CB(skb)->tun_info->tunnel.tun_flags & TUNNEL_CSUM)
+       if (OVS_CB(skb)->egress_tun_info->tunnel.tun_flags & TUNNEL_CSUM)
                hlen += GRE_HEADER_SECTION;
 
-       seq = be64_get_high32(OVS_CB(skb)->tun_info->tunnel.tun_id);
+       seq = be64_get_high32(OVS_CB(skb)->egress_tun_info->tunnel.tun_id);
        return __send(vport, skb, hlen, seq, (TUNNEL_KEY|TUNNEL_SEQ));
 }
 
 const struct vport_ops ovs_gre64_vport_ops = {
-       .type           = OVS_VPORT_TYPE_GRE64,
-       .create         = gre64_create,
-       .destroy        = gre64_tnl_destroy,
-       .get_name       = gre_get_name,
-       .send           = gre64_send,
+       .type                   = OVS_VPORT_TYPE_GRE64,
+       .create                 = gre64_create,
+       .destroy                = gre64_tnl_destroy,
+       .get_name               = gre_get_name,
+       .send                   = gre64_send,
+       .get_egress_tun_info    = gre_get_egress_tun_info,
 };
 #endif