From 50d63168f50d4d0e8007cb1c81112ea3c7e1d111 Mon Sep 17 00:00:00 2001
From: Jesse Gross <jesse@nicira.com>
Date: Fri, 20 Jan 2012 15:12:38 -0800
Subject: [PATCH] datapath: Correct GRE checksum offset.

If a statically defined GRE key is used with checksums then the
checksum will overwrite the key.  This is because the key is set
at header caching time and the checksum is set at packet processing
time and we don't update the offset on packet processing because
we don't do anything with the key.

Reported-by: Christos Argyropoulos <cargious@netmode.ntua.gr>
Signed-off-by: Jesse Gross <jesse@nicira.com>
---
 datapath/vport-gre.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c
index cc64d1299..ce607674f 100644
--- a/datapath/vport-gre.c
+++ b/datapath/vport-gre.c
@@ -91,10 +91,11 @@ static struct sk_buff *gre_update_header(const struct vport *vport,
 					       - GRE_HEADER_SECTION);
 
 	/* Work backwards over the options so the checksum is last. */
-	if (mutable->flags & TNL_F_OUT_KEY_ACTION) {
+	if (mutable->flags & TNL_F_OUT_KEY_ACTION)
 		*options = be64_get_low32(OVS_CB(skb)->tun_id);
+
+	if (mutable->out_key || mutable->flags & TNL_F_OUT_KEY_ACTION)
 		options--;
-	}
 
 	if (mutable->flags & TNL_F_CSUM)
 		*(__sum16 *)options = csum_fold(skb_checksum(skb,
-- 
2.47.0