Skip to content

Commit

Permalink
controller: Prevent crashes when db is empty.
Browse files Browse the repository at this point in the history
Signed-off-by: Rosemarie O'Riorden <[email protected]>
  • Loading branch information
roseoriorden committed Oct 10, 2024
1 parent ed2563a commit 047f544
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
4 changes: 4 additions & 0 deletions controller/chassis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1016,6 +1016,10 @@ store_chassis_index_if_needed(
{
const struct ovsrec_open_vswitch *cfg =
ovsrec_open_vswitch_table_first(ovs_table);
if (!cfg) {
VLOG_INFO("No Open_vSwitch row defined.");
return;
}
const char *chassis_id = get_ovs_chassis_id(ovs_table);

char *idx_key = xasprintf(CHASSIS_IDX_PREFIX "%s", chassis_id);
Expand Down
25 changes: 13 additions & 12 deletions controller/ovn-controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -5434,6 +5434,8 @@ main(int argc, char *argv[])
ovsrec_open_vswitch_table_get(ovs_idl_loop.idl);
const struct ovsrec_bridge *br_int = NULL;
const struct ovsrec_datapath *br_int_dp = NULL;
const struct ovsrec_open_vswitch *cfg =
ovsrec_open_vswitch_table_first(ovs_table);
process_br_int(ovs_idl_txn, bridge_table, ovs_table, &br_int,
ovsrec_server_has_datapath_table(ovs_idl_loop.idl)
? &br_int_dp
Expand All @@ -5446,24 +5448,24 @@ main(int argc, char *argv[])

/* Enable ACL matching for double tagged traffic. */
if (ovs_idl_txn) {
const struct ovsrec_open_vswitch *cfg =
ovsrec_open_vswitch_table_first(ovs_table);
int vlan_limit = smap_get_int(
&cfg->other_config, "vlan-limit", -1);
if (vlan_limit != 0) {
ovsrec_open_vswitch_update_other_config_setkey(
cfg, "vlan-limit", "0");
if (cfg) {
int vlan_limit = smap_get_int(
&cfg->other_config, "vlan-limit", -1);
if (vlan_limit != 0) {
ovsrec_open_vswitch_update_other_config_setkey(
cfg, "vlan-limit", "0");
}
}
}

static bool chassis_idx_stored = false;
if (ovs_idl_txn && !chassis_idx_stored) {
store_chassis_index_if_needed(ovs_table);
if (ovs_idl_txn && !chassis_idx_stored) { //&& cfg) {
store_chassis_index_if_needed(ovs_table); //add check to this funct
chassis_idx_stored = true;
}

if (ovsdb_idl_has_ever_connected(ovnsb_idl_loop.idl) &&
northd_version_match) {
northd_version_match && cfg) {

/* Unconditionally remove all deleted lflows from the lflow
* cache.
Expand Down Expand Up @@ -5550,7 +5552,7 @@ main(int argc, char *argv[])
* change tracking is improved, we can simply skip
* this round of engine_run and continue processing
* acculated changes incrementally later when
* ofctrl_has_backlog() returns false. */
store_chassis_index_if_needed * ofctrl_has_backlog() returns false. */
engine_run(false);
} else {
engine_run(true);
Expand Down Expand Up @@ -5877,7 +5879,6 @@ main(int argc, char *argv[])
= ovsrec_bridge_table_get(ovs_idl_loop.idl);
const struct ovsrec_open_vswitch_table *ovs_table
= ovsrec_open_vswitch_table_get(ovs_idl_loop.idl);

const struct sbrec_port_binding_table *port_binding_table
= sbrec_port_binding_table_get(ovnsb_idl_loop.idl);

Expand Down

0 comments on commit 047f544

Please sign in to comment.