From patchwork Tue Jun 27 18:13:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 781328 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.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 3wxvG26mQXz9s2s for ; Wed, 28 Jun 2017 04:14:34 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id DD3A0CD5; Tue, 27 Jun 2017 18:13:34 +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 22996C9E for ; Tue, 27 Jun 2017 18:13:33 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 8FA9C1FB for ; Tue, 27 Jun 2017 18:13:32 +0000 (UTC) Received: from mfilter19-d.gandi.net (mfilter19-d.gandi.net [217.70.178.147]) by relay4-d.mail.gandi.net (Postfix) with ESMTP id 5FF1D172098; Tue, 27 Jun 2017 20:13:31 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mfilter19-d.gandi.net Received: from relay4-d.mail.gandi.net ([IPv6:::ffff:217.70.183.196]) by mfilter19-d.gandi.net (mfilter19-d.gandi.net [::ffff:10.0.15.180]) (amavisd-new, port 10024) with ESMTP id zMzp2_SXM0l6; Tue, 27 Jun 2017 20:13:30 +0200 (CEST) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id CC09A17209C; Tue, 27 Jun 2017 20:13:28 +0200 (CEST) From: Joe Stringer To: dev@openvswitch.org Date: Tue, 27 Jun 2017 11:13:10 -0700 Message-Id: <20170627181310.2911-2-joe@ovn.org> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170627181310.2911-1-joe@ovn.org> References: <20170627181310.2911-1-joe@ovn.org> 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 Subject: [ovs-dev] [PATCH 2/2] dpif: Fix clean up of dpif_ports on dpif_close(). 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 Commit 32b77c316d9982("dpif: Save added ports in a port map.") introduced tracking of all dpif ports by taking a reference on each available netdev when the dpif is opened, but it failed to clear out and release references to these netdevs when the dpif is closed. Balance the referencing of netdevs by introducing netdev_ports_flush() and clearing these during dpif_close(). Fixes: 32b77c316d9982("dpif: Save added ports in a port map.") Signed-off-by: Joe Stringer --- CC: Paul Blakey CC: Darrell Ball --- lib/dpif.c | 1 + lib/netdev.c | 15 +++++++++++++++ lib/netdev.h | 1 + 3 files changed, 17 insertions(+) diff --git a/lib/dpif.c b/lib/dpif.c index 2ed0ba02f2ce..134388b996d5 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -427,6 +427,7 @@ dpif_close(struct dpif *dpif) struct registered_dpif_class *rc; rc = shash_find_data(&dpif_classes, dpif->dpif_class->type); + netdev_ports_flush(DPIF_HMAP_KEY(dpif)); dpif_uninit(dpif, true); dp_class_unref(rc); } diff --git a/lib/netdev.c b/lib/netdev.c index eb7aef7376f1..52c132f3ad22 100644 --- a/lib/netdev.c +++ b/lib/netdev.c @@ -2247,6 +2247,21 @@ netdev_ports_remove(odp_port_t port_no, const void *obj) return ret; } +void +netdev_ports_flush(const void *obj) +{ + struct port_to_netdev_data *data, *next; + + ovs_mutex_lock(&netdev_hmap_mutex); + HMAP_FOR_EACH_SAFE(data, next, node, &port_to_netdev) { + if (data->obj == obj) { + netdev_port_data_destroy(data); + } + } + + ovs_mutex_unlock(&netdev_hmap_mutex); +} + odp_port_t netdev_ifindex_to_odp_port(int ifindex) { diff --git a/lib/netdev.h b/lib/netdev.h index 31846fabf9af..158c16bcb6ca 100644 --- a/lib/netdev.h +++ b/lib/netdev.h @@ -186,6 +186,7 @@ struct dpif_port; int netdev_ports_insert(struct netdev *, const void *obj, struct dpif_port *); struct netdev *netdev_ports_get(odp_port_t port, const void *obj); int netdev_ports_remove(odp_port_t port, const void *obj); +void netdev_ports_flush(const void *obj); odp_port_t netdev_ifindex_to_odp_port(int ifindex); struct netdev_flow_dump **netdev_ports_flow_dump_create(const void *obj, int *ports);