From patchwork Tue Oct 2 23:00:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand Kumar X-Patchwork-Id: 978066 X-Patchwork-Delegate: aserdean@cloudbasesolutions.com 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=fail (p=none dis=none) header.from=vmware.com 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 42Pvlt6YY8z9s3x for ; Wed, 3 Oct 2018 09:01:30 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id AFB031489; Tue, 2 Oct 2018 23:01:27 +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 D271D1489 for ; Tue, 2 Oct 2018 23:01:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from EX13-EDG-OU-001.vmware.com (ex13-edg-ou-001.vmware.com [208.91.0.189]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 6305F8D for ; Tue, 2 Oct 2018 23:01:25 +0000 (UTC) Received: from sc9-mailhost2.vmware.com (10.113.161.72) by EX13-EDG-OU-001.vmware.com (10.113.208.155) with Microsoft SMTP Server id 15.0.1156.6; Tue, 2 Oct 2018 16:01:18 -0700 Received: from WIN-ANAND1.vmware.com (win-anand1.prom.eng.vmware.com [10.33.79.212]) by sc9-mailhost2.vmware.com (Postfix) with ESMTP id 77F63B1456; Tue, 2 Oct 2018 19:01:24 -0400 (EDT) From: Anand Kumar To: Date: Tue, 2 Oct 2018 16:00:45 -0700 Message-ID: <20181002230045.8708-1-kumaranand@vmware.com> X-Mailer: git-send-email 2.9.3.windows.1 MIME-Version: 1.0 Received-SPF: None (EX13-EDG-OU-001.vmware.com: kumaranand@vmware.com does not designate permitted sender hosts) X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [PATCH RFC] datapath-windows: Remove neighbor entries when Iphelper instance is deleted 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: , Sender: ovs-dev-bounces@openvswitch.org Errors-To: ovs-dev-bounces@openvswitch.org 'OVS_IPHELPER_INSTANCE' is linked to ovsSortedIPNeighList. So when an Iphelper instance is deleted, also delete the ip neighboring entries associated with that instance. Also fix accessing Iphelper instance without acquiring thelock. Signed-off-by: Anand Kumar --- datapath-windows/ovsext/IpHelper.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/datapath-windows/ovsext/IpHelper.c b/datapath-windows/ovsext/IpHelper.c index 6bbd096..581be61 100644 --- a/datapath-windows/ovsext/IpHelper.c +++ b/datapath-windows/ovsext/IpHelper.c @@ -1446,6 +1446,17 @@ static VOID OvsIpHelperDeleteInstance(POVS_IPHELPER_INSTANCE instance) { if (instance) { + if (ovsNumFwdEntries) { + POVS_IPNEIGH_ENTRY ipn; + PLIST_ENTRY link, next; + LIST_FORALL_SAFE(&ovsSortedIPNeighList, link, next) { + ipn = CONTAINING_RECORD(link, OVS_IPNEIGH_ENTRY, slink); + POVS_IPHELPER_INSTANCE ipnInstance = (POVS_IPHELPER_INSTANCE)ipn->context; + if (ipnInstance == instance) { + OvsRemoveIPNeighEntry(ipn); + } + } + } ExDeleteResourceLite(&instance->lock); OvsFreeMemoryWithTag(instance, OVS_IPHELPER_POOL_TAG); } @@ -1942,13 +1953,13 @@ OvsStartIpHelper(PVOID data) NTSTATUS status; POVS_IPHELPER_INSTANCE instance = (POVS_IPHELPER_INSTANCE)ipn->context; NdisReleaseSpinLock(&ovsIpHelperLock); - ExAcquireResourceExclusiveLite(&ovsInstanceListLock, TRUE); + ExAcquireResourceExclusiveLite(&instance->lock, TRUE); status = OvsGetOrResolveIPNeigh(&instance->internalRow, ipAddr, &ipNeigh); OvsUpdateIPNeighEntry(ipAddr, &ipNeigh, status); - ExReleaseResourceLite(&ovsInstanceListLock); + ExReleaseResourceLite(&instance->lock); NdisAcquireSpinLock(&ovsIpHelperLock); } @@ -2098,11 +2109,10 @@ OvsCleanupIpHelper(VOID) OvsFreeMemoryWithTag(ovsFwdHashTable, OVS_IPHELPER_POOL_TAG); OvsFreeMemoryWithTag(ovsRouteHashTable, OVS_IPHELPER_POOL_TAG); OvsFreeMemoryWithTag(ovsNeighHashTable, OVS_IPHELPER_POOL_TAG); - + OvsIpHelperDeleteAllInstances(); NdisFreeRWLock(ovsTableLock); NdisFreeSpinLock(&ovsIpHelperLock); - OvsIpHelperDeleteAllInstances(); ExDeleteResourceLite(&ovsInstanceListLock); }