Skip to content

Commit

Permalink
datapath-windows: Added specific pool tag for switch code
Browse files Browse the repository at this point in the history
All memory allocations within switch code have 'SSVO' pool tag.

Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Reported-at: openvswitch/ovs-issues#56
Acked-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
Acked-by: Eitan Eliahu <eliahue@vmware.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
  • Loading branch information
svinturis authored and blp committed Mar 26, 2015
1 parent 5b55d0a commit ba7f9d9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
53 changes: 30 additions & 23 deletions datapath-windows/ovsext/Switch.c
Expand Up @@ -168,8 +168,8 @@ OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,

OVS_LOG_TRACE("Enter: Create switch object");

switchContext =
(POVS_SWITCH_CONTEXT) OvsAllocateMemory(sizeof(OVS_SWITCH_CONTEXT));
switchContext = (POVS_SWITCH_CONTEXT) OvsAllocateMemoryWithTag(
sizeof(OVS_SWITCH_CONTEXT), OVS_SWITCH_POOL_TAG);
if (switchContext == NULL) {
status = NDIS_STATUS_RESOURCES;
goto create_switch_done;
Expand All @@ -187,7 +187,7 @@ OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,
if (status != NDIS_STATUS_SUCCESS) {
OVS_LOG_ERROR("OvsExtAttach: Extension is running in "
"non-switch environment.");
OvsFreeMemory(switchContext);
OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
goto create_switch_done;
}

Expand All @@ -198,14 +198,14 @@ OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,

status = OvsInitSwitchContext(switchContext);
if (status != NDIS_STATUS_SUCCESS) {
OvsFreeMemory(switchContext);
OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
goto create_switch_done;
}

status = OvsTunnelFilterInitialize(gOvsExtDriverObject);
if (status != NDIS_STATUS_SUCCESS) {
OvsUninitSwitchContext(switchContext);
OvsFreeMemory(switchContext);
OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
goto create_switch_done;
}
*switchContextOut = switchContext;
Expand Down Expand Up @@ -264,7 +264,7 @@ OvsDeleteSwitch(POVS_SWITCH_CONTEXT switchContext)
OvsTunnelFilterUninitialize(gOvsExtDriverObject);
OvsClearAllSwitchVports(switchContext);
OvsUninitSwitchContext(switchContext);
OvsFreeMemory(switchContext);
OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
}
OVS_LOG_TRACE("Exit: deleted switch %p dpNo: %d", switchContext, dpNo);
}
Expand Down Expand Up @@ -358,14 +358,14 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
switchContext->dispatchLock =
NdisAllocateRWLock(switchContext->NdisFilterHandle);

switchContext->portNoHashArray = (PLIST_ENTRY)
OvsAllocateMemory(sizeof(LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
switchContext->ovsPortNameHashArray = (PLIST_ENTRY)
OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
switchContext->portIdHashArray= (PLIST_ENTRY)
OvsAllocateMemory(sizeof (LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE);
switchContext->pidHashArray = (PLIST_ENTRY)
OvsAllocateMemory(sizeof(LIST_ENTRY) * OVS_MAX_PID_ARRAY_SIZE);
switchContext->portNoHashArray = (PLIST_ENTRY)OvsAllocateMemoryWithTag(
sizeof(LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE, OVS_SWITCH_POOL_TAG);
switchContext->ovsPortNameHashArray = (PLIST_ENTRY)OvsAllocateMemoryWithTag(
sizeof(LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE, OVS_SWITCH_POOL_TAG);
switchContext->portIdHashArray= (PLIST_ENTRY)OvsAllocateMemoryWithTag(
sizeof(LIST_ENTRY) * OVS_MAX_VPORT_ARRAY_SIZE, OVS_SWITCH_POOL_TAG);
switchContext->pidHashArray = (PLIST_ENTRY)OvsAllocateMemoryWithTag(
sizeof(LIST_ENTRY) * OVS_MAX_PID_ARRAY_SIZE, OVS_SWITCH_POOL_TAG);
status = OvsAllocateFlowTable(&switchContext->datapath, switchContext);

if (status == NDIS_STATUS_SUCCESS) {
Expand All @@ -381,17 +381,20 @@ OvsInitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
NdisFreeRWLock(switchContext->dispatchLock);
}
if (switchContext->portNoHashArray) {
OvsFreeMemory(switchContext->portNoHashArray);
OvsFreeMemoryWithTag(switchContext->portNoHashArray,
OVS_SWITCH_POOL_TAG);
}
if (switchContext->ovsPortNameHashArray) {
OvsFreeMemory(switchContext->ovsPortNameHashArray);
OvsFreeMemoryWithTag(switchContext->ovsPortNameHashArray,
OVS_SWITCH_POOL_TAG);
}
if (switchContext->portIdHashArray) {
OvsFreeMemory(switchContext->portIdHashArray);
OvsFreeMemoryWithTag(switchContext->portIdHashArray,
OVS_SWITCH_POOL_TAG);
}

if (switchContext->pidHashArray) {
OvsFreeMemory(switchContext->pidHashArray);
OvsFreeMemoryWithTag(switchContext->pidHashArray,
OVS_SWITCH_POOL_TAG);
}

OvsDeleteFlowTable(&switchContext->datapath);
Expand Down Expand Up @@ -437,13 +440,17 @@ OvsUninitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
NdisFreeRWLock(switchContext->dispatchLock);
switchContext->dispatchLock = NULL;
NdisFreeSpinLock(&(switchContext->pidHashLock));
OvsFreeMemory(switchContext->ovsPortNameHashArray);
OvsFreeMemoryWithTag(switchContext->ovsPortNameHashArray,
OVS_SWITCH_POOL_TAG);
switchContext->ovsPortNameHashArray = NULL;
OvsFreeMemory(switchContext->portIdHashArray);
OvsFreeMemoryWithTag(switchContext->portIdHashArray,
OVS_SWITCH_POOL_TAG);
switchContext->portIdHashArray = NULL;
OvsFreeMemory(switchContext->portNoHashArray);
OvsFreeMemoryWithTag(switchContext->portNoHashArray,
OVS_SWITCH_POOL_TAG);
switchContext->portNoHashArray = NULL;
OvsFreeMemory(switchContext->pidHashArray);
OvsFreeMemoryWithTag(switchContext->pidHashArray,
OVS_SWITCH_POOL_TAG);
switchContext->pidHashArray = NULL;
OvsDeleteFlowTable(&switchContext->datapath);
OvsCleanupBufferPool(switchContext);
Expand Down
1 change: 1 addition & 0 deletions datapath-windows/ovsext/Util.h
Expand Up @@ -30,6 +30,7 @@
#define OVS_VXLAN_POOL_TAG 'XSVO'
#define OVS_IPHELPER_POOL_TAG 'HSVO'
#define OVS_OID_POOL_TAG 'ASVO'
#define OVS_SWITCH_POOL_TAG 'SSVO'

VOID *OvsAllocateMemory(size_t size);
VOID *OvsAllocateMemoryWithTag(size_t size, ULONG tag);
Expand Down

0 comments on commit ba7f9d9

Please sign in to comment.