Skip to content

Commit

Permalink
I-P: Handle sbrec_chassis changes
Browse files Browse the repository at this point in the history
Signed-off-by: Numan Siddique <numans@ovn.org>
  • Loading branch information
numansiddique committed Apr 16, 2020
1 parent dbd65b4 commit 3268bda
Showing 1 changed file with 49 additions and 14 deletions.
63 changes: 49 additions & 14 deletions controller/ovn-controller.c
Expand Up @@ -1380,7 +1380,8 @@ static void init_physical_ctx(struct engine_node *node,

struct sbrec_chassis_table *chassis_table =
(struct sbrec_chassis_table *)EN_OVSDB_GET(
engine_get_input("SB_chassis", node));
engine_get_input("SB_chassis",
engine_get_input("physical_flow_changes", node)));

struct ed_type_mff_ovn_geneve *ed_mff_ovn_geneve =
engine_get_input_data("mff_ovn_geneve", node);
Expand All @@ -1396,7 +1397,8 @@ static void init_physical_ctx(struct engine_node *node,
const struct sbrec_chassis *chassis = NULL;
struct ovsdb_idl_index *sbrec_chassis_by_name =
engine_ovsdb_node_get_index(
engine_get_input("SB_chassis", node),
engine_get_input("SB_chassis",
engine_get_input("physical_flow_changes", node)),
"name");
if (chassis_id) {
chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
Expand Down Expand Up @@ -1473,7 +1475,8 @@ static void init_lflow_ctx(struct engine_node *node,
const struct sbrec_chassis *chassis = NULL;
struct ovsdb_idl_index *sbrec_chassis_by_name =
engine_ovsdb_node_get_index(
engine_get_input("SB_chassis", node),
engine_get_input("SB_chassis",
engine_get_input("physical_flow_changes", node)),
"name");
if (chassis_id) {
chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
Expand Down Expand Up @@ -1554,8 +1557,9 @@ en_flow_output_run(struct engine_node *node, void *data)

struct ovsdb_idl_index *sbrec_chassis_by_name =
engine_ovsdb_node_get_index(
engine_get_input("SB_chassis", node),
"name");
engine_get_input("SB_chassis",
engine_get_input("physical_flow_changes", node)),
"name");

const struct sbrec_chassis *chassis = NULL;
if (chassis_id) {
Expand Down Expand Up @@ -1720,8 +1724,9 @@ _flow_output_resource_ref_handler(struct engine_node *node, void *data,

struct ovsdb_idl_index *sbrec_chassis_by_name =
engine_ovsdb_node_get_index(
engine_get_input("SB_chassis", node),
"name");
engine_get_input("SB_chassis",
engine_get_input("physical_flow_changes", node)),
"name");
const struct sbrec_chassis *chassis = NULL;
if (chassis_id) {
chassis = chassis_lookup_by_name(sbrec_chassis_by_name, chassis_id);
Expand Down Expand Up @@ -1809,7 +1814,7 @@ flow_output_port_groups_handler(struct engine_node *node, void *data)
}

struct ed_type_physical_flow_changes {
bool ct_zones_changed;
bool need_physical_run;
};

static bool
Expand All @@ -1825,8 +1830,8 @@ flow_output_physical_flow_changes_handler(struct engine_node *node, void *data)
init_physical_ctx(node, rt_data, &p_ctx);

engine_set_node_state(node, EN_UPDATED);
if (pfc->ct_zones_changed) {
pfc->ct_zones_changed = false;
if (pfc->need_physical_run) {
pfc->need_physical_run = false;
physical_run(&p_ctx, &fo->flow_table);
return true;
}
Expand Down Expand Up @@ -1859,11 +1864,38 @@ physical_flow_changes_ct_zones_handler(struct engine_node *node OVS_UNUSED,
void *data OVS_UNUSED)
{
struct ed_type_physical_flow_changes *pfc = data;
pfc->ct_zones_changed = true;
pfc->need_physical_run = true;
engine_set_node_state(node, EN_UPDATED);
return false;
}

/* Handles sbrec_chassis changes.
* If a new chassis is added or removed return false, so that
* physical flows are programmed.
* For any updates, there is no need for any flow computation.
* Encap changes will also result in sbrec_chassis changes,
* but we handle encap changes separately.
*/
static bool
physical_flow_changes_sb_chassis_handler(struct engine_node *node OVS_UNUSED,
void *data OVS_UNUSED)
{
struct sbrec_chassis_table *chassis_table =
(struct sbrec_chassis_table *)EN_OVSDB_GET(
engine_get_input("SB_chassis", node));
struct ed_type_physical_flow_changes *pfc = data;

const struct sbrec_chassis *ch;
SBREC_CHASSIS_TABLE_FOR_EACH_TRACKED (ch, chassis_table) {
if (sbrec_chassis_is_deleted(ch) || sbrec_chassis_is_new(ch)) {
pfc->need_physical_run = true;
return false;
}
}

return true;
}

static bool
flow_output_runtime_data_handler(struct engine_node *node,
void *data OVS_UNUSED)
Expand Down Expand Up @@ -2072,6 +2104,10 @@ main(int argc, char *argv[])
physical_flow_changes_ct_zones_handler);
engine_add_input(&en_physical_flow_changes, &en_ovs_interface,
NULL);
engine_add_input(&en_physical_flow_changes, &en_sb_chassis,
physical_flow_changes_sb_chassis_handler);
engine_add_input(&en_physical_flow_changes, &en_sb_encap,
NULL);

engine_add_input(&en_flow_output, &en_addr_sets,
flow_output_addr_sets_handler);
Expand All @@ -2086,8 +2122,6 @@ main(int argc, char *argv[])
engine_add_input(&en_flow_output, &en_ovs_open_vswitch, NULL);
engine_add_input(&en_flow_output, &en_ovs_bridge, NULL);

engine_add_input(&en_flow_output, &en_sb_chassis, NULL);
engine_add_input(&en_flow_output, &en_sb_encap, NULL);
engine_add_input(&en_flow_output, &en_sb_multicast_group,
flow_output_sb_multicast_group_handler);
engine_add_input(&en_flow_output, &en_sb_port_binding,
Expand All @@ -2114,7 +2148,8 @@ main(int argc, char *argv[])
runtime_data_ovs_interface_handler);
engine_add_input(&en_runtime_data, &en_ovs_qos, NULL);

engine_add_input(&en_runtime_data, &en_sb_chassis, NULL);
engine_add_input(&en_runtime_data, &en_sb_chassis,
runtime_data_noop_handler);
engine_add_input(&en_runtime_data, &en_sb_datapath_binding,
runtime_data_sb_datapath_binding_handler);
engine_add_input(&en_runtime_data, &en_sb_port_binding,
Expand Down

0 comments on commit 3268bda

Please sign in to comment.