From patchwork Wed Feb 27 14:03:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alin-Gabriel Serdean X-Patchwork-Id: 1048900 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=openvswitch.org (client-ip=140.211.169.12; helo=mail.linuxfoundation.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=ovn.org Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 448cyt40txz9s4Z for ; Thu, 28 Feb 2019 01:10:30 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 909048F5A; Wed, 27 Feb 2019 14:09:52 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@mail.linuxfoundation.org Received: from smtp1.linuxfoundation.org (smtp1.linux-foundation.org [172.17.192.35]) by mail.linuxfoundation.org (Postfix) with ESMTPS id 72D8A8F41 for ; Wed, 27 Feb 2019 14:03:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id DB02A80E for ; Wed, 27 Feb 2019 14:03:13 +0000 (UTC) X-Originating-IP: 89.46.161.178 Received: from localhost.localdomain (unknown [89.46.161.178]) (Authenticated sender: aserdean@ovn.org) by relay3-d.mail.gandi.net (Postfix) with ESMTPSA id 957C460015; Wed, 27 Feb 2019 14:03:11 +0000 (UTC) From: Alin Gabriel Serdean To: dev@openvswitch.org Date: Wed, 27 Feb 2019 16:03:03 +0200 Message-Id: <20190227140303.57652-1-aserdean@ovn.org> X-Mailer: git-send-email 2.16.1.windows.1 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Cc: Alin Gabriel Serdean Subject: [ovs-dev] [PATCH] datapath-windows: Guard vport usage in user.c X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org When using a vport we need to guard its usage with the dispatch lock. Signed-off-by: Alin Gabriel Serdean Acked-by: Anand Kumar Acked-by: Sairam Venugopal --- datapath-windows/ovsext/User.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/datapath-windows/ovsext/User.c b/datapath-windows/ovsext/User.c index b43d7cc04..ed1fcbea8 100644 --- a/datapath-windows/ovsext/User.c +++ b/datapath-windows/ovsext/User.c @@ -452,14 +452,6 @@ OvsExecuteDpIoctl(OvsPacketExecute *execute) } fwdDetail = NET_BUFFER_LIST_SWITCH_FORWARDING_DETAIL(pNbl); - vport = OvsFindVportByPortNo(gOvsSwitchContext, execute->inPort); - if (vport) { - fwdDetail->SourcePortId = vport->portId; - fwdDetail->SourceNicIndex = vport->nicIndex; - } else { - fwdDetail->SourcePortId = NDIS_SWITCH_DEFAULT_PORT_ID; - fwdDetail->SourceNicIndex = 0; - } // XXX: Figure out if any of the other members of fwdDetail need to be set. status = OvsGetFlowMetadata(&key, execute->keyAttrs); @@ -502,6 +494,14 @@ OvsExecuteDpIoctl(OvsPacketExecute *execute) if (ndisStatus == NDIS_STATUS_SUCCESS) { NdisAcquireRWLockRead(gOvsSwitchContext->dispatchLock, &lockState, 0); + vport = OvsFindVportByPortNo(gOvsSwitchContext, execute->inPort); + if (vport) { + fwdDetail->SourcePortId = vport->portId; + fwdDetail->SourceNicIndex = vport->nicIndex; + } else { + fwdDetail->SourcePortId = NDIS_SWITCH_DEFAULT_PORT_ID; + fwdDetail->SourceNicIndex = 0; + } ndisStatus = OvsActionsExecute(gOvsSwitchContext, NULL, pNbl, vport ? vport->portNo : OVS_DPPORT_NUMBER_INVALID,