[ovs-dev] [PATCH 2/8] gre: Don't require incoming checksum.

Jesse Gross jesse at nicira.com
Wed Aug 18 07:08:46 UTC 2010


The current meaning of the GRE checksum option is to include
checksums on transmit and require packets to have them on receive.
In addition, incoming packets with checksums are always validated
regardless of this option.  Requiring checksums on receive creates
surprising behavior and interoperability issues.  This disables the
requirement on receive.  The new behavior is that the sender decides
whether to checksum packets and the receiver will validate packets
with checksums (similar to UDP).

Signed-off-by: Jesse Gross <jesse at nicira.com>
---
 datapath/vport-gre.c      |   11 +++--------
 include/openvswitch/gre.h |    3 +--
 lib/netdev-gre.c          |    3 +--
 vswitchd/vswitch.xml      |    7 ++++---
 4 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/datapath/vport-gre.c b/datapath/vport-gre.c
index 2bddc87..b471b08 100644
--- a/datapath/vport-gre.c
+++ b/datapath/vport-gre.c
@@ -592,7 +592,7 @@ static void create_gre_header(struct sk_buff *skb,
 		options--;
 	}
 
-	if (mutable->port_config.flags & GRE_F_OUT_CSUM) {
+	if (mutable->port_config.flags & GRE_F_CSUM) {
 		greh->flags |= GRE_CSUM;
 
 		*options = 0;
@@ -787,7 +787,7 @@ static void gre_err(struct sk_buff *skb, u32 info)
 	    !!(mutable->port_config.flags & GRE_F_OUT_KEY_ACTION))
 		return;
 
-	if ((mutable->port_config.flags & GRE_F_OUT_CSUM) && !(flags & GRE_CSUM))
+	if ((mutable->port_config.flags & GRE_F_CSUM) && !(flags & GRE_CSUM))
 		return;
 
 	tunnel_hdr_len += iph->ihl << 2;
@@ -881,11 +881,6 @@ static int gre_rcv(struct sk_buff *skb)
 		goto error;
 	}
 
-	if ((mutable->port_config.flags & GRE_F_IN_CSUM) && !(flags & GRE_CSUM)) {
-		vport_record_error(vport, VPORT_E_RX_CRC);
-		goto error;
-	}
-
 	if (!pskb_pull(skb, hdr_len) || !pskb_may_pull(skb, ETH_HLEN)) {
 		vport_record_error(vport, VPORT_E_RX_ERROR);
 		goto error;
@@ -1196,7 +1191,7 @@ static int set_config(const struct vport *cur_vport,
 
 	mutable->tunnel_hlen = sizeof(struct iphdr) + GRE_HEADER_SECTION;
 
-	if (mutable->port_config.flags & GRE_F_OUT_CSUM)
+	if (mutable->port_config.flags & GRE_F_CSUM)
 		mutable->tunnel_hlen += GRE_HEADER_SECTION;
 
 	if (mutable->port_config.out_key ||
diff --git a/include/openvswitch/gre.h b/include/openvswitch/gre.h
index 396a67d..a9ac1d9 100644
--- a/include/openvswitch/gre.h
+++ b/include/openvswitch/gre.h
@@ -42,8 +42,7 @@
 
 #include <linux/types.h>
 
-#define GRE_F_IN_CSUM		(1 << 0) /* Require incoming packets to have checksums. */
-#define GRE_F_OUT_CSUM		(1 << 1) /* Checksum outgoing packets. */
+#define GRE_F_CSUM		(1 << 1) /* Checksum packets. */
 #define GRE_F_IN_KEY_MATCH	(1 << 2) /* Store the key in tun_id to match in flow table. */
 #define GRE_F_OUT_KEY_ACTION	(1 << 3) /* Get the key from a SET_TUNNEL action. */
 #define GRE_F_TOS_INHERIT	(1 << 4) /* Inherit the ToS from the inner packet. */
diff --git a/lib/netdev-gre.c b/lib/netdev-gre.c
index 69411db..04a8332 100644
--- a/lib/netdev-gre.c
+++ b/lib/netdev-gre.c
@@ -111,8 +111,7 @@ parse_config(const char *name, const struct shash *args,
             }
         } else if (!strcmp(node->name, "csum")) {
             if (!strcmp(node->data, "true")) {
-                config->flags |= GRE_F_IN_CSUM;
-                config->flags |= GRE_F_OUT_CSUM;
+                config->flags |= GRE_F_CSUM;
             }
         } else if (!strcmp(node->name, "pmtud")) {
             if (!strcmp(node->data, "false")) {
diff --git a/vswitchd/vswitch.xml b/vswitchd/vswitch.xml
index 36964c8..c19ce3b 100644
--- a/vswitchd/vswitch.xml
+++ b/vswitchd/vswitch.xml
@@ -505,9 +505,10 @@
             </dl>
             <dl>
               <dt><code>csum</code></dt>
-              <dd>Optional.  Compute GRE checksums for outgoing packets and
-                require checksums for incoming packets.  Default is disabled,
-                set to <code>true</code> to enable.</dd>
+              <dd>Optional.  Compute GRE checksums on outgoing packets.
+                Checksums present on incoming packets will be validated
+                regardless of this setting.  Default is disabled, set to
+                <code>true</code> to enable.</dd>
             </dl>
             <dl>
               <dt><code>pmtud</code></dt>
-- 
1.7.0.4





More information about the dev mailing list