From patchwork Thu Dec 13 14:24:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Flavio Leitner X-Patchwork-Id: 1012878 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=redhat.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 43FwxC5Sbtz9s5c for ; Fri, 14 Dec 2018 01:27:11 +1100 (AEDT) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id 70FFE110A; Thu, 13 Dec 2018 14:25:28 +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 D82D910F5 for ; Thu, 13 Dec 2018 14:25:27 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-qt1-f193.google.com (mail-qt1-f193.google.com [209.85.160.193]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 60D85764 for ; Thu, 13 Dec 2018 14:25:27 +0000 (UTC) Received: by mail-qt1-f193.google.com with SMTP id i7so2256192qtj.10 for ; Thu, 13 Dec 2018 06:25:27 -0800 (PST) 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:in-reply-to :references; bh=0r+ewqH0joGqg/bgXIKmc5/7Y8YNmrHxXmEoE2jXW+Y=; b=tHj68zDeaV04v8ALs8AO+cE5Pt2CMjoAs8S+TVdOLGiLgkKl3nexakDkAifObwEIdC HWwto9VgqlGym6PqvkzCm6YYOSBJ4l1stUmPQLB1ZH/uVM82HzTvu4QD09YpuGn7kfdp LgwjqEN5LUTUCmtgagTGNwxb9xkW+xVrvTwtAIPZ6Yr9PVkQOFQXqZCMjTBrqByDjyX8 Zlsww/G6WVPxmath9GSWfWE0FbIK2fpk7cyRAUrj62HOrmZabgKVXx1dcWuZAk8OPIUh uKjtO/qQts3INikpMhfZihorWK4PMzRgEiXaMgPaVpQ+6a7k6Jv//mgxixGLYHtjzmo4 L1Bg== X-Gm-Message-State: AA+aEWYFBK79Wz/QGU37zW9rG9WbPmollBOqWjSLIFw/GdaX8nzO1RG6 0lphCDriNj7ur7ZqvtfLOQV1j5lk000= X-Google-Smtp-Source: AFSGD/WLw+Ss4+hTO5cg09AjliCCpESk4ICHS5HLSl3hqMUHjJASagMaQmp5kQavxHllVjqkUL6A5Q== X-Received: by 2002:aed:2391:: with SMTP id j17mr23686776qtc.205.1544711126286; Thu, 13 Dec 2018 06:25:26 -0800 (PST) Received: from localhost ([177.183.214.253]) by smtp.gmail.com with ESMTPSA id q72sm1198229qki.24.2018.12.13.06.25.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 06:25:25 -0800 (PST) From: Flavio Leitner To: dev@openvswitch.org Date: Thu, 13 Dec 2018 12:24:48 -0200 Message-Id: <20181213142448.8504-4-fbl@redhat.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181213142448.8504-1-fbl@redhat.com> References: <20181213142448.8504-1-fbl@redhat.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, 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 Cc: Guru Shetty , Flavio Leitner Subject: [ovs-dev] [PATCH 3/3] Revert "ofproto-dpif: Let the dpif report when a port is a duplicate." 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 This reverts commit 7521e0cf9e88a62f2feff4e7253654557f94877e. This patch introduced a regression in OSP environments using internal ports in other netns. Their networking configuration is lost when the service is restarted because the ports are recreated now. Before the patch it checked using netlink if the port with a specific "name" was already there. The check is a lookup in all ports attached to the DP regardless of the port's netns. After the patch it relies on the kernel to identify that situation. Unfortunately the only protection there is register_netdevice() which fails only if the port with that name exists in the current netns. If the port is in another netns, it will get a new dp_port and because of that userspace will delete the old port. At this point the original port is gone from the other netns and there a fresh port in the current netns. Signed-off-by: Flavio Leitner --- lib/dpif.c | 9 ++------- ofproto/ofproto-dpif.c | 7 ++++--- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/dpif.c b/lib/dpif.c index e35f11147..457c9bfb9 100644 --- a/lib/dpif.c +++ b/lib/dpif.c @@ -592,13 +592,8 @@ dpif_port_add(struct dpif *dpif, struct netdev *netdev, odp_port_t *port_nop) netdev_ports_insert(netdev, dpif->dpif_class, &dpif_port); } } else { - if (error != EEXIST) { - VLOG_WARN_RL(&error_rl, "%s: failed to add %s as port: %s", - dpif_name(dpif), netdev_name, ovs_strerror(error)); - } else { - /* It's fairly common for upper layers to try to add a duplicate - * port, and they know how to handle it properly. */ - } + VLOG_WARN_RL(&error_rl, "%s: failed to add %s as port: %s", + dpif_name(dpif), netdev_name, ovs_strerror(error)); port_no = ODPP_NONE; } if (port_nop) { diff --git a/ofproto/ofproto-dpif.c b/ofproto/ofproto-dpif.c index f40f157ca..252e8add6 100644 --- a/ofproto/ofproto-dpif.c +++ b/ofproto/ofproto-dpif.c @@ -3662,10 +3662,11 @@ port_add(struct ofproto *ofproto_, struct netdev *netdev) } dp_port_name = netdev_vport_get_dpif_port(netdev, namebuf, sizeof namebuf); + if (!dpif_port_exists(ofproto->backer->dpif, dp_port_name)) { + odp_port_t port_no = ODPP_NONE; + int error; - odp_port_t port_no = ODPP_NONE; - int error = dpif_port_add(ofproto->backer->dpif, netdev, &port_no); - if (error != EEXIST) { + error = dpif_port_add(ofproto->backer->dpif, netdev, &port_no); if (error) { return error; }