Add an additional check that prevents a segfault in ovn-controller, if
it tries to read from a southbound db with an empty SB_Global table.

Co-authored-by: Felix Huettner <[email protected]>
Signed-off-by: Felix Huettner <[email protected]>
Signed-off-by: Martin Morgenstern <[email protected]>
---
 controller/ovn-controller.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c
index 2d9b3e033..77d63feed 100644
--- a/controller/ovn-controller.c
+++ b/controller/ovn-controller.c
@@ -7625,11 +7625,13 @@ main(int argc, char *argv[])
                     engine_set_force_recompute();
                 }
 
-                if (chassis && ovs_feature_set_discovered()) {
+                const struct sbrec_sb_global *sbg =
+                    sbrec_sb_global_first(ovnsb_idl_loop.idl);
+                if (chassis && sbg && ovs_feature_set_discovered()) {
                     encaps_run(ovs_idl_txn, ovnsb_idl_txn, br_int,
                                sbrec_chassis_table_get(ovnsb_idl_loop.idl),
                                chassis,
-                               sbrec_sb_global_first(ovnsb_idl_loop.idl),
+                               sbg,
                                ovs_table,
                                &transport_zones,
                                bridge_table);
-- 
2.51.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to