[ovs-dev] [PATCH] datapath-windows: pop buffer from packet / pop_vlan bug

Alin Serdean aserdean at cloudbasesolutions.com
Thu Oct 27 23:48:54 UTC 2016


Switch too memmove(RtlMoveMemory) instead of copy and predefined allocated
buffer.

Currently if we receive a pop_vlan action, and the vlan tag is inside the
Ethernet frame(not in the net buffer list information) we change the frame
without checking if the it was a vlan tagged or not.

This patch checks if it a vlan tagged frame and makes the action a
non-operation.


Signed-off-by: Alin Gabriel Serdean <aserdean at cloudbasesolutions.com>
---
this patch is intended for 2.6 as well
---
 datapath-windows/ovsext/Actions.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/datapath-windows/ovsext/Actions.c b/datapath-windows/ovsext/Actions.c
index f46309a..9a58fbd 100644
--- a/datapath-windows/ovsext/Actions.c
+++ b/datapath-windows/ovsext/Actions.c
@@ -1079,9 +1079,6 @@ OvsPopFieldInPacketBuf(OvsForwardingContext *ovsFwdCtx,
     UINT32 packetLen, mdlLen;
     PNET_BUFFER_LIST newNbl;
     NDIS_STATUS status;
-    PUINT8 tempBuffer[ETH_HEADER_LENGTH];
-
-    ASSERT(shiftOffset > ETH_ADDR_LENGTH);
 
     newNbl = OvsPartialCopyNBL(ovsFwdCtx->switchContext, ovsFwdCtx->curNbl,
                                0, 0, TRUE /* copy NBL info */);
@@ -1118,8 +1115,16 @@ OvsPopFieldInPacketBuf(OvsForwardingContext *ovsFwdCtx,
         return NDIS_STATUS_FAILURE;
     }
     bufferStart += NET_BUFFER_CURRENT_MDL_OFFSET(curNb);
-    RtlCopyMemory(tempBuffer, bufferStart, shiftOffset);
-    RtlCopyMemory(bufferStart + shiftLength, tempBuffer, shiftOffset);
+    /* XXX At the momemnt !bufferData means it should be treated as VLAN. We
+     * should split the function and refactor. */
+    if (!bufferData) {
+        EthHdr *ethHdr = (EthHdr *)bufferStart;
+        /* If the frame is not VLAN make it a no op */
+        if (ethHdr->Type != ETH_TYPE_802_1PQ_NBO) {
+            return NDIS_STATUS_SUCCESS;
+        }
+    }
+    RtlMoveMemory(bufferStart + shiftLength, bufferStart, shiftOffset);
     NdisAdvanceNetBufferDataStart(curNb, shiftLength, FALSE, NULL);
 
     if (bufferData) {
-- 
2.9.2.windows.1



More information about the dev mailing list