[ovs-dev] datapath-windows: Tunnel filter initialization check
diff mbox

Message ID 1441105264-10353-1-git-send-email-svinturis@cloudbasesolutions.com
State Accepted
Headers show

Commit Message

Sorin Vinturis Sept. 2, 2015, 4:30 p.m. UTC
Verify if the tunnel filter is initialized before submitting requests.

Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
Reported-at: https://github.com/openvswitch/ovs-issues/issues/100
---
 datapath-windows/ovsext/TunnelFilter.c | 71 +++++++++++++++++++++++-----------
 1 file changed, 48 insertions(+), 23 deletions(-)

Comments

Nithin Raju Sept. 3, 2015, 2:18 p.m. UTC | #1
> On Sep 2, 2015, at 9:30 AM, Sorin Vinturis <svinturis@cloudbasesolutions.com> wrote:
> 
> Verify if the tunnel filter is initialized before submitting requests.
> 
> Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
> Reported-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
> Reported-at: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_openvswitch_ovs-2Dissues_issues_100&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=pNHQcdr7B40b4h6Yb7FIedI1dnBsxdDuTLBYD3JqV80&m=2nGvmsCDTDdyyhZa0oS-VW5I3bR194bTi04ou3j5KFM&s=3X78mGHEeExIP5hrcxN61x8Um8RhohMBCPWD7cnK4-Q&e= 

Acked-by: Nithin Raju <nithin@vmware.com>
Sorin Vinturis Sept. 4, 2015, 7:01 p.m. UTC | #2
Hi Ben,

Could you please apply this patch to master and branch-2.4?

Thanks,
Sorin

-----Original Message-----
From: Nithin Raju [mailto:nithin@vmware.com] 
Sent: Thursday, 3 September, 2015 17:18
To: Sorin Vinturis
Cc: dev@openvswitch.org
Subject: Re: [ovs-dev] [PATCH] datapath-windows: Tunnel filter initialization check

> On Sep 2, 2015, at 9:30 AM, Sorin Vinturis <svinturis@cloudbasesolutions.com> wrote:
> 
> Verify if the tunnel filter is initialized before submitting requests.
> 
> Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
> Reported-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
> Reported-at: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_openvswitch_ovs-2Dissues_issues_100&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=pNHQcdr7B40b4h6Yb7FIedI1dnBsxdDuTLBYD3JqV80&m=2nGvmsCDTDdyyhZa0oS-VW5I3bR194bTi04ou3j5KFM&s=3X78mGHEeExIP5hrcxN61x8Um8RhohMBCPWD7cnK4-Q&e= 

Acked-by: Nithin Raju <nithin@vmware.com>
Ben Pfaff Sept. 4, 2015, 11:47 p.m. UTC | #3
Done.

On Fri, Sep 04, 2015 at 07:01:08PM +0000, Sorin Vinturis wrote:
> Hi Ben,
> 
> Could you please apply this patch to master and branch-2.4?
> 
> Thanks,
> Sorin
> 
> -----Original Message-----
> From: Nithin Raju [mailto:nithin@vmware.com] 
> Sent: Thursday, 3 September, 2015 17:18
> To: Sorin Vinturis
> Cc: dev@openvswitch.org
> Subject: Re: [ovs-dev] [PATCH] datapath-windows: Tunnel filter initialization check
> 
> > On Sep 2, 2015, at 9:30 AM, Sorin Vinturis <svinturis@cloudbasesolutions.com> wrote:
> > 
> > Verify if the tunnel filter is initialized before submitting requests.
> > 
> > Signed-off-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
> > Reported-by: Sorin Vinturis <svinturis@cloudbasesolutions.com>
> > Reported-at: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_openvswitch_ovs-2Dissues_issues_100&d=BQIGaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=pNHQcdr7B40b4h6Yb7FIedI1dnBsxdDuTLBYD3JqV80&m=2nGvmsCDTDdyyhZa0oS-VW5I3bR194bTi04ou3j5KFM&s=3X78mGHEeExIP5hrcxN61x8Um8RhohMBCPWD7cnK4-Q&e= 
> 
> Acked-by: Nithin Raju <nithin@vmware.com>
>

Patch
diff mbox

diff --git a/datapath-windows/ovsext/TunnelFilter.c b/datapath-windows/ovsext/TunnelFilter.c
index a359cac..46f756e 100644
--- a/datapath-windows/ovsext/TunnelFilter.c
+++ b/datapath-windows/ovsext/TunnelFilter.c
@@ -121,7 +121,7 @@  typedef struct _OVS_TUNFLT_REQUEST {
         UINT64                  delID;
         /* Pointer used to return filter ID to the caller on filter creation. */
         PUINT64                 addID;
-    }filterID;
+    } filterID;
     /* Requested operation to be performed. */
     OVS_TUNFLT_OPERATION    operation;
     /* Current I/O request to be completed when requested
@@ -147,6 +147,8 @@  typedef struct _OVS_TUNFLT_REQUEST_LIST {
 typedef struct _OVS_TUNFLT_THREAD_CONTEXT {
     /* Thread identification. */
     UINT                    threadID;
+    /* Thread initialization flag. */
+    UINT32                  isInitialized;
     /* Thread's engine session handle. */
     HANDLE                  engineSession;
     /* Reference of the thread object. */
@@ -1091,6 +1093,9 @@  OvsTunnelFilterRequestPush(POVS_TUNFLT_REQUEST_LIST listRequests,
  * request queue. The arrival of the new request is signaled to the thread,
  * in order to start processing it.
  *
+ * Note:
+ * If the thread is not initialized, no operation is performed.
+ *
  * For a uniform distribution of requests to thread queues, a thread index is
  * calculated based on the received destination port.
  * --------------------------------------------------------------------------
@@ -1098,19 +1103,32 @@  OvsTunnelFilterRequestPush(POVS_TUNFLT_REQUEST_LIST listRequests,
 NTSTATUS
 OvsTunnelFilterThreadPush(POVS_TUNFLT_REQUEST request)
 {
-    NTSTATUS status = STATUS_SUCCESS;
+    NTSTATUS status = STATUS_REQUEST_ABORTED;
+    UINT32 count = OVS_TUNFLT_MAX_THREADS;
     UINT32 threadIndex;
 
     threadIndex = request->port % OVS_TUNFLT_MAX_THREADS;
 
-    status = OvsTunnelFilterRequestPush(
-        &gTunnelThreadCtx[threadIndex].listRequests,
-        request);
+    while (count--) {
+        if (gTunnelThreadCtx[threadIndex].isInitialized) {
 
-    if (NT_SUCCESS(status)) {
-        KeSetEvent(&gTunnelThreadCtx[threadIndex].requestEvent,
-                   IO_NO_INCREMENT,
-                   FALSE);
+            status = OvsTunnelFilterRequestPush(
+                &gTunnelThreadCtx[threadIndex].listRequests,
+                request);
+
+            if (NT_SUCCESS(status)) {
+                KeSetEvent(&gTunnelThreadCtx[threadIndex].requestEvent,
+                           IO_NO_INCREMENT,
+                           FALSE);
+            }
+
+            break;
+        } else {
+            OVS_LOG_INFO("OVS tunnel filter thread %d not initialized.",
+                         threadIndex);
+        }
+
+        threadIndex = (threadIndex + 1) % OVS_TUNFLT_MAX_THREADS;
     }
 
     return status;
@@ -1333,20 +1351,23 @@  static VOID
 OvsTunnelFilterThreadStop(POVS_TUNFLT_THREAD_CONTEXT threadCtx,
                           BOOLEAN signalEvent)
 {
-    if (signalEvent) {
-        /* Signal stop thread event. */
-        OVS_LOG_INFO("Received stop event for OVS Tunnel system thread %d.",
-                     threadCtx->threadID);
-        KeSetEvent(&threadCtx->stopEvent, IO_NO_INCREMENT, FALSE);
-    } else {
-        /* Wait for the tunnel thread to finish. */
-        KeWaitForSingleObject(threadCtx->threadObject,
-                              Executive,
-                              KernelMode,
-                              FALSE,
-                              NULL);
-
-        ObDereferenceObject(threadCtx->threadObject);
+    if (threadCtx->isInitialized) {
+
+        if (signalEvent) {
+            /* Signal stop thread event. */
+            OVS_LOG_INFO("Received stop event for OVS Tunnel system thread %d.",
+                         threadCtx->threadID);
+            KeSetEvent(&threadCtx->stopEvent, IO_NO_INCREMENT, FALSE);
+        } else {
+            /* Wait for the tunnel thread to finish. */
+            KeWaitForSingleObject(threadCtx->threadObject,
+                                  Executive,
+                                  KernelMode,
+                                  FALSE,
+                                  NULL);
+
+            ObDereferenceObject(threadCtx->threadObject);
+        }
     }
 }
 
@@ -1382,6 +1403,8 @@  OvsTunnelFilterThreadInit(POVS_TUNFLT_THREAD_CONTEXT threadCtx)
             SynchronizationEvent,
             FALSE);
 
+        threadCtx->isInitialized = TRUE;
+
         error = FALSE;
     } while (error);
 
@@ -1402,6 +1425,8 @@  OvsTunnelFilterThreadUninit(POVS_TUNFLT_THREAD_CONTEXT threadCtx)
         OvsTunnelEngineClose(&threadCtx->engineSession);
 
         NdisFreeSpinLock(&threadCtx->listRequests.spinlock);
+
+        threadCtx->isInitialized = FALSE;
     }
 }