datapath-windows: Fixes in packet created for userspace
authorNithin Raju <nithin@vmware.com>
Sat, 18 Oct 2014 18:39:37 +0000 (11:39 -0700)
committerBen Pfaff <blp@nicira.com>
Tue, 21 Oct 2014 18:45:36 +0000 (11:45 -0700)
A couple of miscellaneous fixes in code that creates a packet for
userspace as well as when we copy the packet to memory specified by
userspace.

Signed-off-by: Nithin Raju <nithin@vmware.com>
Acked-by: Ankur Sharma <ankursharma@vmware.com>
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
datapath-windows/ovsext/User.c

index a4c736b..329b964 100644 (file)
@@ -205,7 +205,7 @@ OvsReadDpIoctl(PFILE_OBJECT fileObject,
             *ptr = sum;
             ovsUserStats.l4Csum++;
         } else {
-            RtlCopyMemory(outputBuffer, &elem->packet, len);
+            RtlCopyMemory(outputBuffer, &elem->packet.data, len);
         }
 
         *replyLen = len;
@@ -892,14 +892,14 @@ OvsCreateQueueNlPacket(PVOID userData,
     UINT32 pid;
     UINT32 nlMsgSize;
     NL_BUFFER nlBuf;
+    PNL_MSG_HDR nlMsg;
 
     /* XXX pass vport in the stack rather than portNo */
     POVS_VPORT_ENTRY vport =
         OvsFindVportByPortNo(gOvsSwitchContext, inPort);
 
     if (vport == NULL){
-        /* Should never happen as dispatch lock is held */
-        ASSERT(vport);
+        /* No vport is not fatal. */
         return NULL;
     }
 
@@ -1028,6 +1028,12 @@ OvsCreateQueueNlPacket(PVOID userData,
         elem->hdrInfo.l4Offset += VLAN_TAG_SIZE;
         ovsUserStats.vlanInsert++;
     }
+
+    nlMsg = (PNL_MSG_HDR)NlBufAt(&nlBuf, 0, 0);
+    nlMsg->nlmsgLen = NlBufSize(&nlBuf);
+    /* 'totalLen' should be size of valid data. */
+    elem->packet.totalLen = nlMsg->nlmsgLen;
+
     return elem;
 fail:
     OvsFreeMemory(elem);