From patchwork Fri May 13 02:09:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nithin Raju X-Patchwork-Id: 621820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (archives.nicira.com [96.126.127.54]) by ozlabs.org (Postfix) with ESMTP id 3r5YG956T8z9sBX for ; Fri, 13 May 2016 12:09:53 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id BCC2922C3E7; Thu, 12 May 2016 19:09:50 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v3.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id 29D3622C3D8 for ; Thu, 12 May 2016 19:09:47 -0700 (PDT) Received: from bar6.cudamail.com (localhost [127.0.0.1]) by mx3v3.cudamail.com (Postfix) with ESMTPS id B5FBB1617E8 for ; Thu, 12 May 2016 20:09:46 -0600 (MDT) X-ASG-Debug-ID: 1463105386-0b32370aa791e30001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar6.cudamail.com with ESMTP id gpeEt81QkxAhU0F2 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Thu, 12 May 2016 20:09:46 -0600 (MDT) X-Barracuda-Envelope-From: nithin@vmware.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO smtp-outbound-1.vmware.com) (208.91.2.12) by mx3-pf3.cudamail.com with ESMTPS (DHE-RSA-AES256-SHA encrypted); 13 May 2016 02:09:46 -0000 Received-SPF: error (mx3-pf3.cudamail.com: error in processing during lookup of vmware.com: DNS problem) X-Barracuda-Apparent-Source-IP: 208.91.2.12 X-Barracuda-RBL-IP: 208.91.2.12 Received: from sc9-mailhost2.vmware.com (sc9-mailhost2.vmware.com [10.113.161.72]) by smtp-outbound-1.vmware.com (Postfix) with ESMTP id A6049984C1 for ; Thu, 12 May 2016 19:09:45 -0700 (PDT) Received: from sc9-mailhost2.vmware.com (unknown [10.129.195.49]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 54BDDB043E; Thu, 12 May 2016 19:09:45 -0700 (PDT) X-CudaMail-Envelope-Sender: nithin@vmware.com From: Nithin Raju To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-511060978 X-CudaMail-DTE: 051216 X-CudaMail-Originating-IP: 208.91.2.12 Date: Thu, 12 May 2016 19:09:29 -0700 X-ASG-Orig-Subj: [##CM-V3-511060978##][PATCH 3/3] datapath-windows: Use l2 port and tunkey during execute Message-Id: <1463105369-3524-3-git-send-email-nithin@vmware.com> X-Mailer: git-send-email 2.7.1.windows.1 In-Reply-To: <1463105369-3524-1-git-send-email-nithin@vmware.com> References: <1463105369-3524-1-git-send-email-nithin@vmware.com> X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1463105386 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 X-ASG-Whitelist: EmailCat (corporate) Subject: [ovs-dev] [PATCH 3/3] datapath-windows: Use l2 port and tunkey during execute 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: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" While testing DFW and recirc code it was found that userspace was calling into packet execute with the tunnel key and the vport added as part of the execute structure. We were not passing this along to the code that executes actions. The right thing is to contruct the key based on all of the attributes sent down from userspace. Signed-off-by: Nithin Raju --- datapath-windows/ovsext/User.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c index 3b3f662..2312940 100644 --- a/datapath-windows/ovsext/User.c +++ b/datapath-windows/ovsext/User.c @@ -51,6 +51,8 @@ static VOID _MapNlAttrToOvsPktExec(PNL_MSG_HDR nlMsgHdr, PNL_ATTR *nlAttrs, OvsPacketExecute *execute); extern NL_POLICY nlFlowKeyPolicy[]; extern UINT32 nlFlowKeyPolicyLen; +extern NL_POLICY nlFlowTunnelKeyPolicy[]; +extern UINT32 nlFlowTunnelKeyPolicyLen; static __inline VOID OvsAcquirePidHashLock() @@ -375,6 +377,7 @@ _MapNlAttrToOvsPktExec(PNL_MSG_HDR nlMsgHdr, PNL_ATTR *nlAttrs, execute->actions = NlAttrGet(nlAttrs[OVS_PACKET_ATTR_ACTIONS]); execute->actionsLen = NlAttrGetSize(nlAttrs[OVS_PACKET_ATTR_ACTIONS]); + ASSERT(keyAttrs[OVS_KEY_ATTR_IN_PORT]); execute->inPort = NlAttrGetU32(keyAttrs[OVS_KEY_ATTR_IN_PORT]); execute->keyAttrs = keyAttrs; } @@ -391,6 +394,8 @@ OvsExecuteDpIoctl(OvsPacketExecute *execute) OvsFlowKey key = { 0 }; OVS_PACKET_HDR_INFO layers = { 0 }; POVS_VPORT_ENTRY vport = NULL; + PNL_ATTR tunnelAttrs[__OVS_TUNNEL_KEY_ATTR_MAX]; + OvsFlowKey tempTunKey = {0}; if (execute->packetLen == 0) { status = STATUS_INVALID_PARAMETER; @@ -428,8 +433,31 @@ OvsExecuteDpIoctl(OvsPacketExecute *execute) goto dropit; } - ndisStatus = OvsExtractFlow(pNbl, fwdDetail->SourcePortId, &key, &layers, - NULL); + if (execute->keyAttrs[OVS_KEY_ATTR_TUNNEL]) { + UINT32 tunnelKeyAttrOffset; + + tunnelKeyAttrOffset = (UINT32)((PCHAR) + (execute->keyAttrs[OVS_KEY_ATTR_TUNNEL]) + - (PCHAR)execute->nlMsgHdr); + + /* Get tunnel keys attributes */ + if ((NlAttrParseNested(execute->nlMsgHdr, tunnelKeyAttrOffset, + NlAttrLen(execute->keyAttrs[OVS_KEY_ATTR_TUNNEL]), + nlFlowTunnelKeyPolicy, nlFlowTunnelKeyPolicyLen, + tunnelAttrs, ARRAY_SIZE(tunnelAttrs))) + != TRUE) { + OVS_LOG_ERROR("Tunnel key Attr Parsing failed for msg: %p", + execute->nlMsgHdr); + status = STATUS_INVALID_PARAMETER; + goto dropit; + } + + MapTunAttrToFlowPut(execute->keyAttrs, tunnelAttrs, &tempTunKey); + } + + ndisStatus = OvsExtractFlow(pNbl, execute->inPort, &key, &layers, + tempTunKey.tunKey.dst == 0 ? NULL : &tempTunKey.tunKey); + if (ndisStatus == NDIS_STATUS_SUCCESS) { NdisAcquireRWLockRead(gOvsSwitchContext->dispatchLock, &lockState, 0); ndisStatus = OvsActionsExecute(gOvsSwitchContext, NULL, pNbl,