[ovs-dev,v3,2/2] chassis.c: Return chassis record whenever available in chassis_run().

Message ID 1554338953-75998-2-git-send-email-hzhou8@ebay.com
State Superseded
Headers show
Series
  • [ovs-dev,v3,1/2] ovn-controller: Fix busy loop when sb disconnected.
Related show

Commit Message

Han Zhou April 4, 2019, 12:49 a.m.
From: Han Zhou <hzhou8@ebay.com>

The ovn-controller main loop relies on the return value of chassis_run().
When ovnsb_idl_txn is NULL (i.e. there is a pending transaction for SB),
chasssis_run() returns NULL, which blocks functions to be executed in
the main loop unnecessarily. This patch updates chassis_run() so that
it returns chassis record whenever it is available.

This changes allows xxx_run() functions being executed whenever
br_int and chassis are not NULL. For functions that need to update
SB DB, there are already additional checks making sure ovnsb_idl_txn
is not NULL.

Acked-by: Numan Siddique <nusiddiq@redhat.com>
Signed-off-by: Han Zhou <hzhou8@ebay.com>
---

Notes:
    v2->v3: no change

 ovn/controller/chassis.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

Patch

diff --git a/ovn/controller/chassis.c b/ovn/controller/chassis.c
index 3ea908d..58d5d49 100644
--- a/ovn/controller/chassis.c
+++ b/ovn/controller/chassis.c
@@ -73,8 +73,7 @@  get_cms_options(const struct smap *ext_ids)
     return smap_get_def(ext_ids, "ovn-cms-options", "");
 }
 
-/* Returns this chassis's Chassis record, if it is available and is currently
- * amenable to a transaction. */
+/* Returns this chassis's Chassis record, if it is available. */
 const struct sbrec_chassis *
 chassis_run(struct ovsdb_idl_txn *ovnsb_idl_txn,
             struct ovsdb_idl_index *sbrec_chassis_by_name,
@@ -82,8 +81,10 @@  chassis_run(struct ovsdb_idl_txn *ovnsb_idl_txn,
             const char *chassis_id,
             const struct ovsrec_bridge *br_int)
 {
+    const struct sbrec_chassis *chassis_rec
+        = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
     if (!ovnsb_idl_txn) {
-        return NULL;
+        return chassis_rec;
     }
 
     const struct ovsrec_open_vswitch *cfg;
@@ -148,8 +149,6 @@  chassis_run(struct ovsdb_idl_txn *ovnsb_idl_txn,
     ds_chomp(&iface_types, ',');
     const char *iface_types_str = ds_cstr(&iface_types);
 
-    const struct sbrec_chassis *chassis_rec
-        = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
     const char *encap_csum = smap_get_def(&cfg->external_ids,
                                           "ovn-encap-csum", "true");
     int n_encaps = count_1bits(req_tunnels);