That's a good catch. Thanks Nithin!

Acked-by: Sorin Vinturis <svintu...@cloudbasesolutions.com>

-----Original Message-----
From: dev [mailto:dev-boun...@openvswitch.org] On Behalf Of Nithin Raju
Sent: Thursday, 23 April, 2015 03:10
To: dev@openvswitch.org
Subject: [ovs-dev] [PATCH] datapath-windows: don't free switch cxt until ref == 0

This is a hard to hit corner case, because currently we recommend that all 
handles to the kernel datapath be closed before trying to unload the OVS 
extension.

Signed-off-by: Nithin Raju <nit...@vmware.com>
---
 datapath-windows/ovsext/Switch.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c
index 4f4591f..9dd2ef3 100644
--- a/datapath-windows/ovsext/Switch.c
+++ b/datapath-windows/ovsext/Switch.c
@@ -211,7 +211,6 @@ OvsCreateSwitch(NDIS_HANDLE ndisFilterHandle,
     status = OvsTunnelFilterInitialize(gOvsExtDriverObject);
     if (status != NDIS_STATUS_SUCCESS) {
         OvsUninitSwitchContext(switchContext);
-        OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
         goto create_switch_done;
     }
     *switchContextOut = switchContext;
@@ -270,7 +269,6 @@ OvsDeleteSwitch(POVS_SWITCH_CONTEXT switchContext)
         OvsTunnelFilterUninitialize(gOvsExtDriverObject);
         OvsClearAllSwitchVports(switchContext);
         OvsUninitSwitchContext(switchContext);
-        OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
     }
     OVS_LOG_TRACE("Exit: deleted switch %p  dpNo: %d", switchContext, dpNo);  
} @@ -441,7 +439,12 @@ OvsUninitSwitchContext(POVS_SWITCH_CONTEXT switchContext)
     OvsReleaseSwitchContext(switchContext);
 }
 
-VOID
+/*
+ * 
+-----------------------------------------------------------------------
+---
+ *  Frees up the contents of and also the switch context.
+ * 
+-----------------------------------------------------------------------
+---
+ */
+static VOID
 OvsDeleteSwitchContext(POVS_SWITCH_CONTEXT switchContext)  {
     OVS_LOG_TRACE("Enter: Delete switchContext:%p", switchContext); @@ -467,6 
+470,8 @@ OvsDeleteSwitchContext(POVS_SWITCH_CONTEXT switchContext)
     switchContext->pidHashArray = NULL;
     OvsDeleteFlowTable(&switchContext->datapath);
     OvsCleanupBufferPool(switchContext);
+
+    OvsFreeMemoryWithTag(switchContext, OVS_SWITCH_POOL_TAG);
     OVS_LOG_TRACE("Exit: Delete switchContext: %p", switchContext);  }
 
--
1.8.5.6

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to