summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/BufferMgmt.c
diff options
context:
space:
mode:
authorAnand Kumar <kumaranand@vmware.com>2019-04-11 09:14:21 -0700
committerAlin Gabriel Serdean <aserdean@ovn.org>2019-04-25 02:08:32 +0300
commit5406e557b00043e60e925c9500f492ff2e8176fe (patch)
tree409cf283b789e2cdee5cc36426a9efcbb3cee73c /datapath-windows/ovsext/BufferMgmt.c
parent0cdd5b13de91b989dc92246e20ee6d528417df97 (diff)
downloadopenvswitch-5406e557b00043e60e925c9500f492ff2e8176fe.tar.gz
datapath-windows: Do not send out nbls when cloned nbls are being accessed
As per MSDN documentation, "As soon as a filter driver calls the NdisFSendNetBufferLists function, it relinquishes ownership of the NET_BUFFER_LIST structures and all associated resources. A filter driver should never try to examine the NET_BUFFER_LIST structures or any associated data after calling NdisFSendNetBufferLists". https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/content/ndis/nf-ndis-ndisfsendnetbufferlists When freeing up memory of a cloned nbl, parent's nbl and context is being accessed, which is incorrect can cause BSOD. With this patch, original nbl is sent out only when cloned nbl is done with packet processing and its memory is freed. Signed-off-by: Anand Kumar <kumaranand@vmware.com> Acked-by: Alin Gabriel Serdean <aserdean@ovn.org> Signed-off-by: Alin Gabriel Serdean <aserdean@ovn.org>
Diffstat (limited to 'datapath-windows/ovsext/BufferMgmt.c')
-rw-r--r--datapath-windows/ovsext/BufferMgmt.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/datapath-windows/ovsext/BufferMgmt.c b/datapath-windows/ovsext/BufferMgmt.c
index 47d872df2..6627acf25 100644
--- a/datapath-windows/ovsext/BufferMgmt.c
+++ b/datapath-windows/ovsext/BufferMgmt.c
@@ -81,6 +81,7 @@
#include "Flow.h"
#include "Offload.h"
#include "NetProto.h"
+#include "PacketIO.h"
#include "PacketParser.h"
#include "Switch.h"
#include "Vport.h"
@@ -267,6 +268,7 @@ OvsInitNBLContext(POVS_BUFFER_CONTEXT ctx,
ctx->srcPortNo = srcPortNo;
ctx->origDataLength = origDataLength;
ctx->mru = 0;
+ ctx->pendingSend = 0;
}
@@ -1746,8 +1748,13 @@ OvsCompleteNBL(PVOID switch_ctx,
if (parent != NULL) {
ctx = (POVS_BUFFER_CONTEXT)NET_BUFFER_LIST_CONTEXT_DATA_START(parent);
ASSERT(ctx && ctx->magic == OVS_CTX_MAGIC);
+ UINT16 pendingSend = 1, exchange = 0;
value = InterlockedDecrement((LONG volatile *)&ctx->refCount);
- if (value == 0) {
+ InterlockedCompareExchange16((SHORT volatile *)&pendingSend, exchange, (SHORT)ctx->pendingSend);
+ if (value == 1 && pendingSend == exchange) {
+ InterlockedExchange16((SHORT volatile *)&ctx->pendingSend, 0);
+ OvsSendNBLIngress(context, parent, ctx->sendFlags);
+ } else if (value == 0){
return OvsCompleteNBL(context, parent, FALSE);
}
}