[ovs-dev] [PATCH] bridge: Set ofport column in every database transaction.

Ben Pfaff blp at nicira.com
Thu Jan 30 23:40:34 UTC 2014


Database transactions can occasionally fail due to concurrent changes in
the database.  When that happens, the next transaction should repeat the
changes that ovs-vswitchd tried to make the first time (adjusted for the
changes to the database).

The code to report the OpenFlow port number in use didn't do that.  It set
the ofport field once when it created the port and never set it again, even
if the transaction to set it failed.  This commit fixes the problem.

Bug #23047.
Reported-by: Suganya Ramachandran <suganyar at vmware.com>
Signed-off-by: Ben Pfaff <blp at nicira.com>
---
 AUTHORS           |    1 +
 vswitchd/bridge.c |    7 +++----
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 08ebdba..f1b129b 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -237,6 +237,7 @@ Spiro Kourtessis        spiro at vmware.com
 Srini Seetharaman       seethara at stanford.edu
 Stephen Hemminger       shemminger at vyatta.com
 Stephen Finucane        stephen.finucane at intel.com
+Suganya Ramachandran    suganyar at vmware.com
 Takayuki HAMA           t-hama at cb.jp.nec.com
 Teemu Koponen           koponen at nicira.com
 Timothy Chen            tchen at nicira.com
diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index e6be975..5b1aec3 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+/* Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -575,6 +575,7 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
             port_configure(port);
 
             LIST_FOR_EACH (iface, port_elem, &port->ifaces) {
+                iface_set_ofport(iface->cfg, iface->ofp_port);
                 iface_configure_cfm(iface);
                 iface_configure_qos(iface, port->cfg->qos);
                 iface_set_mac(iface, port->cfg->fake_bridge ? br->ea : NULL);
@@ -1478,7 +1479,6 @@ iface_create(struct bridge *br, const struct ovsrec_interface *iface_cfg,
     ovs_assert(!iface_lookup(br, iface_cfg->name));
     error = iface_do_create(br, iface_cfg, port_cfg, &ofp_port, &netdev);
     if (error) {
-        iface_set_ofport(iface_cfg, OFPP_NONE);
         iface_clear_db_record(iface_cfg);
         return false;
     }
@@ -1503,8 +1503,6 @@ iface_create(struct bridge *br, const struct ovsrec_interface *iface_cfg,
     hmap_insert(&br->ifaces, &iface->ofp_port_node,
                 hash_ofp_port(ofp_port));
 
-    iface_set_ofport(iface->cfg, ofp_port);
-
     /* Populate initial status in database. */
     iface_refresh_stats(iface);
     iface_refresh_status(iface);
@@ -3539,6 +3537,7 @@ static void
 iface_clear_db_record(const struct ovsrec_interface *if_cfg)
 {
     if (!ovsdb_idl_row_is_synthetic(&if_cfg->header_)) {
+        iface_set_ofport(if_cfg, OFPP_NONE);
         ovsrec_interface_set_status(if_cfg, NULL);
         ovsrec_interface_set_admin_state(if_cfg, NULL);
         ovsrec_interface_set_duplex(if_cfg, NULL);
-- 
1.7.10.4




More information about the dev mailing list