diff mbox series

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

Message ID 20180403150849.4812-1-aserdean@ovn.org
State RFC
Headers show
Series [ovs-dev] RFC datapath-windows: Create com device only when extension is enabled | expand

Commit Message

Alin-Gabriel Serdean April 3, 2018, 3:08 p.m. UTC
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@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(-)

Comments

Alin-Gabriel Serdean April 5, 2018, 9:32 a.m. UTC | #1
> -----Mesaj original-----
> De la: ovs-dev-bounces@openvswitch.org <ovs-dev-
> bounces@openvswitch.org> În numele Shashank Ram
> Trimis: Wednesday, April 4, 2018 8:31 PM
> Către: Alin Gabriel Serdean <aserdean@ovn.org>; dev@openvswitch.org
> Subiect: Re: [ovs-dev] [PATCH] RFC datapath-windows: Create com device
> only when extension is enabled
> 
> 
> 
> 
> 
> ________________________________________
> From: ovs-dev-bounces@openvswitch.org <ovs-dev-
> bounces@openvswitch.org> on behalf of Alin Gabriel Serdean
> <aserdean@ovn.org>
> Sent: Tuesday, April 3, 2018 8:08 AM
> To: dev@openvswitch.org
> Cc: Alin Gabriel Serdean
> Subject: [ovs-dev] [PATCH] RFC datapath-windows: Create com device only
> when    extension is enabled
> 
> 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@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;
> 
> Why change the status? It would be better to retain the status to whatever is
> returned by OvsCreateDeviceObject()
> 
[Alin Serdean] Ooops. Copy paste error 😊. I should also log the error using 'OVS_LOG_TRACE'.
Does the change fix the issue you encountered?
diff mbox series

Patch

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();