datapath: tunnel: Fix gre64 tunnel when key not specified.
authorPravin B Shelar <pshelar@nicira.com>
Thu, 15 Aug 2013 00:31:57 +0000 (17:31 -0700)
committerPravin B Shelar <pshelar@nicira.com>
Tue, 13 Aug 2013 07:12:37 +0000 (00:12 -0700)
User is allowed to create tunnel without any keys.  In this
case userspace set tunnel action does not set tun-key flag
which was confusing gre64 vport header calculations.  Following
patch fixes it by always assuming TUNNEL_KEY parameter as we
do it with tun-seq.

Signed-off-by: Pravin B Shelar <pshelar@nicira.com>
Acked-by: Jesse Gross <jesse@nicira.com>
Bug #19121

datapath/vport-gre.c

index c74f5fc..38245a7 100644 (file)
@@ -335,17 +335,19 @@ static __be32 be64_get_high32(__be64 x)
 
 static int gre64_send(struct vport *vport, struct sk_buff *skb)
 {
-       int hlen;
+       int hlen = GRE_HEADER_SECTION +         /* GRE Hdr */
+                  GRE_HEADER_SECTION +         /* GRE Key */
+                  GRE_HEADER_SECTION;          /* GRE SEQ */
        __be32 seq;
 
        if (unlikely(!OVS_CB(skb)->tun_key))
                return -EINVAL;
 
-       hlen = ip_gre_calc_hlen(OVS_CB(skb)->tun_key->tun_flags)
-              + GRE_HEADER_SECTION;
+       if (OVS_CB(skb)->tun_key->tun_flags & TUNNEL_CSUM)
+               hlen += GRE_HEADER_SECTION;
 
        seq = be64_get_high32(OVS_CB(skb)->tun_key->tun_id);
-       return __send(vport, skb, hlen, seq, TUNNEL_SEQ);
+       return __send(vport, skb, hlen, seq, (TUNNEL_KEY|TUNNEL_SEQ));
 }
 
 const struct vport_ops ovs_gre64_vport_ops = {