[ovs-dev] [PATCH] datapath-windows: Solved BSOD when loading an activated extension

Sorin Vinturis svinturis at cloudbasesolutions.com
Thu Jan 22 14:12:14 UTC 2015


If the OVS extension was previously enabled and the driver unloaded,
when the driver is loaded again a BSOD is triggered.

This happens because the OVS extension registers its FilterXxx routines
to NDIS, by calling NdisFRegisterFilterDriver, before performing all
the necessary initialization. Because drivers that call
NdisFRegisterFilterDriver must be prepared for an immediate call to any
of their FilterXxx functions.

The BSOD is triggered because the FilterAttach routine, OvsExtAttach,
tries to acquire the control lock, when the lock is not yet initialized.
This happens because the FilterAttach is called before the driver
finishes initialization, in OvsInit().

The solution is to perform all necessary initialization before
registering OVS FilterXxx routines.

Signed-off-by: Sorin Vinturis <svinturis at cloudbasesolutions.com>
Reported-by: Sorin Vinturis <svinturis at cloudbasesolutions.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/67

---
 datapath-windows/ovsext/Datapath.c | 5 +----
 datapath-windows/ovsext/Datapath.h | 2 ++
 datapath-windows/ovsext/Driver.c   | 7 +++++++
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-windows/ovsext/Datapath.c
index 0665412..8eb13f1 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -448,10 +448,8 @@ OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle)
         if (ovsExt) {
             ovsExt->numberOpenInstance = 0;
         }
-    } else {
-        /* Initialize the associated data structures. */
-        OvsInit();
     }
+
     OVS_LOG_TRACE("DeviceObject: %p", gOvsDeviceObject);
     return status;
 }
@@ -474,7 +472,6 @@ OvsDeleteDeviceObject()
         gOvsDeviceHandle = NULL;
         gOvsDeviceObject = NULL;
     }
-    OvsCleanup();
 }
 
 POVS_OPEN_INSTANCE
diff --git a/datapath-windows/ovsext/Datapath.h b/datapath-windows/ovsext/Datapath.h
index 2e3bac5..ba31ece 100644
--- a/datapath-windows/ovsext/Datapath.h
+++ b/datapath-windows/ovsext/Datapath.h
@@ -81,6 +81,8 @@ typedef struct _OVS_OPEN_INSTANCE {
 
 NDIS_STATUS OvsCreateDeviceObject(NDIS_HANDLE ovsExtDriverHandle);
 VOID OvsDeleteDeviceObject();
+VOID OvsInit();
+VOID OvsCleanup();
 
 POVS_OPEN_INSTANCE OvsGetOpenInstance(PFILE_OBJECT fileObject,
                                       UINT32 dpNo);
diff --git a/datapath-windows/ovsext/Driver.c b/datapath-windows/ovsext/Driver.c
index 0a9c35a..0c3c479 100644
--- a/datapath-windows/ovsext/Driver.c
+++ b/datapath-windows/ovsext/Driver.c
@@ -95,6 +95,9 @@ DriverEntry(PDRIVER_OBJECT driverObject,
 
     UNREFERENCED_PARAMETER(registryPath);
 
+    /* Initialize driver associated data structures. */
+    OvsInit();
+
     gOvsExtDriverObject = driverObject;
 
     RtlZeroMemory(&driverChars, sizeof driverChars);
@@ -163,7 +166,11 @@ OvsExtUnload(struct _DRIVER_OBJECT *driverObject)
 {
     UNREFERENCED_PARAMETER(driverObject);
 
+    /* Release driver associated data structures. */
+    OvsCleanup();
+
     OvsDeleteDeviceObject();
+
     NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
 }
 
-- 
1.9.0.msysgit.0



More information about the dev mailing list