Adding checksum to IP packets created by ovs for testing.
authorMehak Mahajan <mmahajan@nicira.com>
Thu, 2 Aug 2012 23:11:58 +0000 (16:11 -0700)
committerMehak Mahajan <mmahajan@nicira.com>
Thu, 2 Aug 2012 23:11:58 +0000 (16:11 -0700)
OVS provides a utility to create IP packets for the purpose of testing
using ovs-appctl netdev-dummy/receive.  These packets created by
flow_compose() earlier did not have the IP checksum in them.  With this
commit, the checksum with be added to these test IP packets.

Signed-off-by: Mehak Mahajan <mmahajan@nicira.com>
AUTHORS
lib/flow.c

diff --git a/AUTHORS b/AUTHORS
index 11ccf8768320e001b144465b28775db106bebb1d..c59d50000460fce75f61e3793948a02c9066c285 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -43,6 +43,7 @@ Keith Amidon            keith@nicira.com
 Leo Alterman            lalterman@nicira.com
 Luca Giraudo            lgiraudo@nicira.com
 Martin Casado           casado@nicira.com
+Mehak Mahajan           mmahajan@nicira.com
 Natasha Gude            natasha@nicira.com
 Neil McKee              neil.mckee@inmon.com
 Paul Fazzone            pfazzone@nicira.com
index 59b5fb7d48f64e1023462e5f65858eeacbbf0649..1781ed3c15e627515f0fa846f6dc426cf8290886 100644 (file)
@@ -26,6 +26,7 @@
 #include <string.h>
 #include "byte-order.h"
 #include "coverage.h"
+#include "csum.h"
 #include "dynamic-string.h"
 #include "hash.h"
 #include "ofpbuf.h"
@@ -1009,7 +1010,7 @@ flow_set_vlan_pcp(struct flow *flow, uint8_t pcp)
  * 'flow'.
  *
  * (This is useful only for testing, obviously, and the packet isn't really
- * valid.  It hasn't got any checksums filled in, for one, and lots of fields
+ * valid. It hasn't got some checksums filled in, for one, and lots of fields
  * are just zeroed.) */
 void
 flow_compose(struct ofpbuf *b, const struct flow *flow)
@@ -1068,6 +1069,7 @@ flow_compose(struct ofpbuf *b, const struct flow *flow)
         ip = b->l3;
         ip->ip_tot_len = htons((uint8_t *) b->data + b->size
                                - (uint8_t *) b->l3);
+        ip->ip_csum = csum(ip, sizeof *ip);
     } else if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
         /* XXX */
     } else if (flow->dl_type == htons(ETH_TYPE_ARP)) {