From patchwork Wed Sep 2 16:30:08 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sorin Vinturis X-Patchwork-Id: 513572 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (li376-54.members.linode.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id E9DC414018C for ; Thu, 3 Sep 2015 02:30:43 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 7D87D10A87; Wed, 2 Sep 2015 09:30:42 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id F0C57109EF for ; Wed, 2 Sep 2015 09:30:40 -0700 (PDT) Received: from bar3.cudamail.com (bar1 [192.168.15.1]) by mx3v1.cudamail.com (Postfix) with ESMTP id E9649619225 for ; Wed, 2 Sep 2015 10:30:39 -0600 (MDT) X-ASG-Debug-ID: 1441211434-03dd7b127d43c550001-byXFYA Received: from mx3-pf2.cudamail.com ([192.168.14.1]) by bar3.cudamail.com with ESMTP id UIjgPPMGAmyBw9FT (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 02 Sep 2015 10:30:34 -0600 (MDT) X-Barracuda-Envelope-From: svinturis@cloudbasesolutions.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.1 Received: from unknown (HELO cbssmtp1.cloudbase.local) (91.232.152.5) by mx3-pf2.cudamail.com with SMTP; 2 Sep 2015 16:30:32 -0000 Received-SPF: pass (mx3-pf2.cudamail.com: SPF record at cloudbasesolutions.com designates 91.232.152.5 as permitted sender) X-Barracuda-Apparent-Source-IP: 91.232.152.5 X-Barracuda-RBL-IP: 91.232.152.5 Received: from localhost (localhost [127.0.0.1]) by cbssmtp1.cloudbase.local (Postfix) with ESMTP id CFC31423F6 for ; Wed, 2 Sep 2015 19:30:30 +0300 (EEST) X-Virus-Scanned: amavisd-new at cloudbasesolutions.com Received: from cbssmtp1.cloudbase.local ([127.0.0.1]) by localhost (cbssmtp1.cloudbase.local [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Lqll-6fKarQQ for ; Wed, 2 Sep 2015 19:30:10 +0300 (EEST) Received: from CBSEX1.cloudbase.local (unknown [10.77.78.3]) by cbssmtp1.cloudbase.local (Postfix) with ESMTP id 7A74242400 for ; Wed, 2 Sep 2015 19:30:10 +0300 (EEST) Received: from CBSEX1.cloudbase.local ([10.77.78.3]) by CBSEX1.cloudbase.local ([10.77.78.3]) with mapi id 14.03.0224.002; Wed, 2 Sep 2015 18:30:09 +0200 X-CudaMail-Envelope-Sender: svinturis@cloudbasesolutions.com From: Sorin Vinturis To: "dev@openvswitch.org" X-CudaMail-MID: CM-V2-901031220 X-CudaMail-DTE: 090215 X-CudaMail-Originating-IP: 91.232.152.5 Thread-Topic: [PATCH] datapath-windows: Tunnel filter initialization check X-ASG-Orig-Subj: [##CM-V2-901031220##][PATCH] datapath-windows: Tunnel filter initialization check Thread-Index: AQHQ5Zyh8RoWomzb5kakHwt9Y7LH0A== Date: Wed, 2 Sep 2015 16:30:08 +0000 Message-ID: <1441105264-10353-1-git-send-email-svinturis@cloudbasesolutions.com> Accept-Language: en-US, it-IT Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.77.78.1] MIME-Version: 1.0 X-GBUdb-Analysis: 0, 91.232.152.5, Ugly c=0.237282 p=-0.4 Source Normal X-MessageSniffer-Rules: 0-0-0-11445-c X-Barracuda-Connect: UNKNOWN[192.168.14.1] X-Barracuda-Start-Time: 1441211434 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-Barracuda-Spam-Score: 0.10 X-Barracuda-Spam-Status: No, SCORE=0.10 using per-user scores of TAG_LEVEL=3.0 QUARANTINE_LEVEL=1000.0 KILL_LEVEL=3.0 tests=RDNS_NONE X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.3.22158 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- 0.10 RDNS_NONE Delivered to trusted network by a host with no rDNS Subject: [ovs-dev] [PATCH] datapath-windows: Tunnel filter initialization check X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@openvswitch.org Sender: "dev" Verify if the tunnel filter is initialized before submitting requests. Signed-off-by: Sorin Vinturis Reported-by: Sorin Vinturis Reported-at: https://github.com/openvswitch/ovs-issues/issues/100 Acked-by: Nithin Raju Acked-by: Nithin Raju --- datapath-windows/ovsext/TunnelFilter.c | 71 +++++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 23 deletions(-) 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; } }