diff options
author | Shashank Ram <rams@vmware.com> | 2017-07-24 15:31:38 -0700 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2017-08-02 15:54:06 -0700 |
commit | 5071802a6c9090dcd13d39e4e06b550d478ef6fc (patch) | |
tree | 21510d0c0edf8fce310fb84dcc69f0f999911bde /datapath-windows | |
parent | 1bc241690f276c057e8d3590118f687a170bd46a (diff) | |
download | openvswitch-5071802a6c9090dcd13d39e4e06b550d478ef6fc.tar.gz |
datapath-windows: Refactor OvsCreateNewNBLsFromMultipleNBs
Previously, the function would take the curNbl and nextNbl
as inputs, and modify the linked list, and merge the input
linked list with the newly generated newNbl list.
This is confusing for the caller, and the function has
unnecessary logic for merging linked lists that instead
the caller should take care of. This is because the
OvsCreateNewNBLsFromMultipleNBs() is a generic API
that can be used by other functions as well, and its
natural for different callers to have different needs.
This patch refactors the behavior of OvsCreateNewNBLsFromMultipleNBs
to take in the curNbl and lastNbl, and it returns
a linked list of NBLs and sets the HEAD and TAIL of the
new list obtained from the curNbl. If the caller wants
to chain a new linked list at the HEAD or TAIL, it
can make use of the curNbl and lastNbl to do so.
Signed-off-by: Shashank Ram <rams@vmware.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Anand Kumar <kumaranand@vmware.com>
Diffstat (limited to 'datapath-windows')
-rw-r--r-- | datapath-windows/ovsext/PacketIO.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/datapath-windows/ovsext/PacketIO.c b/datapath-windows/ovsext/PacketIO.c index a90b556d4..81c574e75 100644 --- a/datapath-windows/ovsext/PacketIO.c +++ b/datapath-windows/ovsext/PacketIO.c @@ -49,7 +49,7 @@ static VOID OvsCompleteNBLIngress(POVS_SWITCH_CONTEXT switchContext, static NTSTATUS OvsCreateNewNBLsFromMultipleNBs( POVS_SWITCH_CONTEXT switchContext, PNET_BUFFER_LIST *curNbl, - PNET_BUFFER_LIST *nextNbl); + PNET_BUFFER_LIST *lastNbl); VOID OvsInitCompletionList(OvsCompletionList *completionList, @@ -212,7 +212,7 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext, NDIS_SWITCH_PORT_ID sourcePort = 0; NDIS_SWITCH_NIC_INDEX sourceIndex = 0; PNDIS_SWITCH_FORWARDING_DETAIL_NET_BUFFER_LIST_INFO fwdDetail; - PNET_BUFFER_LIST curNbl = NULL, nextNbl = NULL; + PNET_BUFFER_LIST curNbl = NULL, nextNbl = NULL, lastNbl = NULL; ULONG sendCompleteFlags; UCHAR dispatch; LOCK_STATE_EX lockState, dpLockState; @@ -282,7 +282,7 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext, /* Create a NET_BUFFER_LIST for each NET_BUFFER. */ status = OvsCreateNewNBLsFromMultipleNBs(switchContext, &curNbl, - &nextNbl); + &lastNbl); if (!NT_SUCCESS(status)) { RtlInitUnicodeString(&filterReason, L"Cannot allocate NBLs with single NB."); @@ -292,6 +292,10 @@ OvsStartNBLIngress(POVS_SWITCH_CONTEXT switchContext, NDIS_STATUS_RESOURCES); continue; } + + lastNbl->Next = nextNbl; + nextNbl = curNbl->Next; + curNbl->Next = NULL; } { OvsFlow *flow; @@ -500,11 +504,10 @@ OvsExtCancelSendNBL(NDIS_HANDLE filterModuleContext, static NTSTATUS OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT switchContext, PNET_BUFFER_LIST *curNbl, - PNET_BUFFER_LIST *nextNbl) + PNET_BUFFER_LIST *lastNbl) { NTSTATUS status = STATUS_SUCCESS; PNET_BUFFER_LIST newNbls = NULL; - PNET_BUFFER_LIST lastNbl = NULL; PNET_BUFFER_LIST nbl = NULL; BOOLEAN error = TRUE; @@ -520,16 +523,15 @@ OvsCreateNewNBLsFromMultipleNBs(POVS_SWITCH_CONTEXT switchContext, nbl = newNbls; while (nbl) { - lastNbl = nbl; + *lastNbl = nbl; nbl = NET_BUFFER_LIST_NEXT_NBL(nbl); } - lastNbl->Next = *nextNbl; - *nextNbl = newNbls->Next; + + (*curNbl)->Next = NULL; OvsCompleteNBL(switchContext, *curNbl, TRUE); *curNbl = newNbls; - (*curNbl)->Next = NULL; error = FALSE; } while (error); |