datapath-windows: Update VXLAN header information
authorAlin Serdean <aserdean@cloudbasesolutions.com>
Mon, 13 Jul 2015 16:59:26 +0000 (16:59 +0000)
committerBen Pfaff <blp@nicira.com>
Wed, 15 Jul 2015 17:41:46 +0000 (10:41 -0700)
Use tunnel key information on the IP header preceding the VXLAN header.

Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath-windows/ovsext/Vxlan.c
datapath-windows/ovsext/Vxlan.h

index b84c1d0..f700b76 100644 (file)
@@ -15,6 +15,7 @@
  */
 
 #include "precomp.h"
+#include "Atomic.h"
 #include "NetProto.h"
 #include "Switch.h"
 #include "Vport.h"
@@ -263,11 +264,13 @@ OvsDoEncapVxlan(POVS_VPORT_ENTRY vport,
         ipHdr = (IPHdr *)((PCHAR)ethHdr + sizeof *ethHdr);
 
         ipHdr->ihl = sizeof *ipHdr / 4;
-        ipHdr->version = IPV4;
-        ipHdr->tos = 0;
+        ipHdr->version = IPPROTO_IPV4;
+        ipHdr->tos = tunKey->tos;
         ipHdr->tot_len = htons(NET_BUFFER_DATA_LENGTH(curNb) - sizeof *ethHdr);
-        ipHdr->id = 0;
-        ipHdr->frag_off = IP_DF_NBO;
+        ipHdr->id = (uint16)atomic_add64(&vportVxlan->ipId,
+                                         NET_BUFFER_DATA_LENGTH(curNb));
+        ipHdr->frag_off = (tunKey->flags & OVS_TNL_F_DONT_FRAGMENT) ?
+                          IP_DF_NBO : 0;
         ipHdr->ttl = tunKey->ttl ? tunKey->ttl : VXLAN_DEFAULT_TTL;
         ipHdr->protocol = IPPROTO_UDP;
         ASSERT(tunKey->dst == fwdInfo->dstIpAddr);
@@ -279,7 +282,7 @@ OvsDoEncapVxlan(POVS_VPORT_ENTRY vport,
 
         /* UDP header */
         udpHdr = (UDPHdr *)((PCHAR)ipHdr + sizeof *ipHdr);
-        udpHdr->source = htons(tunKey->flow_hash | 32768);
+        udpHdr->source = htons(tunKey->flow_hash | MAXINT16);
         udpHdr->dest = htons(vportVxlan->dstPort);
         udpHdr->len = htons(NET_BUFFER_DATA_LENGTH(curNb) - headRoom +
                             sizeof *udpHdr + sizeof *vxlanHdr);
index b010af0..a05834d 100644 (file)
@@ -25,6 +25,7 @@ typedef struct _OVS_VXLAN_VPORT {
     UINT64 slowInPkts;
     UINT64 slowOutPkts;
     UINT64 filterID;
+    UINT64 ipId;
     /*
      * To be filled
      */