[ovs-dev] [PATCH] RFC datapath-windows: Create com device only when extension is enabled

Alin Gabriel Serdean aserdean at ovn.org
Tue Apr 3 15:08:49 UTC 2018


Until now the communication device between the kernel and userspace
is created when the network driver is installed.

Since we only do processing if the Hyper-V vSwitch extension is enabled by
the user, it makes more sense to move the device creation only when that is true.

Signed-off-by: Alin Gabriel Serdean <aserdean at ovn.org>
---
 datapath-windows/ovsext/Datapath.c |  2 +-
 datapath-windows/ovsext/Driver.c   | 10 ----------
 datapath-windows/ovsext/Switch.c   |  7 +++++++
 3 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/datapath-windows/ovsext/Datapath.c b/datapath-windows/ovsext/Datapath.c
index 34ef2b40a..264cfd3a0 100644
--- a/datapath-windows/ovsext/Datapath.c
+++ b/datapath-windows/ovsext/Datapath.c
@@ -352,7 +352,7 @@ _Dispatch_type_(IRP_MJ_DEVICE_CONTROL)
 DRIVER_DISPATCH OvsDeviceControl;
 
 #ifdef ALLOC_PRAGMA
-#pragma alloc_text(INIT, OvsCreateDeviceObject)
+#pragma alloc_text(PAGE, OvsCreateDeviceObject)
 #pragma alloc_text(PAGE, OvsOpenCloseDevice)
 #pragma alloc_text(PAGE, OvsCleanupDevice)
 #pragma alloc_text(PAGE, OvsDeviceControl)
diff --git a/datapath-windows/ovsext/Driver.c b/datapath-windows/ovsext/Driver.c
index 50c9614e4..39e50c34b 100644
--- a/datapath-windows/ovsext/Driver.c
+++ b/datapath-windows/ovsext/Driver.c
@@ -152,14 +152,6 @@ DriverEntry(PDRIVER_OBJECT driverObject,
         goto cleanup;
     }
 
-    /* Create the communication channel for userspace. */
-    status = OvsCreateDeviceObject(gOvsExtDriverHandle);
-    if (status != NDIS_STATUS_SUCCESS) {
-        NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
-        gOvsExtDriverHandle = NULL;
-        goto cleanup;
-    }
-
 cleanup:
     if (status != NDIS_STATUS_SUCCESS){
         OvsCleanup();
@@ -179,8 +171,6 @@ OvsExtUnload(struct _DRIVER_OBJECT *driverObject)
 {
     UNREFERENCED_PARAMETER(driverObject);
 
-    OvsDeleteDeviceObject();
-
     NdisFDeregisterFilterDriver(gOvsExtDriverHandle);
 
     /* Release driver associated data structures. */
diff --git a/datapath-windows/ovsext/Switch.c b/datapath-windows/ovsext/Switch.c
index 1ac4fa77c..81b897ffe 100644
--- a/datapath-windows/ovsext/Switch.c
+++ b/datapath-windows/ovsext/Switch.c
@@ -73,6 +73,12 @@ OvsExtAttach(NDIS_HANDLE ndisFilterHandle,
     NDIS_STATUS status = NDIS_STATUS_FAILURE;
     NDIS_FILTER_ATTRIBUTES ovsExtAttributes;
     POVS_SWITCH_CONTEXT switchContext = NULL;
+    /* Create the communication channel for userspace. */
+    status = OvsCreateDeviceObject(gOvsExtDriverHandle);
+    if (status != NDIS_STATUS_SUCCESS) {
+        status = NDIS_STATUS_INVALID_PARAMETER;
+        goto cleanup;
+    }
 
     UNREFERENCED_PARAMETER(filterDriverContext);
 
@@ -266,6 +272,7 @@ OvsExtDetach(NDIS_HANDLE filterModuleContext)
     while(switchContext->pendingOidCount > 0) {
         NdisMSleep(1000);
     }
+    OvsDeleteDeviceObject();
     OvsDeleteSwitch(switchContext);
     OvsCleanupIpHelper();
     OvsCleanupSttDefragmentation();
-- 
2.16.1.windows.1



More information about the dev mailing list