From patchwork Wed Aug 9 00:10:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Stringer X-Patchwork-Id: 799505 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=) 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 3xRsBh5LYzz9sCZ for ; Wed, 9 Aug 2017 10:11:40 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 1659BC48; Wed, 9 Aug 2017 00:11:18 +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 1FD30B68 for ; Wed, 9 Aug 2017 00:11:16 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id EC35F3CF for ; Wed, 9 Aug 2017 00:11:15 +0000 (UTC) X-Originating-IP: 208.91.1.34 Received: from carno.eng.vmware.com (unknown [208.91.1.34]) (Authenticated sender: joe@ovn.org) by relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 57B5EC5A56 for ; Wed, 9 Aug 2017 02:11:14 +0200 (CEST) From: Joe Stringer To: dev@openvswitch.org Date: Tue, 8 Aug 2017 17:10:58 -0700 Message-Id: <20170809001058.8102-2-joe@ovn.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170809001058.8102-1-joe@ovn.org> References: <20170809001058.8102-1-joe@ovn.org> Subject: [ovs-dev] [PATCHv3 2/2] dpif: Clean up netdev_ports map 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. One of the problems introduced by this was that upon clean exit of ovs-vswitchd via "ovs-appctl exit --cleanup", the "ovs-netdev" device was not deleted. This which could cause problems in subsequent start up. Commit 5119e258da92 ("dpif: Fix cleanup of userspace datapath.") fixed this particular problem by not adding such devices to the netdev_ports map, but the referencing/unreferencing upon dpif_open()/dpif_close() is still not balanced. Balance the referencing of netdevs by clearing these during dpif_close(). Fixes: 32b77c316d9982("dpif: Save added ports in a port map.") Signed-off-by: Joe Stringer Acked-by: Andy Zhou --- v3: Rather than flushing ports from this dpif, iterate ports and remove them. v2: Update commit message. Rebase. v1: Initial posting. --- lib/dpif.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/dpif.c b/lib/dpif.c index e71f6a3d1475..eccd8607f17e 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -435,8 +435,17 @@ dpif_close(struct dpif *dpif) { if (dpif) { struct registered_dpif_class *rc; + struct dpif_port_dump port_dump; + struct dpif_port dpif_port; rc = shash_find_data(&dpif_classes, dpif->dpif_class->type); + + DPIF_PORT_FOR_EACH (&dpif_port, &port_dump, dpif) { + if (dpif_is_internal_port(dpif_port.type)) { + continue; + } + netdev_ports_remove(dpif_port.port_no, dpif->dpif_class); + } dpif_uninit(dpif, true); dp_class_unref(rc); }