Change handlers' return type is a boolean: true if the handler could handle the changed input data, and false if the handler could not handle the input data. Unfortunately, a change handler also has a hidden task it must do: update the node state if its data has been updated.
To make this responsibility more clear, this commit updates the return type of change handlers to be an enum. This way, the change handler can indicate if the change cannot be handled, if the change could be handled but the node data is unchanged, or if the change could be handled and the node data is updated. The incremental engine uses this return value to update the node state. This has a positive side effect as well, as this change now eliminates the possibility of inputs overwriting state set by previous inputs. Consider if node X has inputs A and B. A's change handler sets X's state to EN_UPDATED. Then B's change handler sets X's state to EN_UNCHANGED. B has overwritten the update that A made and therefore, X appears to be unchanged, even though its data has been updated. With this commit, this can no longer happen, since the incremental engine library itself is now responsible for setting the state based on the change handler results. The incremental engine will not change a node's state back to EN_UNCHANGED if a previous change handler has set the state TO EN_UPDATED. Signed-off-by: Mark Michelson <mmich...@redhat.com> Acked-by: Ales Musil <amu...@redhat.com> --- v1 -> v2: * Fixed interface_shadow handler return in ovn-controller.c * Added Ales's Ack --- controller/ovn-controller.c | 469 +++++++++++++++--------------- lib/inc-proc-eng.c | 14 +- lib/inc-proc-eng.h | 50 ++-- northd/en-acl-ids.h | 1 - northd/en-advertised-route-sync.c | 18 +- northd/en-advertised-route-sync.h | 8 +- northd/en-ecmp-nexthop.c | 4 +- northd/en-ecmp-nexthop.h | 3 +- northd/en-global-config.c | 60 ++-- northd/en-global-config.h | 16 +- northd/en-group-ecmp-route.c | 10 +- northd/en-group-ecmp-route.h | 5 +- northd/en-lb-data.c | 28 +- northd/en-lb-data.h | 12 +- northd/en-learned-route-sync.c | 14 +- northd/en-learned-route-sync.h | 9 +- northd/en-lflow.c | 54 ++-- northd/en-lflow.h | 19 +- northd/en-lr-nat.c | 10 +- northd/en-lr-nat.h | 4 +- northd/en-lr-stateful.c | 22 +- northd/en-lr-stateful.h | 9 +- northd/en-ls-stateful.c | 22 +- northd/en-ls-stateful.h | 6 +- northd/en-multicast.c | 6 +- northd/en-multicast.h | 3 +- northd/en-northd-output.c | 52 ++-- northd/en-northd-output.h | 29 +- northd/en-northd.c | 60 ++-- northd/en-northd.h | 32 +- northd/en-port-group.c | 7 +- northd/en-port-group.h | 3 +- northd/en-sync-from-sb.c | 6 +- northd/en-sync-from-sb.h | 3 +- northd/en-sync-sb.c | 40 ++- northd/en-sync-sb.h | 14 +- 36 files changed, 579 insertions(+), 543 deletions(-) diff --git a/controller/ovn-controller.c b/controller/ovn-controller.c index ebc43dd0a..4e59d75f5 100644 --- a/controller/ovn-controller.c +++ b/controller/ovn-controller.c @@ -1100,18 +1100,20 @@ en_if_status_mgr_run(struct engine_node *node, void *data_) return state; } -static bool -if_status_mgr_ovs_interface_handler(struct engine_node *node, void *data) +static enum engine_input_handler_result +if_status_mgr_ovs_interface_handler(struct engine_node *node OVS_UNUSED, + void *data) { struct ed_type_if_status_mgr *data_ = data; + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; const struct ovsrec_interface *iface; OVSREC_INTERFACE_TABLE_FOR_EACH_TRACKED (iface, data_->iface_table) { if (if_status_mgr_iface_update(data_->manager, iface)) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } - return true; + return result; } /* This engine node is to wrap the OVS_interface input and maintain a copy of @@ -1190,12 +1192,16 @@ en_ovs_interface_shadow_run(struct engine_node *node, void *data_) return EN_UPDATED; } -static bool +static enum engine_input_handler_result ovs_interface_shadow_ovs_interface_handler(struct engine_node *node, void *data_) { - engine_set_node_state(node, en_ovs_interface_shadow_run(node, data_)); - return true; + enum engine_node_state state = en_ovs_interface_shadow_run(node, data_); + if (state == EN_UPDATED) { + return EN_HANDLED_UPDATED; + } else { + return EN_HANDLED_UNCHANGED; + } } struct ed_type_activated_ports { @@ -1613,10 +1619,11 @@ en_sb_ro_cleanup(void *data OVS_UNUSED) { } -static bool +static enum engine_input_handler_result runtime_data_sb_ro_handler(struct engine_node *node, void *data) { const struct sbrec_chassis *chassis = NULL; + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; struct ovsrec_open_vswitch_table *ovs_table = (struct ovsrec_open_vswitch_table *)EN_OVSDB_GET( @@ -1645,51 +1652,53 @@ runtime_data_sb_ro_handler(struct engine_node *node, void *data) chassis, &rt_data->tracked_dp_bindings, pb_table, sb_readonly)) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; rt_data->tracked = true; } } - return true; + return result; } -static bool +static enum engine_input_handler_result runtime_data_ovs_interface_shadow_handler(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = data; struct binding_ctx_in b_ctx_in; struct binding_ctx_out b_ctx_out; + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; init_binding_ctx(node, rt_data, &b_ctx_in, &b_ctx_out); rt_data->tracked = true; b_ctx_out.tracked_dp_bindings = &rt_data->tracked_dp_bindings; if (!binding_handle_ovs_interface_changes(&b_ctx_in, &b_ctx_out)) { - return false; + return EN_UNHANDLED; } if (b_ctx_out.local_lports_changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; rt_data->local_lports_changed = b_ctx_out.local_lports_changed; } - return true; + return result; } -static bool +static enum engine_input_handler_result runtime_data_sb_port_binding_handler(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = data; struct binding_ctx_in b_ctx_in; struct binding_ctx_out b_ctx_out; + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; init_binding_ctx(node, rt_data, &b_ctx_in, &b_ctx_out); if (!b_ctx_in.chassis_rec) { - return false; + return EN_UNHANDLED; } rt_data->tracked = true; b_ctx_out.tracked_dp_bindings = &rt_data->tracked_dp_bindings; if (!binding_handle_port_binding_changes(&b_ctx_in, &b_ctx_out)) { - return false; + return EN_UNHANDLED; } rt_data->local_lports_changed = b_ctx_out.local_lports_changed; @@ -1700,13 +1709,13 @@ runtime_data_sb_port_binding_handler(struct engine_node *node, void *data) b_ctx_out.local_lports_changed || b_ctx_out.localnet_learn_fdb_changed || !hmap_is_empty(b_ctx_out.tracked_dp_bindings)) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } - return true; + return result; } -static bool +static enum engine_input_handler_result runtime_data_sb_datapath_binding_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { @@ -1720,7 +1729,7 @@ runtime_data_sb_datapath_binding_handler(struct engine_node *node OVS_UNUSED, if (sbrec_datapath_binding_is_deleted(dp)) { if (get_local_datapath(&rt_data->local_datapaths, dp->tunnel_key)) { - return false; + return EN_UNHANDLED; } } @@ -1734,12 +1743,12 @@ runtime_data_sb_datapath_binding_handler(struct engine_node *node OVS_UNUSED, */ if (get_local_datapath_no_hash(&rt_data->local_datapaths, dp->tunnel_key)) { - return false; + return EN_UNHANDLED; } } } - return true; + return EN_HANDLED_UNCHANGED; } static void @@ -1867,11 +1876,12 @@ en_template_vars_run(struct engine_node *node, void *data) return EN_UPDATED; } -static bool +static enum engine_input_handler_result template_vars_sb_chassis_template_var_handler(struct engine_node *node, void *data) { struct ed_type_template_vars *tv_data = data; + enum engine_input_handler_result result; const struct sbrec_chassis_template_var_table *tv_table = EN_OVSDB_GET(engine_get_input("SB_chassis_template_var", node)); @@ -1889,13 +1899,13 @@ template_vars_sb_chassis_template_var_handler(struct engine_node *node, if (!sset_is_empty(&tv_data->new) || !sset_is_empty(&tv_data->deleted) || !sset_is_empty(&tv_data->updated)) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } else { - engine_set_node_state(node, EN_UNCHANGED); + result = EN_HANDLED_UNCHANGED; } tv_data->change_tracked = true; - return true; + return result; } static void @@ -2050,10 +2060,11 @@ en_addr_sets_run(struct engine_node *node, void *data) return EN_UPDATED; } -static bool +static enum engine_input_handler_result addr_sets_sb_address_set_handler(struct engine_node *node, void *data) { struct ed_type_addr_sets *as = data; + enum engine_input_handler_result result; struct sbrec_address_set_table *as_table = (struct sbrec_address_set_table *)EN_OVSDB_GET( @@ -2064,13 +2075,13 @@ addr_sets_sb_address_set_handler(struct engine_node *node, void *data) if (!sset_is_empty(&as->new) || !sset_is_empty(&as->deleted) || !shash_is_empty(&as->updated)) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } else { - engine_set_node_state(node, EN_UNCHANGED); + result = EN_HANDLED_UNCHANGED; } as->change_tracked = true; - return true; + return result; } struct ed_type_port_groups{ @@ -2240,10 +2251,11 @@ en_port_groups_run(struct engine_node *node, void *data) return EN_UPDATED; } -static bool +static enum engine_input_handler_result port_groups_sb_port_group_handler(struct engine_node *node, void *data) { struct ed_type_port_groups *pg = data; + enum engine_input_handler_result result; const struct sbrec_port_group_table *pg_table = EN_OVSDB_GET(engine_get_input("SB_port_group", node)); @@ -2257,16 +2269,16 @@ port_groups_sb_port_group_handler(struct engine_node *node, void *data) if (!sset_is_empty(&pg->new) || !sset_is_empty(&pg->deleted) || !sset_is_empty(&pg->updated)) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } else { - engine_set_node_state(node, EN_UNCHANGED); + result = EN_HANDLED_UNCHANGED; } pg->change_tracked = true; - return true; + return result; } -static bool +static enum engine_input_handler_result port_groups_runtime_data_handler(struct engine_node *node, void *data) { const struct sbrec_port_group_table *pg_table = @@ -2276,8 +2288,10 @@ port_groups_runtime_data_handler(struct engine_node *node, void *data) struct ed_type_runtime_data *rt_data = engine_get_input_data("runtime_data", node); + enum engine_input_handler_result result; + if (!rt_data->tracked) { - return false; + return EN_UNHANDLED; } if (hmap_is_empty(&rt_data->tracked_dp_bindings)) { @@ -2319,12 +2333,12 @@ port_groups_runtime_data_handler(struct engine_node *node, void *data) out: if (!sset_is_empty(&pg->new) || !sset_is_empty(&pg->deleted) || !sset_is_empty(&pg->updated)) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } else { - engine_set_node_state(node, EN_UNCHANGED); + result = EN_HANDLED_UNCHANGED; } pg->change_tracked = true; - return true; + return result; } static void * @@ -2382,7 +2396,7 @@ en_ct_zones_run(struct engine_node *node, void *data) /* Handles datapath binding changes for the ct_zones engine. * Returns false if the datapath is deleted or if the requested snat * ct zone doesn't match with the ct_zones data. */ -static bool +static enum engine_input_handler_result ct_zones_datapath_binding_handler(struct engine_node *node, void *data) { struct ed_type_ct_zones *ct_zones_data = data; @@ -2402,19 +2416,19 @@ ct_zones_datapath_binding_handler(struct engine_node *node, void *data) if (sbrec_datapath_binding_is_deleted(dp) || sbrec_datapath_binding_is_new(dp)) { /* Fall back to full recompute of ct_zones engine. */ - return false; + return EN_UNHANDLED; } if (!ct_zone_handle_dp_update(&ct_zones_data->ctx, local_dp, &rt_data->lbinding_data.lports)) { - return false; + return EN_UNHANDLED; } } - return true; + return EN_HANDLED_UNCHANGED; } -static bool +static enum engine_input_handler_result ct_zones_runtime_data_handler(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = @@ -2424,7 +2438,7 @@ ct_zones_runtime_data_handler(struct engine_node *node, void *data) /* There is no tracked data. Fall back to full recompute of ct_zones. */ if (!rt_data->tracked) { - return false; + return EN_UNHANDLED; } struct ed_type_ct_zones *ct_zones_data = data; @@ -2441,7 +2455,7 @@ ct_zones_runtime_data_handler(struct engine_node *node, void *data) HMAP_FOR_EACH (tdp, node, tracked_dp_bindings) { if (tdp->tracked_type == TRACKED_RESOURCE_NEW) { /* A new datapath has been added. Fall back to full recompute. */ - return false; + return EN_UNHANDLED; } struct shash_node *shash_node; @@ -2474,11 +2488,7 @@ ct_zones_runtime_data_handler(struct engine_node *node, void *data) } } - if (updated) { - engine_set_node_state(node, EN_UPDATED); - } - - return true; + return updated ? EN_HANDLED_UPDATED : EN_HANDLED_UNCHANGED; } /* The data in the ct_zones node is always valid (i.e., no stale pointers). */ @@ -2855,7 +2865,7 @@ en_lb_data_run(struct engine_node *node, void *data) return EN_UPDATED; } -static bool +static enum engine_input_handler_result lb_data_sb_load_balancer_handler(struct engine_node *node, void *data) { struct ed_type_lb_data *lb_data = data; @@ -2891,13 +2901,13 @@ lb_data_sb_load_balancer_handler(struct engine_node *node, void *data) if (!uuidset_is_empty(&lb_data->deleted) || !uuidset_is_empty(&lb_data->updated) || !uuidset_is_empty(&lb_data->new)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } -static bool +static enum engine_input_handler_result lb_data_template_var_handler(struct engine_node *node, void *data) { struct ed_type_lb_data *lb_data = data; @@ -2907,9 +2917,10 @@ lb_data_template_var_handler(struct engine_node *node, void *data) engine_get_input_data("template_vars", node); const struct sbrec_load_balancer_table *lb_table = EN_OVSDB_GET(engine_get_input("SB_load_balancer", node)); + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; if (!tv_data->change_tracked) { - return false; + return EN_UNHANDLED; } const struct lb_data_ctx_in ctx_in = { @@ -2927,10 +2938,10 @@ lb_data_template_var_handler(struct engine_node *node, void *data) res_name, lb_data_handle_changed_ref, &lb_data->objs_processed, &ctx_in, lb_data, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } SSET_FOR_EACH (res_name, &tv_data->updated) { @@ -2939,10 +2950,10 @@ lb_data_template_var_handler(struct engine_node *node, void *data) res_name, lb_data_handle_changed_ref, &lb_data->objs_processed, &ctx_in, lb_data, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } SSET_FOR_EACH (res_name, &tv_data->new) { @@ -2951,19 +2962,19 @@ lb_data_template_var_handler(struct engine_node *node, void *data) res_name, lb_data_handle_changed_ref, &lb_data->objs_processed, &ctx_in, lb_data, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } lb_data->change_tracked = true; - return true; + return result; } -static bool +static enum engine_input_handler_result lb_data_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED) { struct ed_type_lb_data *lb_data = data; @@ -2977,12 +2988,12 @@ lb_data_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED) /* There are no tracked data. Fall back to full recompute of * lb_ct_tuple. */ if (!rt_data->tracked) { - return false; + return EN_UNHANDLED; } struct hmap *tracked_dp_bindings = &rt_data->tracked_dp_bindings; if (hmap_is_empty(tracked_dp_bindings)) { - return true; + return EN_HANDLED_UNCHANGED; } struct hmap *lbs = NULL; @@ -3023,10 +3034,10 @@ lb_data_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED) if (!uuidset_is_empty(&lb_data->deleted) || !uuidset_is_empty(&lb_data->updated) || !uuidset_is_empty(&lb_data->new)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } static void @@ -3217,7 +3228,7 @@ en_mac_cache_run(struct engine_node *node, void *data) return EN_UPDATED; } -static bool +static enum engine_input_handler_result mac_cache_sb_mac_binding_handler(struct engine_node *node, void *data) { struct mac_cache_data *cache_data = data; @@ -3246,13 +3257,13 @@ mac_cache_sb_mac_binding_handler(struct engine_node *node, void *data) } if (hmap_count(&cache_data->mac_bindings) != previous_size) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } -static bool +static enum engine_input_handler_result mac_cache_sb_fdb_handler(struct engine_node *node, void *data) { struct mac_cache_data *cache_data = data; @@ -3282,13 +3293,13 @@ mac_cache_sb_fdb_handler(struct engine_node *node, void *data) } if (hmap_count(&cache_data->fdbs) != previous_size) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } -static bool +static enum engine_input_handler_result mac_cache_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED) { struct mac_cache_data *cache_data = data; @@ -3305,7 +3316,7 @@ mac_cache_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED) /* There are no tracked data. Fall back to full recompute. */ if (!rt_data->tracked) { - return false; + return EN_UNHANDLED; } size_t previous_mb_size = hmap_count(&cache_data->mac_bindings); @@ -3330,13 +3341,13 @@ mac_cache_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED) if (hmap_count(&cache_data->mac_bindings) != previous_mb_size || hmap_count(&cache_data->fdbs) != previous_fdb_size) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } -static bool +static enum engine_input_handler_result mac_cache_sb_datapath_binding_handler(struct engine_node *node, void *data) { struct mac_cache_data *cache_data = data; @@ -3383,10 +3394,10 @@ mac_cache_sb_datapath_binding_handler(struct engine_node *node, void *data) if (hmap_count(&cache_data->mac_bindings) != previous_mb_size || hmap_count(&cache_data->fdbs) != previous_fdb_size) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } @@ -3463,7 +3474,7 @@ en_dns_cache_run(struct engine_node *node, void *data OVS_UNUSED) return EN_UPDATED; } -static bool +static enum engine_input_handler_result dns_cache_sb_dns_handler(struct engine_node *node, void *data OVS_UNUSED) { const struct sbrec_dns_table *dns_table = @@ -3471,8 +3482,7 @@ dns_cache_sb_dns_handler(struct engine_node *node, void *data OVS_UNUSED) ovn_dns_update_cache(dns_table); - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } static void @@ -3542,13 +3552,17 @@ en_non_vif_data_run(struct engine_node *node, void *data) return EN_UPDATED; } -static bool +static enum engine_input_handler_result non_vif_data_ovs_iface_handler(struct engine_node *node, void *data OVS_UNUSED) { const struct ovsrec_interface_table *iface_table = EN_OVSDB_GET(engine_get_input("OVS_interface", node)); - return local_nonvif_data_handle_ovs_iface_changes(iface_table); + if (local_nonvif_data_handle_ovs_iface_changes(iface_table)) { + return EN_HANDLED_UNCHANGED; + } else { + return EN_UNHANDLED; + } } struct ed_type_northd_options { @@ -3605,7 +3619,7 @@ en_northd_options_run(struct engine_node *node, void *data) return EN_UPDATED; } -static bool +static enum engine_input_handler_result en_northd_options_sb_sb_global_handler(struct engine_node *node, void *data) { struct ed_type_northd_options *n_opts = data; @@ -3613,6 +3627,7 @@ en_northd_options_sb_sb_global_handler(struct engine_node *node, void *data) EN_OVSDB_GET(engine_get_input("SB_sb_global", node)); const struct sbrec_sb_global *sb_global = sbrec_sb_global_table_first(sb_global_table); + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; bool explicit_arp_ns_output = sb_global @@ -3622,7 +3637,7 @@ en_northd_options_sb_sb_global_handler(struct engine_node *node, void *data) if (explicit_arp_ns_output != n_opts->explicit_arp_ns_output) { n_opts->explicit_arp_ns_output = explicit_arp_ns_output; - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } bool always_tunnel = @@ -3633,7 +3648,7 @@ en_northd_options_sb_sb_global_handler(struct engine_node *node, void *data) if (always_tunnel != n_opts->always_tunnel) { n_opts->always_tunnel = always_tunnel; - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } bool register_consolidation = @@ -3644,10 +3659,10 @@ en_northd_options_sb_sb_global_handler(struct engine_node *node, void *data) if (register_consolidation != n_opts->register_consolidation) { n_opts->register_consolidation = register_consolidation; - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } - return true; + return result; } struct ed_type_dhcp_options { @@ -3998,7 +4013,7 @@ en_lflow_output_run(struct engine_node *node, void *data) return EN_UPDATED; } -static bool +static enum engine_input_handler_result lflow_output_sb_logical_flow_handler(struct engine_node *node, void *data) { struct ed_type_lflow_output *fo = data; @@ -4006,13 +4021,14 @@ lflow_output_sb_logical_flow_handler(struct engine_node *node, void *data) struct lflow_ctx_out l_ctx_out; init_lflow_ctx(node, fo, &l_ctx_in, &l_ctx_out); - bool handled = lflow_handle_changed_flows(&l_ctx_in, &l_ctx_out); + if (lflow_handle_changed_flows(&l_ctx_in, &l_ctx_out)) { + return EN_HANDLED_UPDATED; + } - engine_set_node_state(node, EN_UPDATED); - return handled; + return EN_UNHANDLED; } -static bool +static enum engine_input_handler_result lflow_output_flow_sample_collector_set_handler(struct engine_node *node, void *data OVS_UNUSED) { @@ -4026,13 +4042,13 @@ lflow_output_flow_sample_collector_set_handler(struct engine_node *node, const struct ovsrec_open_vswitch *cfg = ovsrec_open_vswitch_table_first(ovs_table); if (!cfg) { - return true; + return EN_HANDLED_UNCHANGED; } const struct ovsrec_bridge *br_int; br_int = get_bridge(bridge_table, br_int_name(ovs_table)); if (!br_int) { - return true; + return EN_HANDLED_UNCHANGED; } const struct ovsrec_flow_sample_collector_set *set; @@ -4043,12 +4059,11 @@ lflow_output_flow_sample_collector_set_handler(struct engine_node *node, flow_collector_ids_clear(&lfo->collector_ids); flow_collector_ids_init_from_table(&lfo->collector_ids, flow_collector_table); - return false; + return EN_UNHANDLED; } } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } static void @@ -4109,7 +4124,7 @@ pflow_output_get_debug(struct engine_node *node, struct physical_debug *debug) "debug_drop_domain_id", 0); } -static bool +static enum engine_input_handler_result lflow_output_sb_mac_binding_handler(struct engine_node *node, void *data) { struct ovsdb_idl_index *sbrec_port_binding_by_name = @@ -4129,11 +4144,10 @@ lflow_output_sb_mac_binding_handler(struct engine_node *node, void *data) lflow_handle_changed_mac_bindings(sbrec_port_binding_by_name, mac_binding_table, local_datapaths, &lfo->flow_table); - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool +static enum engine_input_handler_result lflow_output_sb_static_mac_binding_handler(struct engine_node *node, void *data) { @@ -4154,11 +4168,10 @@ lflow_output_sb_static_mac_binding_handler(struct engine_node *node, lflow_handle_changed_static_mac_bindings(sbrec_port_binding_by_name, smb_table, local_datapaths, &lfo->flow_table); - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool +static enum engine_input_handler_result lflow_output_sb_multicast_group_handler(struct engine_node *node, void *data) { struct ed_type_lflow_output *lfo = data; @@ -4167,14 +4180,13 @@ lflow_output_sb_multicast_group_handler(struct engine_node *node, void *data) struct lflow_ctx_out l_ctx_out; init_lflow_ctx(node, lfo, &l_ctx_in, &l_ctx_out); if (!lflow_handle_changed_mc_groups(&l_ctx_in, &l_ctx_out)) { - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool +static enum engine_input_handler_result lflow_output_sb_port_binding_handler(struct engine_node *node, void *data) { struct ed_type_lflow_output *lfo = data; @@ -4183,14 +4195,13 @@ lflow_output_sb_port_binding_handler(struct engine_node *node, void *data) struct lflow_ctx_out l_ctx_out; init_lflow_ctx(node, lfo, &l_ctx_in, &l_ctx_out); if (!lflow_handle_changed_port_bindings(&l_ctx_in, &l_ctx_out)) { - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool +static enum engine_input_handler_result lflow_output_addr_sets_handler(struct engine_node *node, void *data) { struct ed_type_addr_sets *as_data = @@ -4204,9 +4215,10 @@ lflow_output_addr_sets_handler(struct engine_node *node, void *data) bool changed; const char *ref_name; + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; if (!as_data->change_tracked) { - return false; + return EN_UNHANDLED; } SSET_FOR_EACH (ref_name, &as_data->deleted) { @@ -4215,10 +4227,10 @@ lflow_output_addr_sets_handler(struct engine_node *node, void *data) lflow_handle_changed_ref, l_ctx_out.objs_processed, &l_ctx_in, &l_ctx_out, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } struct shash_node *shash_node; @@ -4234,11 +4246,11 @@ lflow_output_addr_sets_handler(struct engine_node *node, void *data) lflow_handle_changed_ref, l_ctx_out.objs_processed, &l_ctx_in, &l_ctx_out, &changed)) { - return false; + return EN_UNHANDLED; } } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } SSET_FOR_EACH (ref_name, &as_data->new) { @@ -4247,17 +4259,17 @@ lflow_output_addr_sets_handler(struct engine_node *node, void *data) lflow_handle_changed_ref, l_ctx_out.objs_processed, &l_ctx_in, &l_ctx_out, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } - return true; + return result; } -static bool +static enum engine_input_handler_result lflow_output_port_groups_handler(struct engine_node *node, void *data) { struct ed_type_port_groups *pg_data = @@ -4271,9 +4283,10 @@ lflow_output_port_groups_handler(struct engine_node *node, void *data) bool changed; const char *ref_name; + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; if (!pg_data->change_tracked) { - return false; + return EN_UNHANDLED; } SSET_FOR_EACH (ref_name, &pg_data->deleted) { @@ -4282,10 +4295,10 @@ lflow_output_port_groups_handler(struct engine_node *node, void *data) lflow_handle_changed_ref, l_ctx_out.objs_processed, &l_ctx_in, &l_ctx_out, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } SSET_FOR_EACH (ref_name, &pg_data->updated) { @@ -4294,10 +4307,10 @@ lflow_output_port_groups_handler(struct engine_node *node, void *data) lflow_handle_changed_ref, l_ctx_out.objs_processed, &l_ctx_in, &l_ctx_out, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } SSET_FOR_EACH (ref_name, &pg_data->new) { @@ -4306,17 +4319,17 @@ lflow_output_port_groups_handler(struct engine_node *node, void *data) lflow_handle_changed_ref, l_ctx_out.objs_processed, &l_ctx_in, &l_ctx_out, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } - return true; + return result; } -static bool +static enum engine_input_handler_result lflow_output_template_vars_handler(struct engine_node *node, void *data) { struct ed_type_template_vars *tv_data = @@ -4329,9 +4342,10 @@ lflow_output_template_vars_handler(struct engine_node *node, void *data) const char *res_name; bool changed; + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; if (!tv_data->change_tracked) { - return false; + return EN_UNHANDLED; } SSET_FOR_EACH (res_name, &tv_data->deleted) { @@ -4340,10 +4354,10 @@ lflow_output_template_vars_handler(struct engine_node *node, void *data) res_name, lflow_handle_changed_ref, l_ctx_out.objs_processed, &l_ctx_in, &l_ctx_out, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } SSET_FOR_EACH (res_name, &tv_data->updated) { @@ -4352,10 +4366,10 @@ lflow_output_template_vars_handler(struct engine_node *node, void *data) res_name, lflow_handle_changed_ref, l_ctx_out.objs_processed, &l_ctx_in, &l_ctx_out, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } SSET_FOR_EACH (res_name, &tv_data->new) { @@ -4364,17 +4378,17 @@ lflow_output_template_vars_handler(struct engine_node *node, void *data) res_name, lflow_handle_changed_ref, l_ctx_out.objs_processed, &l_ctx_in, &l_ctx_out, &changed)) { - return false; + return EN_UNHANDLED; } if (changed) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } } - return true; + return result; } -static bool +static enum engine_input_handler_result lflow_output_runtime_data_handler(struct engine_node *node, void *data OVS_UNUSED) { @@ -4384,15 +4398,14 @@ lflow_output_runtime_data_handler(struct engine_node *node, /* There is no tracked data. Fall back to full recompute of * flow_output. */ if (!rt_data->tracked) { - return false; + return EN_UNHANDLED; } struct hmap *tracked_dp_bindings = &rt_data->tracked_dp_bindings; if (hmap_is_empty(tracked_dp_bindings)) { - if (rt_data->local_lports_changed) { - engine_set_node_state(node, EN_UPDATED); - } - return true; + return rt_data->local_lports_changed + ? EN_HANDLED_UPDATED + : EN_HANDLED_UNCHANGED; } struct lflow_ctx_in l_ctx_in; @@ -4405,7 +4418,7 @@ lflow_output_runtime_data_handler(struct engine_node *node, if (tdp->tracked_type == TRACKED_RESOURCE_NEW) { if (!lflow_add_flows_for_datapath(tdp->dp, &l_ctx_in, &l_ctx_out)) { - return false; + return EN_UNHANDLED; } } struct shash_node *shash_node; @@ -4414,23 +4427,22 @@ lflow_output_runtime_data_handler(struct engine_node *node, if (!lflow_handle_flows_for_lport( lport->pb, &l_ctx_in, &l_ctx_out, lport->tracked_type == TRACKED_RESOURCE_REMOVED)) { - return false; + return EN_UNHANDLED; } } } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool +static enum engine_input_handler_result lflow_output_lb_data_handler(struct engine_node *node, void *data) { struct ed_type_lflow_output *fo = data; struct ed_type_lb_data *lb_data = engine_get_input_data("lb_data", node); if (!lb_data->change_tracked) { - return false; + return EN_UNHANDLED; } struct lflow_ctx_in l_ctx_in; @@ -4442,11 +4454,10 @@ lflow_output_lb_data_handler(struct engine_node *node, void *data) &lb_data->updated, &lb_data->new); - engine_set_node_state(node, EN_UPDATED); - return handled; + return handled ? EN_HANDLED_UPDATED : EN_UNHANDLED; } -static bool +static enum engine_input_handler_result lflow_output_sb_fdb_handler(struct engine_node *node, void *data) { struct ed_type_lflow_output *fo = data; @@ -4456,11 +4467,10 @@ lflow_output_sb_fdb_handler(struct engine_node *node, void *data) bool handled = lflow_handle_changed_fdbs(&l_ctx_in, &l_ctx_out); - engine_set_node_state(node, EN_UPDATED); - return handled; + return handled ? EN_HANDLED_UPDATED : EN_UNHANDLED; } -static bool +static enum engine_input_handler_result lflow_output_sb_meter_handler(struct engine_node *node, void *data) { struct ed_type_lflow_output *fo = data; @@ -4471,12 +4481,11 @@ lflow_output_sb_meter_handler(struct engine_node *node, void *data) SBREC_METER_TABLE_FOR_EACH_TRACKED (iter, meter_table) { if (ovn_extend_table_desired_lookup_by_name(&fo->meter_table, iter->name)) { - engine_set_node_state(node, EN_UPDATED); - break; + return EN_HANDLED_UPDATED; } } - return true; + return EN_HANDLED_UNCHANGED; } struct ed_type_pflow_output { @@ -4657,7 +4666,7 @@ en_pflow_output_run(struct engine_node *node, void *data) return EN_UPDATED; } -static bool +static enum engine_input_handler_result pflow_output_if_status_mgr_handler(struct engine_node *node, void *data) { @@ -4673,6 +4682,7 @@ pflow_output_if_status_mgr_handler(struct engine_node *node, init_physical_ctx(node, rt_data, non_vif_data, &p_ctx); const struct ovsrec_interface *iface; + enum engine_input_handler_result result = EN_HANDLED_UNCHANGED; OVSREC_INTERFACE_TABLE_FOR_EACH_TRACKED (iface, if_mgr_data->iface_table) { const char *iface_id = smap_get(&iface->external_ids, "iface-id"); if (!iface_id) { @@ -4693,16 +4703,16 @@ pflow_output_if_status_mgr_handler(struct engine_node *node, if (!physical_handle_flows_for_lport(pb, removed, &p_ctx, &pfo->flow_table)) { destroy_physical_ctx(&p_ctx); - return false; + return EN_UNHANDLED; } } - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } destroy_physical_ctx(&p_ctx); - return true; + return result; } -static bool +static enum engine_input_handler_result pflow_output_sb_port_binding_handler(struct engine_node *node, void *data) { @@ -4725,22 +4735,21 @@ pflow_output_sb_port_binding_handler(struct engine_node *node, /* Trigger a full recompute if type column is updated. */ if (sbrec_port_binding_is_updated(pb, SBREC_PORT_BINDING_COL_TYPE)) { destroy_physical_ctx(&p_ctx); - return false; + return EN_UNHANDLED; } bool removed = sbrec_port_binding_is_deleted(pb); if (!physical_handle_flows_for_lport(pb, removed, &p_ctx, &pfo->flow_table)) { destroy_physical_ctx(&p_ctx); - return false; + return EN_UNHANDLED; } } - engine_set_node_state(node, EN_UPDATED); destroy_physical_ctx(&p_ctx); - return true; + return EN_HANDLED_UPDATED; } -static bool +static enum engine_input_handler_result pflow_output_sb_multicast_group_handler(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = @@ -4755,12 +4764,11 @@ pflow_output_sb_multicast_group_handler(struct engine_node *node, void *data) physical_handle_mc_group_changes(&p_ctx, &pfo->flow_table); - engine_set_node_state(node, EN_UPDATED); destroy_physical_ctx(&p_ctx); - return true; + return EN_HANDLED_UPDATED; } -static bool +static enum engine_input_handler_result pflow_output_runtime_data_handler(struct engine_node *node, void *data) { struct ed_type_runtime_data *rt_data = @@ -4771,12 +4779,12 @@ pflow_output_runtime_data_handler(struct engine_node *node, void *data) /* There is no tracked data. Fall back to full recompute of * pflow_output. */ if (!rt_data->tracked) { - return false; + return EN_UNHANDLED; } struct hmap *tracked_dp_bindings = &rt_data->tracked_dp_bindings; if (hmap_is_empty(tracked_dp_bindings)) { - return true; + return EN_HANDLED_UNCHANGED; } struct ed_type_pflow_output *pfo = data; @@ -4790,7 +4798,7 @@ pflow_output_runtime_data_handler(struct engine_node *node, void *data) /* Fall back to full recompute when a local datapath * is added or deleted. */ destroy_physical_ctx(&p_ctx); - return false; + return EN_UNHANDLED; } struct shash_node *shash_node; @@ -4801,17 +4809,16 @@ pflow_output_runtime_data_handler(struct engine_node *node, void *data) if (!physical_handle_flows_for_lport(lport->pb, removed, &p_ctx, &pfo->flow_table)) { destroy_physical_ctx(&p_ctx); - return false; + return EN_UNHANDLED; } } } - engine_set_node_state(node, EN_UPDATED); destroy_physical_ctx(&p_ctx); - return true; + return EN_HANDLED_UPDATED; } -static bool +static enum engine_input_handler_result pflow_output_ct_zones_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { @@ -4827,16 +4834,16 @@ pflow_output_ct_zones_handler(struct engine_node *node OVS_UNUSED, * - pflow_output handler for the runtime_data adds the physical * flows for the claimed lport. * */ - return !ct_zones_data->recomputed; + return ct_zones_data->recomputed ? EN_UNHANDLED : EN_HANDLED_UNCHANGED; } -static bool +static enum engine_input_handler_result pflow_output_activated_ports_handler(struct engine_node *node, void *data) { struct ed_type_activated_ports *ap = engine_get_input_data("activated_ports", node); if (!ap->activated_ports) { - return true; + return EN_HANDLED_UNCHANGED; } struct ed_type_pflow_output *pfo = data; @@ -4865,17 +4872,16 @@ pflow_output_activated_ports_handler(struct engine_node *node, void *data) if (!physical_handle_flows_for_lport(pb, false, &p_ctx, &pfo->flow_table)) { destroy_physical_ctx(&p_ctx); - return false; + return EN_UNHANDLED; } tag_port_as_activated_in_engine(pp); } } - engine_set_node_state(node, EN_UPDATED); destroy_physical_ctx(&p_ctx); - return true; + return EN_HANDLED_UPDATED; } -static bool +static enum engine_input_handler_result pflow_output_debug_handler(struct engine_node *node, void *data) { struct ed_type_pflow_output *pfo = data; @@ -4886,10 +4892,9 @@ pflow_output_debug_handler(struct engine_node *node, void *data) if (pfo->debug.collector_set_id != debug.collector_set_id || pfo->debug.obs_domain_id != debug.obs_domain_id) { pfo->debug = debug; - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } static void * @@ -4912,52 +4917,46 @@ en_controller_output_run(struct engine_node *node OVS_UNUSED, return EN_UPDATED; } -static bool -controller_output_pflow_output_handler(struct engine_node *node, +static enum engine_input_handler_result +controller_output_pflow_output_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool -controller_output_lflow_output_handler(struct engine_node *node, +static enum engine_input_handler_result +controller_output_lflow_output_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool -controller_output_mac_cache_handler(struct engine_node *node, +static enum engine_input_handler_result +controller_output_mac_cache_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool -controller_output_bfd_chassis_handler(struct engine_node *node, +static enum engine_input_handler_result +controller_output_bfd_chassis_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool -controller_output_acl_id_handler(struct engine_node *node, +static enum engine_input_handler_result +controller_output_acl_id_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -static bool -controller_output_route_exchange_handler(struct engine_node *node, +static enum engine_input_handler_result +controller_output_route_exchange_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } /* Handles sbrec_chassis changes. @@ -4966,7 +4965,7 @@ controller_output_route_exchange_handler(struct engine_node *node, * any flow computation. Encap changes will also result in * sbrec_chassis changes, but we handle encap changes separately. */ -static bool +static enum engine_input_handler_result pflow_lflow_output_sb_chassis_handler(struct engine_node *node, void *data OVS_UNUSED) { @@ -4976,11 +4975,11 @@ pflow_lflow_output_sb_chassis_handler(struct engine_node *node, 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)) { - return false; + return EN_UNHANDLED; } } - return true; + return EN_HANDLED_UNCHANGED; } struct ed_type_route { @@ -5088,7 +5087,7 @@ en_route_cleanup(void *data) hmap_destroy(&re_data->announce_routes); } -static bool +static enum engine_input_handler_result route_runtime_data_handler(struct engine_node *node, void *data) { struct ed_type_route *re_data = data; @@ -5096,7 +5095,7 @@ route_runtime_data_handler(struct engine_node *node, void *data) engine_get_input_data("runtime_data", node); if (!rt_data->tracked) { - return false; + return EN_UNHANDLED; } struct tracked_datapath *t_dp; @@ -5107,7 +5106,7 @@ route_runtime_data_handler(struct engine_node *node, void *data) if (re_t_dp) { /* XXX: Until we get I-P support for route exchange we need to * request recompute. */ - return false; + return EN_UNHANDLED; } struct shash_node *shash_node; @@ -5116,15 +5115,15 @@ route_runtime_data_handler(struct engine_node *node, void *data) if (route_exchange_relevant_port(lport->pb)) { /* XXX: Until we get I-P support for route exchange we need to * request recompute. */ - return false; + return EN_UNHANDLED; } } } - return true; + return EN_HANDLED_UNCHANGED; } -static bool +static enum engine_input_handler_result route_sb_port_binding_data_handler(struct engine_node *node, void *data) { struct ed_type_route *re_data = data; @@ -5159,13 +5158,13 @@ route_sb_port_binding_data_handler(struct engine_node *node, void *data) if (re_t_dp) { /* XXX: Until we get I-P support for route exchange we need to * request recompute. */ - return false; + return EN_UNHANDLED; } if (route_exchange_relevant_port(sbrec_pb)) { /* XXX: Until we get I-P support for route exchange we need to * request recompute. */ - return false; + return EN_UNHANDLED; } if (sset_contains(&re_data->tracked_ports_local, @@ -5174,7 +5173,7 @@ route_sb_port_binding_data_handler(struct engine_node *node, void *data) &rt_data->active_tunnels, sbrec_pb)) { /* The port was previously local but now it no longer is. */ - return false; + return EN_UNHANDLED; } } @@ -5184,16 +5183,16 @@ route_sb_port_binding_data_handler(struct engine_node *node, void *data) &rt_data->active_tunnels, sbrec_pb)) { /* The port was previously remote but now we bound it. */ - return false; + return EN_UNHANDLED; } } } - return true; + return EN_HANDLED_UNCHANGED; } -static bool +static enum engine_input_handler_result route_sb_advertised_route_data_handler(struct engine_node *node, void *data) { struct ed_type_route *re_data = data; @@ -5209,10 +5208,10 @@ route_sb_advertised_route_data_handler(struct engine_node *node, void *data) if (re_t_dp) { /* XXX: Until we get I-P support for route exchange we need to * request recompute. */ - return false; + return EN_UNHANDLED; } } - return true; + return EN_HANDLED_UNCHANGED; } struct ed_type_route_exchange { diff --git a/lib/inc-proc-eng.c b/lib/inc-proc-eng.c index 70913a00c..953023bb1 100644 --- a/lib/inc-proc-eng.c +++ b/lib/inc-proc-eng.c @@ -274,7 +274,8 @@ engine_get_input_data(const char *input_name, struct engine_node *node) void engine_add_input(struct engine_node *node, struct engine_node *input, - bool (*change_handler)(struct engine_node *, void *)) + enum engine_input_handler_result (*change_handler) + (struct engine_node *, void *)) { ovs_assert(node->n_inputs < ENGINE_MAX_INPUT); node->inputs[node->n_inputs].node = input; @@ -453,7 +454,8 @@ engine_compute(struct engine_node *node, bool recompute_allowed) * the node handler. */ long long int now = time_msec(); - bool handled = node->inputs[i].change_handler(node, node->data); + enum engine_input_handler_result handled; + handled = node->inputs[i].change_handler(node, node->data); long long int delta_time = time_msec() - now; if (delta_time > engine_compute_log_timeout_msec) { static struct vlog_rate_limit rl = @@ -465,11 +467,17 @@ engine_compute(struct engine_node *node, bool recompute_allowed) VLOG_DBG("node: %s, handler for input %s took %lldms", node->name, node->inputs[i].node->name, delta_time); } - if (!handled) { + if (handled == EN_UNHANDLED) { engine_recompute(node, recompute_allowed, "failed handler for input %s", node->inputs[i].node->name); return (node->state != EN_CANCELED); + } else if (!engine_node_changed(node)) { + /* We only want to update the state if the node is unchanged. + * Otherwise, handlers might change the state from EN_UPDATED + * back to EN_UNCHANGED. + */ + engine_set_node_state(node, (enum engine_node_state) handled); } } } diff --git a/lib/inc-proc-eng.h b/lib/inc-proc-eng.h index 5ff320cf8..8d9348122 100644 --- a/lib/inc-proc-eng.h +++ b/lib/inc-proc-eng.h @@ -170,22 +170,6 @@ struct engine_arg { struct engine_node; -struct engine_node_input { - /* The input node. */ - struct engine_node *node; - - /* Change handler for changes of the input node. The changes may need to be - * evaluated against all the other inputs. Returns: - * - true: if change can be handled - * - false: if change cannot be handled (indicating full recompute needed) - * A change handler can also call engine_get_context() but it must make - * sure the txn pointers returned by it are non-NULL. In case the change - * handler needs to use the txn pointers returned by engine_get_context(), - * and the pointers are NULL, the change handler MUST return false. - */ - bool (*change_handler)(struct engine_node *node, void *data); -}; - enum engine_node_state { EN_STALE, /* Data in the node is not up to date with the DB. */ EN_UPDATED, /* Data in the node is valid but was updated during the @@ -200,6 +184,33 @@ enum engine_node_state { EN_STATE_MAX, }; +enum engine_input_handler_result { + EN_UNHANDLED = -1, + EN_HANDLED_UPDATED = EN_UPDATED, + EN_HANDLED_UNCHANGED = EN_UNCHANGED, +}; + +struct engine_node_input { + /* The input node. */ + struct engine_node *node; + + /* Change handler for changes of the input node. The changes may need to be + * evaluated against all the other inputs. Returns: + * - EN_UNHANDLED: the change cannot be handled (indicating full + * recompute needed). + * - EN_HANDLED_UPDATED: the change can be handled, and the node's + * data was updated as a result. + * - EN_HANDLED_UNCHANGED: the change can be handled, and the node's + * data was left unchanged. + * A change handler can also call engine_get_context() but it must make + * sure the txn pointers returned by it are non-NULL. In case the change + * handler needs to use the txn pointers returned by engine_get_context(), + * and the pointers are NULL, the change handler MUST return EN_UNHANDLED. + */ + enum engine_input_handler_result (*change_handler) + (struct engine_node *node, void *data); +}; + struct engine_stats { uint64_t recompute; uint64_t compute; @@ -295,7 +306,8 @@ void *engine_get_input_data(const char *input_name, struct engine_node *); * be able to process the change incrementally, and will fall back to call * the run method to recompute. */ void engine_add_input(struct engine_node *node, struct engine_node *input, - bool (*change_handler)(struct engine_node *, void *)); + enum engine_input_handler_result (*change_handler) + (struct engine_node *, void *)); /* Force the engine to recompute everything. It is used * in circumstances when we are not sure there is change or not, or @@ -385,10 +397,10 @@ struct ovsdb_idl_index * engine_ovsdb_node_get_index(struct engine_node *, const char *name); /* Any engine node can use this function for no-op handlers. */ -static inline bool +static inline enum engine_input_handler_result engine_noop_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - return true; + return EN_HANDLED_UNCHANGED; } /* Adds an OVSDB IDL index to the node. This should be called only after diff --git a/northd/en-acl-ids.h b/northd/en-acl-ids.h index cc0b58628..8aee7a5cb 100644 --- a/northd/en-acl-ids.h +++ b/northd/en-acl-ids.h @@ -6,7 +6,6 @@ #include "lib/inc-proc-eng.h" -bool northd_acl_id_handler(struct engine_node *node, void *data); void *en_acl_id_init(struct engine_node *, struct engine_arg *); enum engine_node_state en_acl_id_run(struct engine_node *, void *data); void en_acl_id_cleanup(void *data); diff --git a/northd/en-advertised-route-sync.c b/northd/en-advertised-route-sync.c index 8bc1d999e..fce3821c2 100644 --- a/northd/en-advertised-route-sync.c +++ b/northd/en-advertised-route-sync.c @@ -132,7 +132,7 @@ advertised_route_table_sync( const struct hmap *dynamic_routes, struct advertised_route_sync_data *data); -bool +enum engine_input_handler_result advertised_route_sync_lr_stateful_change_handler(struct engine_node *node, void *data_) { @@ -149,21 +149,21 @@ advertised_route_sync_lr_stateful_change_handler(struct engine_node *node, lr_stateful_rec = hmapx_node->data; if (uuidset_contains(&data->nb_lr, &lr_stateful_rec->nbr_uuid)) { - return false; + return EN_UNHANDLED; } } - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result advertised_route_sync_northd_change_handler(struct engine_node *node, void *data_) { struct advertised_route_sync_data *data = data_; struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - return false; + return EN_UNHANDLED; } /* We indirectly use northd_data->ls_ports if we announce host routes. @@ -175,25 +175,25 @@ advertised_route_sync_northd_change_handler(struct engine_node *node, op = hmapx_node->data; if (uuidset_contains(&data->nb_ls, &op->od->nbs->header_.uuid)) { - return false; + return EN_UNHANDLED; } } HMAPX_FOR_EACH (hmapx_node, &northd_data->trk_data.trk_lsps.updated) { op = hmapx_node->data; if (uuidset_contains(&data->nb_ls, &op->od->nbs->header_.uuid)) { - return false; + return EN_UNHANDLED; } } HMAPX_FOR_EACH (hmapx_node, &northd_data->trk_data.trk_lsps.deleted) { op = hmapx_node->data; if (uuidset_contains(&data->nb_ls, &op->od->nbs->header_.uuid)) { - return false; + return EN_UNHANDLED; } } - return true; + return EN_HANDLED_UNCHANGED; } static void diff --git a/northd/en-advertised-route-sync.h b/northd/en-advertised-route-sync.h index 64a2e9f1b..7a2927000 100644 --- a/northd/en-advertised-route-sync.h +++ b/northd/en-advertised-route-sync.h @@ -28,9 +28,11 @@ struct advertised_route_sync_data { struct uuidset nb_ls; }; -bool advertised_route_sync_lr_stateful_change_handler(struct engine_node *, - void *data); -bool advertised_route_sync_northd_change_handler(struct engine_node *, +enum engine_input_handler_result +advertised_route_sync_lr_stateful_change_handler(struct engine_node *, + void *data); +enum engine_input_handler_result +advertised_route_sync_northd_change_handler(struct engine_node *, void *data); void *en_advertised_route_sync_init(struct engine_node *, struct engine_arg *); void en_advertised_route_sync_cleanup(void *data); diff --git a/northd/en-ecmp-nexthop.c b/northd/en-ecmp-nexthop.c index ccdf5af41..7e9ed4f34 100644 --- a/northd/en-ecmp-nexthop.c +++ b/northd/en-ecmp-nexthop.c @@ -149,7 +149,7 @@ ecmp_nexthop_lookup(struct ovsdb_idl_index *sbrec_ecmp_by_nexthop, return retval; } -bool +enum engine_input_handler_result ecmp_nexthop_mac_binding_handler(struct engine_node *node, void *data OVS_UNUSED) { @@ -179,7 +179,7 @@ ecmp_nexthop_mac_binding_handler(struct engine_node *node, } } - return true; + return EN_HANDLED_UNCHANGED; } void * diff --git a/northd/en-ecmp-nexthop.h b/northd/en-ecmp-nexthop.h index 6983b799f..492632832 100644 --- a/northd/en-ecmp-nexthop.h +++ b/northd/en-ecmp-nexthop.h @@ -24,7 +24,8 @@ #include "lib/inc-proc-eng.h" -bool ecmp_nexthop_mac_binding_handler(struct engine_node *, void *data); +enum engine_input_handler_result +ecmp_nexthop_mac_binding_handler(struct engine_node *, void *data); enum engine_node_state en_ecmp_nexthop_run(struct engine_node *, void *data); void *en_ecmp_nexthop_init(struct engine_node *, struct engine_arg *); void en_ecmp_nexthop_cleanup(void *data); diff --git a/northd/en-global-config.c b/northd/en-global-config.c index 4fb08d8ff..98c2fd0cc 100644 --- a/northd/en-global-config.c +++ b/northd/en-global-config.c @@ -197,7 +197,7 @@ en_global_config_clear_tracked_data(void *data) config_data->tracked_data.chassis_features_changed = false; } -bool +enum engine_input_handler_result global_config_nb_global_handler(struct engine_node *node, void *data) { const struct nbrec_nb_global_table *nb_global_table = @@ -211,19 +211,19 @@ global_config_nb_global_handler(struct engine_node *node, void *data) const struct nbrec_nb_global *nb = nbrec_nb_global_table_first(nb_global_table); if (!nb) { - return false; + return EN_UNHANDLED; } const struct sbrec_sb_global *sb = sbrec_sb_global_table_first(sb_global_table); if (!sb) { - return false; + return EN_UNHANDLED; } /* We are only interested in ipsec and options column. */ if (!nbrec_nb_global_is_updated(nb, NBREC_NB_GLOBAL_COL_IPSEC) && !nbrec_nb_global_is_updated(nb, NBREC_NB_GLOBAL_COL_OPTIONS)) { - return true; + return EN_HANDLED_UNCHANGED; } if (nb->ipsec != sb->ipsec) { @@ -234,7 +234,7 @@ global_config_nb_global_handler(struct engine_node *node, void *data) config_data->tracked = true; if (smap_equal(&nb->options, &config_data->nb_options)) { - return true; + return EN_HANDLED_UNCHANGED; } /* Return false if an option is out of sync and requires updating the @@ -242,31 +242,31 @@ global_config_nb_global_handler(struct engine_node *node, void *data) /* Check if svc_monitor_mac has changed or not. */ if (config_out_of_sync(&nb->options, &config_data->nb_options, "svc_monitor_mac", true)) { - return false; + return EN_UNHANDLED; } /* Check if max_tunid has changed or not. */ if (config_out_of_sync(&nb->options, &config_data->nb_options, "max_tunid", true)) { - return false; + return EN_UNHANDLED; } /* Check if mac_prefix has changed or not. */ if (config_out_of_sync(&nb->options, &config_data->nb_options, "mac_prefix", true)) { - return false; + return EN_UNHANDLED; } /* Check if ignore_chassis_features has changed or not. */ if (config_out_of_sync(&nb->options, &config_data->nb_options, "ignore_chassis_features", false)) { - return false; + return EN_UNHANDLED; } /* Check if northd_internal_version has changed or not. */ if (config_out_of_sync(&nb->options, &config_data->nb_options, "northd_internal_version", false)) { - return false; + return EN_UNHANDLED; } if (check_nb_options_out_of_sync(nb, config_data, sampling_apps)) { @@ -278,11 +278,10 @@ global_config_nb_global_handler(struct engine_node *node, void *data) update_sb_config_options_to_sbrec(config_data, sb); - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool +enum engine_input_handler_result global_config_sb_global_handler(struct engine_node *node, void *data) { const struct sbrec_sb_global_table *sb_global_table = @@ -291,20 +290,20 @@ global_config_sb_global_handler(struct engine_node *node, void *data) const struct sbrec_sb_global *sb = sbrec_sb_global_table_first(sb_global_table); if (!sb) { - return false; + return EN_UNHANDLED; } struct ed_type_global_config *config_data = data; if (!smap_equal(&sb->options, &config_data->sb_options)) { - return false; + return EN_UNHANDLED; } /* No need to update the engine node. */ - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result global_config_sb_chassis_handler(struct engine_node *node, void *data) { struct ed_type_global_config *config_data = data; @@ -318,20 +317,20 @@ global_config_sb_chassis_handler(struct engine_node *node, void *data) || sbrec_chassis_is_deleted(chassis) || sbrec_chassis_is_updated(chassis, SBREC_CHASSIS_COL_ENCAPS)) { - return false; + return EN_UNHANDLED; } for (size_t i = 0; i < chassis->n_encaps; i++) { if (sbrec_encap_row_get_seqno(chassis->encaps[i], OVSDB_IDL_CHANGE_MODIFY) > 0) { - return false; + return EN_UNHANDLED; } } } if (smap_get_bool(&config_data->nb_options, "ignore_chassis_features", false)) { - return true; + return EN_HANDLED_UNCHANGED; } bool reevaluate_chassis_features = false; @@ -346,7 +345,7 @@ global_config_sb_chassis_handler(struct engine_node *node, void *data) } if (!reevaluate_chassis_features) { - return true; + return EN_HANDLED_UNCHANGED; } struct chassis_features present_features = config_data->features; @@ -359,15 +358,15 @@ global_config_sb_chassis_handler(struct engine_node *node, void *data) if (chassis_features_changed(&present_features, &config_data->features)) { config_data->tracked_data.chassis_features_changed = true; config_data->tracked = true; - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } /* generic global config handler for any engine node which has global_config * has an input node . */ -bool +enum engine_input_handler_result node_global_config_handler(struct engine_node *node, void *data OVS_UNUSED) { struct ed_type_global_config *global_config = @@ -376,13 +375,13 @@ node_global_config_handler(struct engine_node *node, void *data OVS_UNUSED) if (!global_config->tracked || global_config->tracked_data.chassis_features_changed || global_config->tracked_data.nb_options_changed) { - return false; + return EN_UNHANDLED; } - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result global_config_nb_logical_switch_handler(struct engine_node *node, void *data) { @@ -393,6 +392,7 @@ global_config_nb_logical_switch_handler(struct engine_node *node, EN_OVSDB_GET(engine_get_input("NB_nb_global", node))); const struct sbrec_chassis_table *sbrec_chassis_table = EN_OVSDB_GET(engine_get_input("SB_chassis", node)); + enum engine_input_handler_result result; bool ic_vxlan_mode = false; const struct nbrec_logical_switch *nbs; @@ -411,9 +411,9 @@ global_config_nb_logical_switch_handler(struct engine_node *node, const char *cur_max_tunid = smap_get(options, "max_tunid"); if (!cur_max_tunid || strcmp(max_tunid, cur_max_tunid)) { - engine_set_node_state(node, EN_UPDATED); + result = EN_HANDLED_UPDATED; } else { - engine_set_node_state(node, EN_UNCHANGED); + result = EN_HANDLED_UNCHANGED; } smap_replace(options, "max_tunid", max_tunid); @@ -426,7 +426,7 @@ global_config_nb_logical_switch_handler(struct engine_node *node, config_data->tracked = true; - return true; + return result; } /* static functions. */ diff --git a/northd/en-global-config.h b/northd/en-global-config.h index 36acf8d64..08da8a5ab 100644 --- a/northd/en-global-config.h +++ b/northd/en-global-config.h @@ -58,14 +58,18 @@ enum engine_node_state en_global_config_run(struct engine_node *, void *data); void en_global_config_cleanup(void *data); void en_global_config_clear_tracked_data(void *data); -bool global_config_nb_global_handler(struct engine_node *, void *data); -bool global_config_sb_global_handler(struct engine_node *, void *data); -bool global_config_sb_chassis_handler(struct engine_node *, void *data); -bool global_config_nb_logical_switch_handler(struct engine_node *node, - void *data); +enum engine_input_handler_result +global_config_nb_global_handler(struct engine_node *, void *data); +enum engine_input_handler_result +global_config_sb_global_handler(struct engine_node *, void *data); +enum engine_input_handler_result +global_config_sb_chassis_handler(struct engine_node *, void *data); +enum engine_input_handler_result +global_config_nb_logical_switch_handler(struct engine_node *node, void *data); /* generic global config handler for any engine node which has global_config * has an input node . */ -bool node_global_config_handler(struct engine_node *, void *data); +enum engine_input_handler_result +node_global_config_handler(struct engine_node *, void *data); #endif /* EN_GLOBAL_CONFIG_H */ diff --git a/northd/en-group-ecmp-route.c b/northd/en-group-ecmp-route.c index 1c6524f2e..067c83492 100644 --- a/northd/en-group-ecmp-route.c +++ b/northd/en-group-ecmp-route.c @@ -464,7 +464,7 @@ handle_deleted_route(struct group_ecmp_route_data *data, return true; } -bool +enum engine_input_handler_result group_ecmp_route_learned_route_change_handler(struct engine_node *eng_node, void *_data) { @@ -474,7 +474,7 @@ group_ecmp_route_learned_route_change_handler(struct engine_node *eng_node, if (!learned_route_data->tracked) { data->tracked = false; - return false; + return EN_UNHANDLED; } data->tracked = true; @@ -488,7 +488,7 @@ group_ecmp_route_learned_route_change_handler(struct engine_node *eng_node, pr = hmapx_node->data; if (!handle_deleted_route(data, pr, &updated_routes)) { hmapx_destroy(&updated_routes); - return false; + return EN_UNHANDLED; } } @@ -515,7 +515,7 @@ group_ecmp_route_learned_route_change_handler(struct engine_node *eng_node, if (!(hmapx_is_empty(&data->trk_data.crupdated_datapath_routes) && hmapx_is_empty(&data->trk_data.deleted_datapath_routes))) { - engine_set_node_state(eng_node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } diff --git a/northd/en-group-ecmp-route.h b/northd/en-group-ecmp-route.h index d593d4e94..91c8552df 100644 --- a/northd/en-group-ecmp-route.h +++ b/northd/en-group-ecmp-route.h @@ -93,8 +93,9 @@ void en_group_ecmp_route_clear_tracked_data(void *data); enum engine_node_state en_group_ecmp_route_run(struct engine_node *, void *data); -bool group_ecmp_route_learned_route_change_handler(struct engine_node *, - void *data); +enum engine_input_handler_result +group_ecmp_route_learned_route_change_handler(struct engine_node *, + void *data); struct group_ecmp_datapath *group_ecmp_datapath_lookup( const struct group_ecmp_route_data *data, diff --git a/northd/en-lb-data.c b/northd/en-lb-data.c index 4d1699500..3b19d9ac9 100644 --- a/northd/en-lb-data.c +++ b/northd/en-lb-data.c @@ -132,7 +132,7 @@ en_lb_data_clear_tracked_data(void *data) /* Handler functions. */ -bool +enum engine_input_handler_result lb_data_load_balancer_handler(struct engine_node *node, void *data) { const struct nbrec_load_balancer_table *nb_lb_table = @@ -214,20 +214,19 @@ lb_data_load_balancer_handler(struct engine_node *node, void *data) if (routable != lb->routable) { /* If routable is toggled trigger a full recompute. */ - return false; + return EN_UNHANDLED; } if (neigh_mode != lb->neigh_mode) { /* If neigh_mode is updated trigger a full recompute. */ - return false; + return EN_UNHANDLED; } } } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool +enum engine_input_handler_result lb_data_load_balancer_group_handler(struct engine_node *node, void *data) { struct ed_type_lb_data *lb_data = (struct ed_type_lb_data *) data; @@ -318,11 +317,10 @@ lb_data_load_balancer_group_handler(struct engine_node *node, void *data) } } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool +enum engine_input_handler_result lb_data_logical_switch_handler(struct engine_node *node, void *data) { struct ed_type_lb_data *lb_data = (struct ed_type_lb_data *) data; @@ -376,13 +374,10 @@ lb_data_logical_switch_handler(struct engine_node *node, void *data) } } - if (changed) { - engine_set_node_state(node, EN_UPDATED); - } - return true; + return changed ? EN_HANDLED_UPDATED : EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result lb_data_logical_router_handler(struct engine_node *node, void *data) { struct ed_type_lb_data *lb_data = (struct ed_type_lb_data *) data; @@ -436,10 +431,7 @@ lb_data_logical_router_handler(struct engine_node *node, void *data) } } - if (changed) { - engine_set_node_state(node, EN_UPDATED); - } - return true; + return changed ? EN_HANDLED_UPDATED : EN_HANDLED_UNCHANGED; } /* static functions. */ diff --git a/northd/en-lb-data.h b/northd/en-lb-data.h index 6a5fe169b..583b3e412 100644 --- a/northd/en-lb-data.h +++ b/northd/en-lb-data.h @@ -114,9 +114,13 @@ enum engine_node_state en_lb_data_run(struct engine_node *, void *data); void en_lb_data_cleanup(void *data); void en_lb_data_clear_tracked_data(void *data); -bool lb_data_load_balancer_handler(struct engine_node *, void *data); -bool lb_data_load_balancer_group_handler(struct engine_node *, void *data); -bool lb_data_logical_switch_handler(struct engine_node *, void *data); -bool lb_data_logical_router_handler(struct engine_node *, void *data); +enum engine_input_handler_result +lb_data_load_balancer_handler(struct engine_node *, void *data); +enum engine_input_handler_result +lb_data_load_balancer_group_handler(struct engine_node *, void *data); +enum engine_input_handler_result +lb_data_logical_switch_handler(struct engine_node *, void *data); +enum engine_input_handler_result +lb_data_logical_router_handler(struct engine_node *, void *data); #endif /* end of EN_NORTHD_LB_DATA_H */ diff --git a/northd/en-learned-route-sync.c b/northd/en-learned-route-sync.c index b8252ff11..f14f610ac 100644 --- a/northd/en-learned-route-sync.c +++ b/northd/en-learned-route-sync.c @@ -35,13 +35,13 @@ routes_table_sync( const struct ovn_datapaths *lr_datapaths, struct hmap *parsed_routes_out); -bool +enum engine_input_handler_result learned_route_sync_northd_change_handler(struct engine_node *node, void *data_ OVS_UNUSED) { struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - return false; + return EN_UNHANDLED; } /* This node uses the below data from the en_northd engine node. @@ -56,7 +56,7 @@ learned_route_sync_northd_change_handler(struct engine_node *node, * logical router ports, we need to revisit this handler. */ - return true; + return EN_HANDLED_UNCHANGED; } static void @@ -245,7 +245,7 @@ find_learned_route(const struct sbrec_learned_route *learned_route, &learned_route->header_, routes); } -bool +enum engine_input_handler_result learned_route_sync_sb_learned_route_change_handler(struct engine_node *node, void *data_) { @@ -293,12 +293,12 @@ learned_route_sync_sb_learned_route_change_handler(struct engine_node *node, if (!hmapx_is_empty(&data->trk_data.trk_created_parsed_route) || !hmapx_is_empty(&data->trk_data.trk_deleted_parsed_route)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; fail: routes_sync_clear_tracked(data); - return false; + return EN_UNHANDLED; } diff --git a/northd/en-learned-route-sync.h b/northd/en-learned-route-sync.h index c9ad14c9e..8d3801b75 100644 --- a/northd/en-learned-route-sync.h +++ b/northd/en-learned-route-sync.h @@ -41,10 +41,11 @@ struct learned_route_sync_data { struct learned_routes_tracked_data trk_data; }; -bool learned_route_sync_northd_change_handler(struct engine_node *, - void *data); -bool learned_route_sync_sb_learned_route_change_handler(struct engine_node *, - void *data); +enum engine_input_handler_result +learned_route_sync_northd_change_handler(struct engine_node *, void *data); +enum engine_input_handler_result +learned_route_sync_sb_learned_route_change_handler(struct engine_node *, + void *data); void *en_learned_route_sync_init(struct engine_node *, struct engine_arg *); void en_learned_route_sync_cleanup(void *data); void en_learned_route_sync_clear_tracked_data(void *data); diff --git a/northd/en-lflow.c b/northd/en-lflow.c index da83f7fd8..6ad14d0b8 100644 --- a/northd/en-lflow.c +++ b/northd/en-lflow.c @@ -126,7 +126,7 @@ en_lflow_run(struct engine_node *node, void *data) return EN_UPDATED; } -bool +enum engine_input_handler_result lflow_northd_handler(struct engine_node *node, void *data) { @@ -145,20 +145,19 @@ lflow_northd_handler(struct engine_node *node, &northd_data->trk_data.trk_lsps, &lflow_input, lflow_data->lflow_table)) { - return false; + return EN_UNHANDLED; } if (!lflow_handle_northd_lb_changes( eng_ctx->ovnsb_idl_txn, &northd_data->trk_data.trk_lbs, &lflow_input, lflow_data->lflow_table)) { - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool +enum engine_input_handler_result lflow_port_group_handler(struct engine_node *node, void *data OVS_UNUSED) { struct port_group_data *pg_data = @@ -168,21 +167,20 @@ lflow_port_group_handler(struct engine_node *node, void *data OVS_UNUSED) * need to reprocess lflows. Otherwise, there might be a need to * add/delete port-group ACLs to/from switches. */ if (pg_data->ls_port_groups_sets_changed) { - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool +enum engine_input_handler_result lflow_lr_stateful_handler(struct engine_node *node, void *data) { struct ed_type_lr_stateful *lr_sful_data = engine_get_input_data("lr_stateful", node); if (!lr_stateful_has_tracked_data(&lr_sful_data->trk_data)) { - return false; + return EN_UNHANDLED; } const struct engine_context *eng_ctx = engine_get_context(); @@ -194,21 +192,20 @@ lflow_lr_stateful_handler(struct engine_node *node, void *data) &lr_sful_data->trk_data, &lflow_input, lflow_data->lflow_table)) { - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool +enum engine_input_handler_result lflow_ls_stateful_handler(struct engine_node *node, void *data) { struct ed_type_ls_stateful *ls_sful_data = engine_get_input_data("ls_stateful", node); if (!ls_stateful_has_tracked_data(&ls_sful_data->trk_data)) { - return false; + return EN_UNHANDLED; } const struct engine_context *eng_ctx = engine_get_context(); @@ -220,14 +217,13 @@ lflow_ls_stateful_handler(struct engine_node *node, void *data) &ls_sful_data->trk_data, &lflow_input, lflow_data->lflow_table)) { - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool +enum engine_input_handler_result lflow_multicast_igmp_handler(struct engine_node *node, void *data) { struct multicast_igmp_data *mcast_igmp_data = @@ -246,7 +242,7 @@ lflow_multicast_igmp_handler(struct engine_node *node, void *data) lflow_input.ovn_internal_version_changed, lflow_input.sbrec_logical_flow_table, lflow_input.sbrec_logical_dp_group_table)) { - return false; + return EN_UNHANDLED; } build_igmp_lflows(&mcast_igmp_data->igmp_groups, @@ -262,14 +258,13 @@ lflow_multicast_igmp_handler(struct engine_node *node, void *data) lflow_input.ovn_internal_version_changed, lflow_input.sbrec_logical_flow_table, lflow_input.sbrec_logical_dp_group_table)) { - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool +enum engine_input_handler_result lflow_group_ecmp_route_change_handler(struct engine_node *node, void *data OVS_UNUSED) { @@ -278,7 +273,7 @@ lflow_group_ecmp_route_change_handler(struct engine_node *node, /* If we do not have tracked data we need to recompute. */ if (!group_ecmp_route_data->tracked) { - return false; + return EN_UNHANDLED; } const struct engine_context *eng_ctx = engine_get_context(); @@ -305,7 +300,7 @@ lflow_group_ecmp_route_change_handler(struct engine_node *node, lflow_input.sbrec_logical_flow_table, lflow_input.sbrec_logical_dp_group_table); if (!handled) { - return false; + return EN_UNHANDLED; } } @@ -327,12 +322,11 @@ lflow_group_ecmp_route_change_handler(struct engine_node *node, lflow_input.sbrec_logical_flow_table, lflow_input.sbrec_logical_dp_group_table); if (!handled) { - return false; + return EN_UNHANDLED; } } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } void *en_lflow_init(struct engine_node *node OVS_UNUSED, diff --git a/northd/en-lflow.h b/northd/en-lflow.h index 9c54cbbf5..d3c96c027 100644 --- a/northd/en-lflow.h +++ b/northd/en-lflow.h @@ -18,12 +18,17 @@ struct lflow_data { enum engine_node_state en_lflow_run(struct engine_node *node, void *data); void *en_lflow_init(struct engine_node *node, struct engine_arg *arg); void en_lflow_cleanup(void *data); -bool lflow_northd_handler(struct engine_node *, void *data); -bool lflow_port_group_handler(struct engine_node *, void *data); -bool lflow_lr_stateful_handler(struct engine_node *, void *data); -bool lflow_ls_stateful_handler(struct engine_node *node, void *data); -bool lflow_multicast_igmp_handler(struct engine_node *node, void *data); -bool lflow_group_ecmp_route_change_handler(struct engine_node *node, - void *data); +enum engine_input_handler_result lflow_northd_handler(struct engine_node *, + void *data); +enum engine_input_handler_result lflow_port_group_handler(struct engine_node *, + void *data); +enum engine_input_handler_result +lflow_lr_stateful_handler(struct engine_node *, void *data); +enum engine_input_handler_result +lflow_ls_stateful_handler(struct engine_node *node, void *data); +enum engine_input_handler_result +lflow_multicast_igmp_handler(struct engine_node *node, void *data); +enum engine_input_handler_result +lflow_group_ecmp_route_change_handler(struct engine_node *node, void *data); #endif /* EN_LFLOW_H */ diff --git a/northd/en-lr-nat.c b/northd/en-lr-nat.c index 916a90c8f..0119c1913 100644 --- a/northd/en-lr-nat.c +++ b/northd/en-lr-nat.c @@ -117,16 +117,16 @@ en_lr_nat_run(struct engine_node *node, void *data_) } /* Handler functions. */ -bool +enum engine_input_handler_result lr_nat_northd_handler(struct engine_node *node, void *data_) { struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - return false; + return EN_UNHANDLED; } if (!northd_has_lr_nats_in_tracked_data(&northd_data->trk_data)) { - return true; + return EN_HANDLED_UNCHANGED; } struct ed_type_lr_nat_data *data = data_; @@ -145,10 +145,10 @@ lr_nat_northd_handler(struct engine_node *node, void *data_) } if (lr_nat_has_tracked_data(&data->trk_data)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } /* static functions. */ diff --git a/northd/en-lr-nat.h b/northd/en-lr-nat.h index 7de22f471..df4eb0786 100644 --- a/northd/en-lr-nat.h +++ b/northd/en-lr-nat.h @@ -120,8 +120,8 @@ void en_lr_nat_cleanup(void *data); void en_lr_nat_clear_tracked_data(void *data); enum engine_node_state en_lr_nat_run(struct engine_node *, void *data); -bool lr_nat_logical_router_handler(struct engine_node *, void *data); -bool lr_nat_northd_handler(struct engine_node *, void *data); +enum engine_input_handler_result lr_nat_northd_handler(struct engine_node *, + void *data); static inline bool nat_entry_is_v6(const struct ovn_nat *nat_entry) diff --git a/northd/en-lr-stateful.c b/northd/en-lr-stateful.c index 15c8f83c2..889f80b28 100644 --- a/northd/en-lr-stateful.c +++ b/northd/en-lr-stateful.c @@ -129,12 +129,12 @@ en_lr_stateful_run(struct engine_node *node, void *data_) return EN_UPDATED; } -bool +enum engine_input_handler_result lr_stateful_northd_handler(struct engine_node *node, void *data OVS_UNUSED) { struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - return false; + return EN_UNHANDLED; } /* This node uses the below data from the en_northd engine node. @@ -161,15 +161,15 @@ lr_stateful_northd_handler(struct engine_node *node, void *data OVS_UNUSED) * and (3) if any. * * */ - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result lr_stateful_lb_data_handler(struct engine_node *node, void *data_) { struct ed_type_lb_data *lb_data = engine_get_input_data("lb_data", node); if (!lb_data->tracked) { - return false; + return EN_UNHANDLED; } struct lr_stateful_input input_data = lr_stateful_get_input_data(node); @@ -319,20 +319,20 @@ lr_stateful_lb_data_handler(struct engine_node *node, void *data_) lr_stateful_rec->has_lb_vip = od_has_lb_vip(od); } - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result lr_stateful_lr_nat_handler(struct engine_node *node, void *data_) { struct ed_type_lr_nat_data *lr_nat_data = engine_get_input_data("lr_nat", node); if (!lr_nat_has_tracked_data(&lr_nat_data->trk_data)) { - return false; + return EN_UNHANDLED; } struct lr_stateful_input input_data = lr_stateful_get_input_data(node); @@ -358,10 +358,10 @@ lr_stateful_lr_nat_handler(struct engine_node *node, void *data_) } if (lr_stateful_has_tracked_data(&data->trk_data)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } const struct lr_stateful_record * diff --git a/northd/en-lr-stateful.h b/northd/en-lr-stateful.h index 1a86f311d..2864ebc73 100644 --- a/northd/en-lr-stateful.h +++ b/northd/en-lr-stateful.h @@ -125,9 +125,12 @@ void en_lr_stateful_cleanup(void *data); void en_lr_stateful_clear_tracked_data(void *data); enum engine_node_state en_lr_stateful_run(struct engine_node *, void *data); -bool lr_stateful_northd_handler(struct engine_node *, void *data); -bool lr_stateful_lr_nat_handler(struct engine_node *, void *data); -bool lr_stateful_lb_data_handler(struct engine_node *, void *data); +enum engine_input_handler_result +lr_stateful_northd_handler(struct engine_node *, void *data); +enum engine_input_handler_result +lr_stateful_lr_nat_handler(struct engine_node *, void *data); +enum engine_input_handler_result +lr_stateful_lb_data_handler(struct engine_node *, void *data); const struct lr_stateful_record *lr_stateful_table_find_by_index( const struct lr_stateful_table *, size_t od_index); diff --git a/northd/en-ls-stateful.c b/northd/en-ls-stateful.c index c2965a88c..b713b5bce 100644 --- a/northd/en-ls-stateful.c +++ b/northd/en-ls-stateful.c @@ -130,17 +130,17 @@ en_ls_stateful_run(struct engine_node *node, void *data_) } /* Handler functions. */ -bool +enum engine_input_handler_result ls_stateful_northd_handler(struct engine_node *node, void *data_) { struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - return false; + return EN_UNHANDLED; } if (!northd_has_ls_lbs_in_tracked_data(&northd_data->trk_data) && !northd_has_ls_acls_in_tracked_data(&northd_data->trk_data)) { - return true; + return EN_HANDLED_UNCHANGED; } struct northd_tracked_data *nd_changes = &northd_data->trk_data; @@ -170,23 +170,23 @@ ls_stateful_northd_handler(struct engine_node *node, void *data_) hmapx_add(&data->trk_data.crupdated, ls_stateful_rec); } + hmapx_destroy(&changed_stateful_od); + if (ls_stateful_has_tracked_data(&data->trk_data)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - hmapx_destroy(&changed_stateful_od); - - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result ls_stateful_port_group_handler(struct engine_node *node, void *data_) { struct port_group_data *pg_data = engine_get_input_data("port_group", node); if (pg_data->ls_port_groups_sets_changed) { - return false; + return EN_UNHANDLED; } /* port_group engine node doesn't provide the tracking data yet. @@ -230,9 +230,9 @@ ls_stateful_port_group_handler(struct engine_node *node, void *data_) } if (ls_stateful_has_tracked_data(&data->trk_data)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } /* static functions. */ diff --git a/northd/en-ls-stateful.h b/northd/en-ls-stateful.h index 275fa05b1..1d98b3695 100644 --- a/northd/en-ls-stateful.h +++ b/northd/en-ls-stateful.h @@ -105,8 +105,10 @@ void en_ls_stateful_cleanup(void *data); void en_ls_stateful_clear_tracked_data(void *data); enum engine_node_state en_ls_stateful_run(struct engine_node *, void *data); -bool ls_stateful_northd_handler(struct engine_node *, void *data); -bool ls_stateful_port_group_handler(struct engine_node *, void *data); +enum engine_input_handler_result +ls_stateful_northd_handler(struct engine_node *, void *data); +enum engine_input_handler_result +ls_stateful_port_group_handler(struct engine_node *, void *data); const struct ls_stateful_record *ls_stateful_table_find( const struct ls_stateful_table *, const struct nbrec_logical_switch *); diff --git a/northd/en-multicast.c b/northd/en-multicast.c index 0522fcd9a..41ae84eac 100644 --- a/northd/en-multicast.c +++ b/northd/en-multicast.c @@ -145,12 +145,12 @@ en_multicast_igmp_run(struct engine_node *node, void *data_) return EN_UPDATED; } -bool +enum engine_input_handler_result multicast_igmp_northd_handler(struct engine_node *node, void *data OVS_UNUSED) { struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - return false; + return EN_UNHANDLED; } /* This node uses the below data from the en_northd engine node. @@ -171,7 +171,7 @@ multicast_igmp_northd_handler(struct engine_node *node, void *data OVS_UNUSED) * need to revisit this handler. * * */ - return true; + return EN_HANDLED_UNCHANGED; } void diff --git a/northd/en-multicast.h b/northd/en-multicast.h index 9a0ebf533..21ee8d5b6 100644 --- a/northd/en-multicast.h +++ b/northd/en-multicast.h @@ -85,7 +85,8 @@ struct ovn_mcast_sw_stats { void *en_multicast_igmp_init(struct engine_node *,struct engine_arg *); enum engine_node_state en_multicast_igmp_run(struct engine_node *, void *); -bool multicast_igmp_northd_handler(struct engine_node *, void *); +enum engine_input_handler_result +multicast_igmp_northd_handler(struct engine_node *, void *); void en_multicast_igmp_cleanup(void *); struct sbrec_multicast_group *create_sb_multicast_group( struct ovsdb_idl_txn *ovnsb_txn, const struct sbrec_datapath_binding *, diff --git a/northd/en-northd-output.c b/northd/en-northd-output.c index 879d16e49..b492a771c 100644 --- a/northd/en-northd-output.c +++ b/northd/en-northd-output.c @@ -43,57 +43,51 @@ en_northd_output_cleanup(void *data OVS_UNUSED) } -bool -northd_output_sync_to_sb_handler(struct engine_node *node, +enum engine_input_handler_result +northd_output_sync_to_sb_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool -northd_output_lflow_handler(struct engine_node *node, void *data OVS_UNUSED) +enum engine_input_handler_result +northd_output_lflow_handler(struct engine_node *node OVS_UNUSED, + void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool -northd_output_mac_binding_aging_handler(struct engine_node *node, +enum engine_input_handler_result +northd_output_mac_binding_aging_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool -northd_output_fdb_aging_handler(struct engine_node *node, +enum engine_input_handler_result +northd_output_fdb_aging_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool -northd_output_ecmp_nexthop_handler(struct engine_node *node, +enum engine_input_handler_result +northd_output_ecmp_nexthop_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool -northd_output_acl_id_handler(struct engine_node *node, +enum engine_input_handler_result +northd_output_acl_id_handler(struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } -bool -northd_output_advertised_route_sync_handler(struct engine_node *node, - void *data OVS_UNUSED) +enum engine_input_handler_result +northd_output_advertised_route_sync_handler( + struct engine_node *node OVS_UNUSED, void *data OVS_UNUSED) { - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } diff --git a/northd/en-northd-output.h b/northd/en-northd-output.h index 399ff8125..b7053e60c 100644 --- a/northd/en-northd-output.h +++ b/northd/en-northd-output.h @@ -9,19 +9,24 @@ enum engine_node_state en_northd_output_run(struct engine_node *, void *data OVS_UNUSED); void en_northd_output_cleanup(void *data); -bool northd_output_sync_to_sb_handler(struct engine_node *node, - void *data OVS_UNUSED); -bool northd_output_lflow_handler(struct engine_node *node, +enum engine_input_handler_result +northd_output_sync_to_sb_handler(struct engine_node *node, void *data OVS_UNUSED); -bool northd_output_mac_binding_aging_handler(struct engine_node *node, - void *data OVS_UNUSED); -bool northd_output_fdb_aging_handler(struct engine_node *node, - void *data OVS_UNUSED); -bool northd_output_ecmp_nexthop_handler(struct engine_node *node, +enum engine_input_handler_result +northd_output_lflow_handler(struct engine_node *node, void *data OVS_UNUSED); +enum engine_input_handler_result +northd_output_mac_binding_aging_handler(struct engine_node *node, void *data OVS_UNUSED); -bool northd_output_acl_id_handler(struct engine_node *node, - void *data OVS_UNUSED); -bool northd_output_advertised_route_sync_handler(struct engine_node *node, - void *data OVS_UNUSED); +enum engine_input_handler_result +northd_output_fdb_aging_handler(struct engine_node *node, + void *data OVS_UNUSED); +enum engine_input_handler_result +northd_output_ecmp_nexthop_handler(struct engine_node *node, + void *data OVS_UNUSED); +enum engine_input_handler_result +northd_output_acl_id_handler(struct engine_node *node, void *data OVS_UNUSED); +enum engine_input_handler_result +northd_output_advertised_route_sync_handler(struct engine_node *node, + void *data OVS_UNUSED); #endif diff --git a/northd/en-northd.c b/northd/en-northd.c index 82db29427..f3c61990a 100644 --- a/northd/en-northd.c +++ b/northd/en-northd.c @@ -132,7 +132,7 @@ en_northd_run(struct engine_node *node, void *data) return EN_UPDATED; } -bool +enum engine_input_handler_result northd_nb_logical_switch_handler(struct engine_node *node, void *data) { @@ -144,17 +144,17 @@ northd_nb_logical_switch_handler(struct engine_node *node, northd_get_input_data(node, &input_data); if (!northd_handle_ls_changes(eng_ctx->ovnsb_idl_txn, &input_data, nd)) { - return false; + return EN_UNHANDLED; } if (northd_has_tracked_data(&nd->trk_data)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result northd_sb_port_binding_handler(struct engine_node *node, void *data) { @@ -166,13 +166,13 @@ northd_sb_port_binding_handler(struct engine_node *node, if (!northd_handle_sb_port_binding_changes( input_data.sbrec_port_binding_table, &nd->ls_ports, &nd->lr_ports)) { - return false; + return EN_UNHANDLED; } - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result northd_nb_logical_router_handler(struct engine_node *node, void *data) { @@ -182,23 +182,23 @@ northd_nb_logical_router_handler(struct engine_node *node, northd_get_input_data(node, &input_data); if (!northd_handle_lr_changes(&input_data, nd)) { - return false; + return EN_UNHANDLED; } if (northd_has_lr_nats_in_tracked_data(&nd->trk_data)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result northd_lb_data_handler(struct engine_node *node, void *data) { struct ed_type_lb_data *lb_data = engine_get_input_data("lb_data", node); if (!lb_data->tracked) { - return false; + return EN_UNHANDLED; } struct northd_data *nd = data; @@ -208,17 +208,17 @@ northd_lb_data_handler(struct engine_node *node, void *data) &nd->lb_datapaths_map, &nd->lb_group_datapaths_map, &nd->trk_data)) { - return false; + return EN_UNHANDLED; } if (northd_has_lbs_in_tracked_data(&nd->trk_data)) { - engine_set_node_state(node, EN_UPDATED); + return EN_HANDLED_UPDATED; } - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result northd_global_config_handler(struct engine_node *node, void *data OVS_UNUSED) { struct ed_type_global_config *global_config = @@ -226,19 +226,19 @@ northd_global_config_handler(struct engine_node *node, void *data OVS_UNUSED) if (!global_config->tracked || global_config->tracked_data.nb_options_changed) { - return false; + return EN_UNHANDLED; } - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result route_policies_northd_change_handler(struct engine_node *node, void *data OVS_UNUSED) { struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - return false; + return EN_UNHANDLED; } /* This node uses the below data from the en_northd engine node. @@ -258,7 +258,7 @@ route_policies_northd_change_handler(struct engine_node *node, * Note: When we add I-P to handle route policies changes, we need * to revisit this handler. */ - return true; + return EN_HANDLED_UNCHANGED; } enum engine_node_state @@ -283,13 +283,13 @@ en_route_policies_run(struct engine_node *node, void *data) return EN_UPDATED; } -bool +enum engine_input_handler_result routes_northd_change_handler(struct engine_node *node, void *data OVS_UNUSED) { struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - return false; + return EN_UNHANDLED; } /* This node uses the below data from the en_northd engine node. @@ -309,7 +309,7 @@ routes_northd_change_handler(struct engine_node *node, * Note: When we add I-P to handle static routes changes, we need * to revisit this handler. */ - return true; + return EN_HANDLED_UNCHANGED; } enum engine_node_state @@ -357,12 +357,12 @@ en_bfd_run(struct engine_node *node, void *data) return EN_UPDATED; } -bool +enum engine_input_handler_result bfd_sync_northd_change_handler(struct engine_node *node, void *data OVS_UNUSED) { struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - return false; + return EN_UNHANDLED; } /* This node uses the below data from the en_northd engine node. @@ -374,7 +374,7 @@ bfd_sync_northd_change_handler(struct engine_node *node, void *data OVS_UNUSED) * Note: When we add I-P to the created/deleted logical router ports, * we need to revisit this handler. */ - return true; + return EN_HANDLED_UNCHANGED; } enum engine_node_state @@ -464,7 +464,7 @@ en_northd_clear_tracked_data(void *data_) destroy_northd_data_tracked_changes(data); } -bool +enum engine_input_handler_result northd_sb_fdb_change_handler(struct engine_node *node, void *data) { struct northd_data *nd = data; @@ -497,7 +497,7 @@ northd_sb_fdb_change_handler(struct engine_node *node, void *data) sbrec_fdb_delete(fdb_prev_del); } - return true; + return EN_HANDLED_UNCHANGED; } void diff --git a/northd/en-northd.h b/northd/en-northd.h index ad2ca671e..b19b73270 100644 --- a/northd/en-northd.h +++ b/northd/en-northd.h @@ -15,24 +15,31 @@ void *en_northd_init(struct engine_node *node OVS_UNUSED, struct engine_arg *arg); void en_northd_cleanup(void *data); void en_northd_clear_tracked_data(void *data); -bool northd_global_config_handler(struct engine_node *, void *data OVS_UNUSED); -bool northd_nb_logical_switch_handler(struct engine_node *, void *data); -bool northd_nb_logical_router_handler(struct engine_node *, void *data); -bool northd_sb_port_binding_handler(struct engine_node *, void *data); -bool northd_lb_data_handler(struct engine_node *, void *data); -bool northd_sb_fdb_change_handler(struct engine_node *node, void *data); +enum engine_input_handler_result +northd_global_config_handler(struct engine_node *, void *data OVS_UNUSED); +enum engine_input_handler_result +northd_nb_logical_switch_handler(struct engine_node *, void *data); +enum engine_input_handler_result +northd_nb_logical_router_handler(struct engine_node *, void *data); +enum engine_input_handler_result +northd_sb_port_binding_handler(struct engine_node *, void *data); +enum engine_input_handler_result northd_lb_data_handler(struct engine_node *, + void *data); +enum engine_input_handler_result +northd_sb_fdb_change_handler(struct engine_node *node, void *data); void *en_routes_init(struct engine_node *node OVS_UNUSED, struct engine_arg *arg OVS_UNUSED); void en_route_policies_cleanup(void *data); -bool route_policies_northd_change_handler(struct engine_node *node, - void *data OVS_UNUSED); +enum engine_input_handler_result +route_policies_northd_change_handler(struct engine_node *node, + void *data OVS_UNUSED); enum engine_node_state en_route_policies_run(struct engine_node *node, void *data); void *en_route_policies_init(struct engine_node *node OVS_UNUSED, struct engine_arg *arg OVS_UNUSED); void en_routes_cleanup(void *data); -bool routes_northd_change_handler(struct engine_node *node, - void *data OVS_UNUSED); +enum engine_input_handler_result +routes_northd_change_handler(struct engine_node *node, void *data OVS_UNUSED); enum engine_node_state en_routes_run(struct engine_node *node, void *data); void *en_bfd_init(struct engine_node *node OVS_UNUSED, struct engine_arg *arg OVS_UNUSED); @@ -40,8 +47,9 @@ void en_bfd_cleanup(void *data); enum engine_node_state en_bfd_run(struct engine_node *node, void *data); void *en_bfd_sync_init(struct engine_node *node OVS_UNUSED, struct engine_arg *arg OVS_UNUSED); -bool bfd_sync_northd_change_handler(struct engine_node *node, - void *data OVS_UNUSED); +enum engine_input_handler_result +bfd_sync_northd_change_handler(struct engine_node *node, + void *data OVS_UNUSED); enum engine_node_state en_bfd_sync_run(struct engine_node *node, void *data); void en_bfd_sync_cleanup(void *data OVS_UNUSED); diff --git a/northd/en-port-group.c b/northd/en-port-group.c index 45dd37b2c..4fc1a4f24 100644 --- a/northd/en-port-group.c +++ b/northd/en-port-group.c @@ -508,7 +508,7 @@ en_port_group_run(struct engine_node *node, void *data_) return EN_UPDATED; } -bool +enum engine_input_handler_result port_group_nb_port_group_handler(struct engine_node *node, void *data_) { struct port_group_input input_data = port_group_get_input_data(node); @@ -525,7 +525,7 @@ port_group_nb_port_group_handler(struct engine_node *node, void *data_) NBREC_PORT_GROUP_TABLE_FOR_EACH_TRACKED (nb_pg, nb_pg_table) { if (nbrec_port_group_is_new(nb_pg) || nbrec_port_group_is_deleted(nb_pg)) { - return false; + return EN_UNHANDLED; } } @@ -579,9 +579,8 @@ port_group_nb_port_group_handler(struct engine_node *node, void *data_) } data->ls_port_groups_sets_changed = !success; - engine_set_node_state(node, EN_UPDATED); hmapx_destroy(&updated_ls_port_groups); - return success; + return success ? EN_HANDLED_UPDATED : EN_UNHANDLED; } static void diff --git a/northd/en-port-group.h b/northd/en-port-group.h index 5991fec15..8dcc950da 100644 --- a/northd/en-port-group.h +++ b/northd/en-port-group.h @@ -112,6 +112,7 @@ void en_port_group_cleanup(void *data); void en_port_group_clear_tracked_data(void *data); enum engine_node_state en_port_group_run(struct engine_node *, void *data); -bool port_group_nb_port_group_handler(struct engine_node *, void *data); +enum engine_input_handler_result +port_group_nb_port_group_handler(struct engine_node *, void *data); #endif /* EN_PORT_GROUP_H */ diff --git a/northd/en-sync-from-sb.c b/northd/en-sync-from-sb.c index 3c39d001e..b8aba7e2f 100644 --- a/northd/en-sync-from-sb.c +++ b/northd/en-sync-from-sb.c @@ -62,7 +62,7 @@ en_sync_from_sb_run(struct engine_node *node, void *data OVS_UNUSED) return EN_UNCHANGED; } -bool +enum engine_input_handler_result sync_from_sb_northd_handler(struct engine_node *node, void *data OVS_UNUSED) { @@ -74,9 +74,9 @@ sync_from_sb_northd_handler(struct engine_node *node, * cares about is the "up" column of LSP, which is considered * write-only to this node, so it is safe to ignore the change. (The * real change matters to this node is always from the SB DB.) */ - return true; + return EN_HANDLED_UNCHANGED; } - return false; + return EN_UNHANDLED; } void diff --git a/northd/en-sync-from-sb.h b/northd/en-sync-from-sb.h index 78824ac67..0ad07853a 100644 --- a/northd/en-sync-from-sb.h +++ b/northd/en-sync-from-sb.h @@ -6,6 +6,7 @@ void *en_sync_from_sb_init(struct engine_node *, struct engine_arg *); enum engine_node_state en_sync_from_sb_run(struct engine_node *, void *data); void en_sync_from_sb_cleanup(void *data); -bool sync_from_sb_northd_handler(struct engine_node *, void *data OVS_UNUSED); +enum engine_input_handler_result +sync_from_sb_northd_handler(struct engine_node *, void *data OVS_UNUSED); #endif /* end of EN_SYNC_FROM_SB_H */ diff --git a/northd/en-sync-sb.c b/northd/en-sync-sb.c index 38131dfc3..807f34645 100644 --- a/northd/en-sync-sb.c +++ b/northd/en-sync-sb.c @@ -115,7 +115,7 @@ en_sync_to_sb_addr_set_cleanup(void *data OVS_UNUSED) } -bool +enum engine_input_handler_result sync_to_sb_addr_set_nb_address_set_handler(struct engine_node *node, void *data OVS_UNUSED) { @@ -129,7 +129,7 @@ sync_to_sb_addr_set_nb_address_set_handler(struct engine_node *node, nb_address_set_table) { if (nbrec_address_set_is_new(nb_addr_set) || nbrec_address_set_is_deleted(nb_addr_set)) { - return false; + return EN_UNHANDLED; } } @@ -144,7 +144,7 @@ sync_to_sb_addr_set_nb_address_set_handler(struct engine_node *node, sb_address_set_lookup_by_name(sbrec_address_set_by_name, nb_addr_set->name); if (!sb_addr_set) { - return false; + return EN_UNHANDLED; } struct sorted_array addrs = sorted_array_from_dbrec(nb_addr_set, addresses); @@ -152,10 +152,10 @@ sync_to_sb_addr_set_nb_address_set_handler(struct engine_node *node, sorted_array_destroy(&addrs); } - return true; + return EN_HANDLED_UNCHANGED; } -bool +enum engine_input_handler_result sync_to_sb_addr_set_nb_port_group_handler(struct engine_node *node, void *data OVS_UNUSED) { @@ -165,7 +165,7 @@ sync_to_sb_addr_set_nb_port_group_handler(struct engine_node *node, NBREC_PORT_GROUP_TABLE_FOR_EACH_TRACKED (nb_pg, nb_port_group_table) { if (nbrec_port_group_is_new(nb_pg) || nbrec_port_group_is_deleted(nb_pg)) { - return false; + return EN_UNHANDLED; } } @@ -180,7 +180,7 @@ sync_to_sb_addr_set_nb_port_group_handler(struct engine_node *node, ipv4_addrs_name); if (!sb_addr_set_v4) { free(ipv4_addrs_name); - return false; + return EN_UNHANDLED; } char *ipv6_addrs_name = xasprintf("%s_ip6", nb_pg->name); const struct sbrec_address_set *sb_addr_set_v6 = @@ -189,7 +189,7 @@ sync_to_sb_addr_set_nb_port_group_handler(struct engine_node *node, if (!sb_addr_set_v6) { free(ipv4_addrs_name); free(ipv6_addrs_name); - return false; + return EN_UNHANDLED; } struct svec ipv4_addrs = SVEC_EMPTY_INITIALIZER; @@ -212,7 +212,7 @@ sync_to_sb_addr_set_nb_port_group_handler(struct engine_node *node, free(ipv6_addrs_name); } - return true; + return EN_HANDLED_UNCHANGED; } /* sync_to_sb_lb engine node functions. @@ -310,18 +310,18 @@ en_sync_to_sb_lb_cleanup(void *data_) sb_lb_table_destroy(&data->sb_lbs); } -bool +enum engine_input_handler_result sync_to_sb_lb_northd_handler(struct engine_node *node, void *data_) { struct northd_data *nd = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&nd->trk_data)) { /* Return false if no tracking data. */ - return false; + return EN_UNHANDLED; } if (!northd_has_lbs_in_tracked_data(&nd->trk_data)) { - return true; + return EN_HANDLED_UNCHANGED; } const struct engine_context *eng_ctx = engine_get_context(); @@ -337,11 +337,10 @@ sync_to_sb_lb_northd_handler(struct engine_node *node, void *data_) sb_dpgrp_table, &nd->trk_data.trk_lbs, &nd->ls_datapaths, &nd->lr_datapaths, &global_config->features)) { - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } /* sync_to_sb_pb engine node functions. @@ -379,19 +378,19 @@ en_sync_to_sb_pb_cleanup(void *data OVS_UNUSED) } -bool +enum engine_input_handler_result sync_to_sb_pb_northd_handler(struct engine_node *node, void *data OVS_UNUSED) { const struct engine_context *eng_ctx = engine_get_context(); if (!eng_ctx->ovnsb_idl_txn) { - return false; + return EN_UNHANDLED; } struct northd_data *nd = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&nd->trk_data) || northd_has_lbs_in_tracked_data(&nd->trk_data)) { /* Return false if no tracking data or if lbs changed. */ - return false; + return EN_UNHANDLED; } struct ed_type_lr_stateful *lr_stateful_data = @@ -399,11 +398,10 @@ sync_to_sb_pb_northd_handler(struct engine_node *node, void *data OVS_UNUSED) if (!sync_pbs_for_northd_changed_ovn_ports(&nd->trk_data.trk_lsps, &lr_stateful_data->table)) { - return false; + return EN_UNHANDLED; } - engine_set_node_state(node, EN_UPDATED); - return true; + return EN_HANDLED_UPDATED; } /* static functions. */ diff --git a/northd/en-sync-sb.h b/northd/en-sync-sb.h index 6cfac7f86..32e7577f5 100644 --- a/northd/en-sync-sb.h +++ b/northd/en-sync-sb.h @@ -12,20 +12,22 @@ enum engine_node_state en_sync_to_sb_addr_set_run(struct engine_node *, void *data); void en_sync_to_sb_addr_set_cleanup(void *data); -bool sync_to_sb_addr_set_nb_address_set_handler(struct engine_node *, - void *data); -bool sync_to_sb_addr_set_nb_port_group_handler(struct engine_node *, - void *data); +enum engine_input_handler_result +sync_to_sb_addr_set_nb_address_set_handler(struct engine_node *, void *data); +enum engine_input_handler_result +sync_to_sb_addr_set_nb_port_group_handler(struct engine_node *, void *data); void *en_sync_to_sb_lb_init(struct engine_node *, struct engine_arg *); enum engine_node_state en_sync_to_sb_lb_run(struct engine_node *, void *data); void en_sync_to_sb_lb_cleanup(void *data); -bool sync_to_sb_lb_northd_handler(struct engine_node *, void *data OVS_UNUSED); +enum engine_input_handler_result +sync_to_sb_lb_northd_handler(struct engine_node *, void *data OVS_UNUSED); void *en_sync_to_sb_pb_init(struct engine_node *, struct engine_arg *); enum engine_node_state en_sync_to_sb_pb_run(struct engine_node *, void *data); void en_sync_to_sb_pb_cleanup(void *data); -bool sync_to_sb_pb_northd_handler(struct engine_node *, void *data OVS_UNUSED); +enum engine_input_handler_result +sync_to_sb_pb_northd_handler(struct engine_node *, void *data OVS_UNUSED); #endif /* end of EN_SYNC_SB_H */ -- 2.47.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev