From patchwork Thu Nov 8 06:29:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Han Zhou X-Patchwork-Id: 994661 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=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="T2oSxHDU"; dkim-atps=neutral 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 42rD0p3cFDz9s47 for ; Thu, 8 Nov 2018 17:30:02 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id C9E6C5A8; Thu, 8 Nov 2018 06:29:58 +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 61B8C415 for ; Thu, 8 Nov 2018 06:29:57 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 173DC76F for ; Thu, 8 Nov 2018 06:29:57 +0000 (UTC) Received: by mail-pf1-f195.google.com with SMTP id u10-v6so3102374pfn.9 for ; Wed, 07 Nov 2018 22:29:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Y/oZx2+mgE44sXqRyaKq7paxRkgqlebI8RiXslW9wo8=; b=T2oSxHDUUP9bVisbKKMdtRFvju7tk6fk0jdy5l9tc97uJDURE5HekuJf248h3oWgKc rHk5ZNmOWQVKDDBk7dPUM1X7ufsdJGpV+u/5XIlGPETK5WniiKbyb7f7HsD6GdYtqylE SQradwVpZh7ertlsklChQWf1RBoGj719dvDKrfs0lF2IFnGieyLNBt2FaD1BNMgFfe0g k/TKZ9DwJNy9/2CelfkwKPDY7ec8S5y0p6SAcPLhSJyZTitHuaMJ4EIL/Up9DQ9Gv8Kn wTA1liot6502S1/U2BCbAnTCO8YS1bp1K80IZydgiz6LzLswtISc/vo31/7loDaOicr2 EB+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Y/oZx2+mgE44sXqRyaKq7paxRkgqlebI8RiXslW9wo8=; b=LqxwIx42REk7LkFmVK36K5Jx7mkPjd2nFPoH8OWzQkCb6h0eMLeFLh9wxqaUJCBNmJ zHKJKYGD2HL1beCU1vKc2i6nbhi52lT3/5icfLpVTX71dlNsoWmlXAMxjwvH08W8Z2bl 8Cadd5fm1gufDCWG2vkm5dkM6inkGtIg0siwAP6okVTK6hkUgQpNXYk2SgQaABLyGAFQ UvQs3wndeFXbxTCFIInPCYqvVTdq/gfWO7Qxrs6zXYQHJTm2SAm/7OW3Mcf3E261gr0E OWsgQuGsRdEQvZM2jeJWgBHgfmepucJfpt4odrxo4J34W/r0TVgFNNP0oJ7nVxgVuDg+ gTiA== X-Gm-Message-State: AGRZ1gJjWFxWjAQ29apWdgzDF1ZdTeTkmp8ClKT3K2TBldipF5EOOykB mj8wblfWdvBtz+tjEudvladkTsi1 X-Google-Smtp-Source: AJdET5fchgQNkdxiTXzeE0XOyJHYbaC+olCNd/DDC/S2U5nte1HtBigvIiLhyNj+kK2n/LescJI/BQ== X-Received: by 2002:a63:cf56:: with SMTP id b22mr2683945pgj.336.1541658596352; Wed, 07 Nov 2018 22:29:56 -0800 (PST) Received: from localhost.localdomain.localdomain ([216.113.160.71]) by smtp.gmail.com with ESMTPSA id o12-v6sm2927271pfh.20.2018.11.07.22.29.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Nov 2018 22:29:55 -0800 (PST) From: Han Zhou X-Google-Original-From: Han Zhou To: dev@openvswitch.org Date: Wed, 7 Nov 2018 22:29:43 -0800 Message-Id: <1541658584-73372-1-git-send-email-hzhou8@ebay.com> X-Mailer: git-send-email 2.1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE 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 1/2] ofproto.c: Fix port number leaking. 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 From: Han Zhou When there is an error in ofport_install(), the ofp port number is not deallocated, which leads to port number leak. For example, when there is an redundant tunnel port added in an OVS bridge, ovs-vswitchd will try to add the port to ofproto whenever OVSDB changes, which would trigger the port number leak, and over the time there won't be any port available for valid requests. Signed-off-by: Han Zhou --- ofproto/ofproto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c index 222c749..bb020fe 100644 --- a/ofproto/ofproto.c +++ b/ofproto/ofproto.c @@ -2516,6 +2516,7 @@ ofport_destroy__(struct ofport *port) struct ofproto *ofproto = port->ofproto; const char *name = netdev_get_name(port->netdev); + dealloc_ofp_port(port->ofproto, port->ofp_port); hmap_remove(&ofproto->ports, &port->hmap_node); shash_find_and_delete(&ofproto->port_by_name, name); @@ -2527,7 +2528,6 @@ static void ofport_destroy(struct ofport *port, bool del) { if (port) { - dealloc_ofp_port(port->ofproto, port->ofp_port); port->ofproto->ofproto_class->port_destruct(port, del); ofport_destroy__(port); }