[ovs-dev] [PATCH] bridge: Fix controller status update to passive connections

Andy Zhou azhou at ovn.org
Wed Sep 6 22:24:07 UTC 2017


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.

Reported-by: Josh Bailey <josh at faucet.nz>
Signed-off-by: Andy Zhou <azhou at ovn.org>
---
 AUTHORS.rst       |  1 +
 vswitchd/bridge.c | 12 +++++++-----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/AUTHORS.rst b/AUTHORS.rst
index cb0cd91b21ba..e304609b2b27 100644
--- a/AUTHORS.rst
+++ b/AUTHORS.rst
@@ -389,6 +389,7 @@ Ben Basler                      bbasler at nicira.com
 Bhargava Shastry                bshastry at sec.t-labs.tu-berlin.de
 Bob Ball                        bob.ball at citrix.com
 Brad Hall                       brad at nicira.com
+Brailey Josh                    josh at faucet.nz
 Brandon Heller                  brandonh at stanford.edu
 Brendan Kelley                  bkelley at nicira.com
 Brent Salisbury                 brent.salisbury at gmail.com
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index a8cbae78cb23..00f86182c820 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2720,11 +2720,13 @@ 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);
+            }
         }
 
         ofproto_free_ofproto_controller_info(&info);
-- 
1.8.3.1



More information about the dev mailing list