summaryrefslogtreecommitdiff
path: root/datapath-windows/ovsext/TunnelFilter.c
diff options
context:
space:
mode:
authorSorin Vinturis <svinturis@cloudbasesolutions.com>2015-09-02 16:30:08 +0000
committerBen Pfaff <blp@nicira.com>2015-09-04 16:46:55 -0700
commitaa59fe8c228f18941d7a4a5f79179ef01dab83d9 (patch)
treef262d2c3e13fbffcea1f117f2087c538a5194655 /datapath-windows/ovsext/TunnelFilter.c
parentcc474fada66736c91ec3a606bc01a825ccd17bc9 (diff)
downloadopenvswitch-aa59fe8c228f18941d7a4a5f79179ef01dab83d9.tar.gz
datapath-windows: Tunnel filter initialization check
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 Acked-by: Nithin Raju <nithin@vmware.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
Diffstat (limited to 'datapath-windows/ovsext/TunnelFilter.c')
-rw-r--r--datapath-windows/ovsext/TunnelFilter.c71
1 files changed, 48 insertions, 23 deletions
diff --git a/datapath-windows/ovsext/TunnelFilter.c b/datapath-windows/ovsext/TunnelFilter.c
index 8bff27a21..3d5eb5745 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;
}
}