From patchwork Wed Sep 13 20:05:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andy Zhou X-Patchwork-Id: 813613 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 3xst3j2h9cz9s7f for ; Thu, 14 Sep 2017 06:06:55 +1000 (AEST) Received: from mail.linux-foundation.org (localhost [127.0.0.1]) by mail.linuxfoundation.org (Postfix) with ESMTP id E6A93AB7; Wed, 13 Sep 2017 20:06:51 +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 62A05904 for ; Wed, 13 Sep 2017 20:06:51 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by smtp1.linuxfoundation.org (Postfix) with ESMTPS id 7D24A12A for ; Wed, 13 Sep 2017 20:06:48 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id d8so576178pgt.3 for ; Wed, 13 Sep 2017 13:06:48 -0700 (PDT) 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 :content-transfer-encoding; bh=E9MEnLZJYEEJ+CW6jwqaz1NOmMYV0uhIFVXio9CuCGc=; b=nW8f7IYJBjspoertgk2FJaSSYywYlK3+4XGJ0Mxci91gyocGGvGqpyHRWgX5Mwv32V CTs4HAzZEWU2PJfGfDK7XfcS3Bcn2a/0jCeVqIsehRQMjm7W4Lf0k0aw0vHZ9ECMb+mm 1D1ExES5Z1KQuUWDDZWw1aZ4fNxCWtLIl/LM/8G77qJE3yb4ttB3w3H3h5eNmZ+wqEVr qD9DbThoGzfce2040+23psF6Rp1R8/CRBY/SHAhGNDIDEG4SRhKR7Kb5j5QdxtGmWUyo 3TwQNzuUbqdyCh5p1owu4GtdybCZT4DhVX3Avb2LlndczkLwyI1QB7ttZiyl+tFp5PvC XN0w== X-Gm-Message-State: AHPjjUjBk6Rd6K3YAfkctWQhpOYGjpioKIpIGkXgRdSxBk1jw5RkPS0N ThhgF8AQ75AYJXYp X-Google-Smtp-Source: ADKCNb7sbmRTGQi8tGXO3Oah5Ea3o9WuZSf5YJi12MXuw6XJGXQ1/ivTqkZ1eRwwXbya1v1xG7agwA== X-Received: by 10.159.242.129 with SMTP id u1mr12256712plr.243.1505333207767; Wed, 13 Sep 2017 13:06:47 -0700 (PDT) Received: from centos.eng.vmware.com ([208.91.1.34]) by smtp.gmail.com with ESMTPSA id e78sm24122612pfh.76.2017.09.13.13.06.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Sep 2017 13:06:46 -0700 (PDT) From: Andy Zhou To: dev@openvswitch.org Date: Wed, 13 Sep 2017 13:05:52 -0700 Message-Id: <1505333152-11087-1-git-send-email-azhou@ovn.org> X-Mailer: git-send-email 1.8.3.1 X-Spam-Status: No, score=0.5 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=disabled version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on smtp1.linux-foundation.org Subject: [ovs-dev] [v2] bridge: Fix controller status update to passive connections 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 The bug can cause ovs-vswitchd to crash (due to assert) when it is set up with a passive controller connection. Since only active connections are kept, the passive connection status update should be ignored and not trigger asserts. Fixes: 85c55772a453 ("bridge: Fix controller status update") Reported-by: Josh Bailey Signed-off-by: Andy Zhou Acked-by: Joe Stringer --- v1->v2: Set defaults when cinfo is NULL. --- AUTHORS.rst | 1 + vswitchd/bridge.c | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/AUTHORS.rst b/AUTHORS.rst index 4b9e78f07f87..5d8b723f62e6 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -390,6 +390,7 @@ Ben Basler bbasler@nicira.com Bhargava Shastry bshastry@sec.t-labs.tu-berlin.de Bob Ball bob.ball@citrix.com Brad Hall brad@nicira.com +Brailey Josh josh@faucet.nz Brandon Heller brandonh@stanford.edu Brendan Kelley bkelley@nicira.com Brent Salisbury brent.salisbury@gmail.com diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index a8cbae78cb23..eec9689e6dbd 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -2720,11 +2720,17 @@ refresh_controller_status(void) struct ofproto_controller_info *cinfo = shash_find_data(&info, cfg->target); - ovs_assert(cinfo); - ovsrec_controller_set_is_connected(cfg, cinfo->is_connected); - const char *role = ofp12_controller_role_to_str(cinfo->role); - ovsrec_controller_set_role(cfg, role); - ovsrec_controller_set_status(cfg, &cinfo->pairs); + /* cinfo is NULL when 'cfg->target' is a passive connection. */ + if (cinfo) { + ovsrec_controller_set_is_connected(cfg, cinfo->is_connected); + const char *role = ofp12_controller_role_to_str(cinfo->role); + ovsrec_controller_set_role(cfg, role); + ovsrec_controller_set_status(cfg, &cinfo->pairs); + } else { + ovsrec_controller_set_is_connected(cfg, false); + ovsrec_controller_set_role(cfg, NULL); + ovsrec_controller_set_status(cfg, NULL); + } } ofproto_free_ofproto_controller_info(&info);