datapath-windows: Fix IP fragmentation
authorAlin Serdean <aserdean@cloudbasesolutions.com>
Wed, 30 Sep 2015 21:00:43 +0000 (21:00 +0000)
committerBen Pfaff <blp@nicira.com>
Fri, 2 Oct 2015 14:20:30 +0000 (07:20 -0700)
Currently in the case of IP fragmentation we send to the userspace that
the flag for the last fragment is 3 when it actually should be a value
between 0..2.

This patch fixes the problem and also uses the values used in the common
header of the datapath.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Nithin Raju <nithin@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath-windows/ovsext/DpInternal.h
datapath-windows/ovsext/Flow.c
datapath-windows/ovsext/PacketParser.c

index 3da9d6a..8de48a2 100644 (file)
@@ -62,12 +62,6 @@ typedef struct _OVS_VPORT_EXT_INFO {
  * that is, pure 802.2 frames. */
 #define OVSWIN_DL_TYPE_NONE 0x5ff
 
-/* Fragment bits, used for IPv4 and IPv6, always zero for non-IP flows. */
-#define OVSWIN_NW_FRAG_ANY   (1 << 0)   /* Set for any IP frag. */
-#define OVSWIN_NW_FRAG_LATER (1 << 1)   /* Set for IP frag with nonzero
-                                         * offset. */
-#define OVSWIN_NW_FRAG_MASK  (OVSWIN_NW_FRAG_ANY | OVSWIN_NW_FRAG_LATER)
-
 typedef struct L4Key {
     ovs_be16 tpSrc;              /* TCP/UDP/SCTP source port. */
     ovs_be16 tpDst;              /* TCP/UDP/SCTP destination port. */
index 32cb086..b629c93 100644 (file)
@@ -1785,12 +1785,12 @@ OvsExtractFlow(const NET_BUFFER_LIST *packet,
 
             ipKey->nwTos = nh->tos;
             if (nh->frag_off & htons(IP_MF | IP_OFFSET)) {
-                ipKey->nwFrag = OVSWIN_NW_FRAG_ANY;
+                ipKey->nwFrag = OVS_FRAG_TYPE_FIRST;
                 if (nh->frag_off & htons(IP_OFFSET)) {
-                    ipKey->nwFrag |= OVSWIN_NW_FRAG_LATER;
+                    ipKey->nwFrag = OVS_FRAG_TYPE_LATER;
                 }
             } else {
-                ipKey->nwFrag = 0;
+                ipKey->nwFrag = OVS_FRAG_TYPE_NONE;
             }
 
             ipKey->nwTtl = nh->ttl;
index 2c955e1..e01be17 100644 (file)
@@ -108,7 +108,7 @@ OvsParseIPv6(const NET_BUFFER_LIST *packet,
         ((nh->flow_lbl[0] & 0x0F) << 16) | (nh->flow_lbl[1] << 8) | nh->flow_lbl[2];
     flow->nwTtl = nh->hop_limit;
     flow->nwProto = SOCKET_IPPROTO_NONE;
-    flow->nwFrag = 0;
+    flow->nwFrag = OVS_FRAG_TYPE_NONE;
 
     // Parse extended headers and compute L4 offset
     ofs += sizeof(IPv6Hdr);
@@ -161,9 +161,9 @@ OvsParseIPv6(const NET_BUFFER_LIST *packet,
             /* We only process the first fragment. */
             if (fragHdr->offlg != htons(0)) {
                 if ((fragHdr->offlg & IP6F_OFF_HOST_ORDER_MASK) == htons(0)) {
-                    flow->nwFrag = OVSWIN_NW_FRAG_ANY;
+                    flow->nwFrag = OVS_FRAG_TYPE_FIRST;
                 } else {
-                    flow->nwFrag |= OVSWIN_NW_FRAG_LATER;
+                    flow->nwFrag = OVS_FRAG_TYPE_LATER;
                     nextHdr = SOCKET_IPPROTO_FRAGMENT;
                     break;
                 }