Signed-off-by: Sorin Vinturis <[email protected]>
---
datapath-windows/ovsext/PacketIO.c | 99 ++++++++++++++++++--------------------
1 file changed, 47 insertions(+), 52 deletions(-)
diff --git a/datapath-windows/ovsext/PacketIO.c
b/datapath-windows/ovsext/PacketIO.c
index 1f5c8b0..69d7110 100644
--- a/datapath-windows/ovsext/PacketIO.c
+++ b/datapath-windows/ovsext/PacketIO.c
@@ -177,6 +177,29 @@ OvsStartNBLIngressError(POVS_SWITCH_CONTEXT switchContext,
}
static VOID
+OvsAppendNativeForwardedPacket(POVS_SWITCH_CONTEXT switchContext,
+ PNET_BUFFER_LIST curNbl,
+ PNET_BUFFER_LIST *nativeNbls,
+ ULONG flags,
+ BOOLEAN isRecv)
+{
+ POVS_BUFFER_CONTEXT ctx = { 0 };
+ NDIS_STRING filterReason;
+
+ *nativeNbls = curNbl;
+ nativeNbls = &(curNbl->Next);
+
+ ctx = OvsInitExternalNBLContext(switchContext, curNbl, isRecv);
+ if (ctx == NULL) {
+ RtlInitUnicodeString(&filterReason,
+ L"Cannot allocate native NBL context.");
+
+ OvsStartNBLIngressError(switchContext, curNbl, flags, &filterReason,
+ NDIS_STATUS_RESOURCES);
+ }
+}
+
+static VOID
OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
PNET_BUFFER_LIST netBufferLists,
ULONG SendFlags)
@@ -193,9 +216,7 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
LIST_ENTRY missedPackets;
UINT32 num = 0;
OvsCompletionList completionList;
- PNET_BUFFER_LIST ovsForwardedNbls = NULL;
PNET_BUFFER_LIST nativeForwardedNbls = NULL;
- PNET_BUFFER_LIST *nextOvsForwardNbl = &ovsForwardedNbls;
PNET_BUFFER_LIST *nextNativeForwardedNbl = &nativeForwardedNbls;
dispatch = NDIS_TEST_SEND_AT_DISPATCH_LEVEL(SendFlags)?
@@ -206,48 +227,7 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
InitializeListHead(&missedPackets);
OvsInitCompletionList(&completionList, switchContext, sendCompleteFlags);
-#if (NDIS_SUPPORT_NDIS640)
- /*
- * Split NBL list into NBLs to be forwarded by us, and those that require
- * native forwarding.
- */
for (curNbl = netBufferLists; curNbl != NULL; curNbl = nextNbl) {
- nextNbl = curNbl->Next;
- curNbl->Next = NULL;
- fwdDetail = NET_BUFFER_LIST_SWITCH_FORWARDING_DETAIL(curNbl);
-
- if (fwdDetail->NativeForwardingRequired) {
- POVS_BUFFER_CONTEXT ctx;
-
- *nextNativeForwardedNbl = curNbl;
- nextNativeForwardedNbl = &(curNbl->Next);
-
- ctx = OvsInitExternalNBLContext(switchContext, curNbl,
- sourcePort == switchContext->virtualExternalPortId);
- if (ctx == NULL) {
- RtlInitUnicodeString(&filterReason,
- L"Cannot allocate native NBL context.");
-
- OvsStartNBLIngressError(switchContext, curNbl,
- sendCompleteFlags, &filterReason,
- NDIS_STATUS_RESOURCES);
-
- continue;
- }
- } else {
- *nextOvsForwardNbl = curNbl;
- nextOvsForwardNbl = &(curNbl->Next);
- }
- }
-#else
- UNREFERENCED_PARAMETER(nativeForwardedNbls);
- UNREFERENCED_PARAMETER(nextNativeForwardedNbl);
- UNREFERENCED_PARAMETER(nextOvsForwardNbl);
-
- ovsForwardedNbls = netBufferLists;
-#endif
-
- for (curNbl = ovsForwardedNbls; curNbl != NULL; curNbl = nextNbl) {
POVS_VPORT_ENTRY vport;
UINT32 portNo;
OVS_DATAPATH *datapath = &switchContext->datapath;
@@ -255,10 +235,30 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
OvsFlowKey key;
UINT64 hash;
PNET_BUFFER curNb;
+ BOOLEAN isRecv = FALSE;
nextNbl = curNbl->Next;
curNbl->Next = NULL;
+ fwdDetail = NET_BUFFER_LIST_SWITCH_FORWARDING_DETAIL(curNbl);
+ sourcePort = fwdDetail->SourcePortId;
+ sourceIndex = (NDIS_SWITCH_NIC_INDEX)fwdDetail->SourceNicIndex;
+
+ isRecv = (sourcePort == switchContext->virtualExternalPortId) ? TRUE :
+ FALSE;
+
+#if (NDIS_SUPPORT_NDIS640)
+ if (fwdDetail->NativeForwardingRequired) {
+ /* Add current NBL to the those that require native forwarding. */
+ OvsAppendNativeForwardedPacket(switchContext,
+ curNbl,
+ nextNativeForwardedNbl,
+ sendCompleteFlags,
+ isRecv);
+ continue;
+ }
+#endif
+
/* Ethernet Header is a guaranteed safe access. */
curNb = NET_BUFFER_LIST_FIRST_NB(curNbl);
if (curNb->Next != NULL) {
@@ -273,10 +273,6 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
POVS_BUFFER_CONTEXT ctx;
OvsFlow *flow;
- fwdDetail = NET_BUFFER_LIST_SWITCH_FORWARDING_DETAIL(curNbl);
- sourcePort = fwdDetail->SourcePortId;
- sourceIndex = (NDIS_SWITCH_NIC_INDEX)fwdDetail->SourceNicIndex;
-
/* Take the DispatchLock so none of the VPORTs disconnect while
* we are setting destination ports.
*
@@ -285,8 +281,7 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
NdisAcquireRWLockRead(switchContext->dispatchLock, &lockState,
dispatch);
- ctx = OvsInitExternalNBLContext(switchContext, curNbl,
- sourcePort == switchContext->virtualExternalPortId);
+ ctx = OvsInitExternalNBLContext(switchContext, curNbl, isRecv);
if (ctx == NULL) {
RtlInitUnicodeString(&filterReason,
L"Cannot allocate external NBL context.");
@@ -338,9 +333,9 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext,
datapath->misses++;
status = OvsCreateAndAddPackets(NULL, 0, OVS_PACKET_CMD_MISS,
- portNo, &key, curNbl,
- sourcePort ==
switchContext->virtualExternalPortId,
- &layers, switchContext, &missedPackets, &num);
+ portNo, &key, curNbl, isRecv,
+ &layers, switchContext,
+ &missedPackets, &num);
if (status == NDIS_STATUS_SUCCESS) {
/* Complete the packet since it was copied to user
* buffer. */
--
1.9.0.msysgit.0
_______________________________________________
dev mailing list
[email protected]
http://openvswitch.org/mailman/listinfo/dev