> #endif >@@ -299,34 +312,21 @@ OvsDecapGre(POVS_SWITCH_CONTEXT switchContext, > EthHdr *ethHdr; > IPHdr *ipHdr; > GREHdr *greHdr; >- UINT32 tunnelSize = 0, packetLength = 0; >+ UINT32 tunnelSize, packetLength; > UINT32 headRoom = 0; > PUINT8 bufferStart; > NDIS_STATUS status; > > curNb = NET_BUFFER_LIST_FIRST_NB(curNbl); > packetLength = NET_BUFFER_DATA_LENGTH(curNb); >- tunnelSize = GreTunHdrSize(tunKey->flags); >+ curMdl = NET_BUFFER_CURRENT_MDL(curNb); >+ tunnelSize = GreTunHdrSize(0); > if (packetLength <= tunnelSize) { > return NDIS_STATUS_INVALID_LENGTH; > } > >- /* >- * Create a copy of the NBL so that we have all the headers in one >MDL. >- */ >- *newNbl = OvsPartialCopyNBL(switchContext, curNbl, >- tunnelSize + OVS_DEFAULT_COPY_SIZE, 0, >- TRUE /*copy NBL info */); >- >- if (*newNbl == NULL) { >- return NDIS_STATUS_RESOURCES; >- } >- >- curNbl = *newNbl; >- curNb = NET_BUFFER_LIST_FIRST_NB(curNbl); >- curMdl = NET_BUFFER_CURRENT_MDL(curNb); >- bufferStart = (PUINT8)MmGetSystemAddressForMdlSafe(curMdl, >LowPagePriority) + >- NET_BUFFER_CURRENT_MDL_OFFSET(curNb); >+ /* Get a contignuous buffer for the maxmimum length of a GRE header >*/ >+ bufferStart = NdisGetDataBuffer(curNb, OVS_MAX_GRE_LGTH, NULL, 1, 0);
Sorry we have to go back and forth on this. Like I mentioned in the previous email, the idea is to get a contiguous chunk of memory so we can walk all the header until the GRE header. It is a good idea to use NdisGetDataBuffer() instead of copying the NBL. But, we won¹t avoid the copied NBL anyway since decap has to happen on the copied NBL. In any case, NdisGetDataBuffer() has some pitfalls: "If the requested data in the buffer is contiguous, this return value is a pointer to a location that NDIS provides. If the data is not contiguous, NDIS uses the Storage parameter as follows: * If the Storage parameter is non-NULL, NDIS copies the data to the buffer at Storage. This return value is the pointer passed to the Storage parameter. * If the Storage parameter is NULL, this return value is NULL.² So, if the first MDL does not fit the headers until the GRE headers, we need to pass explicit memory to NdisGetDataBuffer() in argument #3 in order for NDIS to copy it over to a contiguous chunk of memory. Thanks, -- Nithin _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev