From: Han Zhou <hzh...@ebay.com> Even if mac_binding is not used for workload provisioning, the mac_binding table update will happen for gateway external ARP processing. This patch ensures ARP events on gateway nodes causing mac-binding changes do not trigger full recomputing on all chassises.
Signed-off-by: Han Zhou <hzh...@ebay.com> --- ovn/controller/lflow.c | 34 ++++++++++++++++++++++++++++++++++ ovn/controller/lflow.h | 5 +++++ ovn/controller/ovn-controller.c | 26 +++++++++++++++++++++++++- 3 files changed, 64 insertions(+), 1 deletion(-) diff --git a/ovn/controller/lflow.c b/ovn/controller/lflow.c index 11dc69d..feb8f8f 100644 --- a/ovn/controller/lflow.c +++ b/ovn/controller/lflow.c @@ -801,6 +801,40 @@ add_neighbor_flows(struct ovsdb_idl_index *sbrec_port_binding_by_name, consider_neighbor_flow(sbrec_port_binding_by_name, b, flow_table); } } + +/* Handles neighbor changes in mac_binding table. */ +void +lflow_handle_changed_neighbors( + struct ovsdb_idl_index *sbrec_port_binding_by_name, + const struct sbrec_mac_binding_table *mac_binding_table, + struct ovn_desired_flow_table *flow_table) +{ + + const struct sbrec_mac_binding *mb; + /* Handle deleted mac_bindings first, to avoid *duplicated flow* problem + * when same flow needs to be added. */ + SBREC_MAC_BINDING_TABLE_FOR_EACH_TRACKED (mb, mac_binding_table) { + /* Remove any flows that should be removed. */ + if (sbrec_mac_binding_is_deleted(mb)) { + VLOG_DBG("handle deleted mac_binding "UUID_FMT, + UUID_ARGS(&mb->header_.uuid)); + ofctrl_remove_flows(flow_table, &mb->header_.uuid); + } + } + SBREC_MAC_BINDING_TABLE_FOR_EACH_TRACKED (mb, mac_binding_table) { + if (!sbrec_mac_binding_is_deleted(mb)) { + if (!sbrec_mac_binding_is_new(mb)) { + VLOG_DBG("handle updated mac_binding "UUID_FMT, + UUID_ARGS(&mb->header_.uuid)); + ofctrl_remove_flows(flow_table, &mb->header_.uuid); + } + VLOG_DBG("handle new mac_binding "UUID_FMT, + UUID_ARGS(&mb->header_.uuid)); + consider_neighbor_flow(sbrec_port_binding_by_name, mb, flow_table); + } + } +} + /* Translates logical flows in the Logical_Flow table in the OVN_SB database * into OpenFlow flows. See ovn-architecture(7) for more information. */ diff --git a/ovn/controller/lflow.h b/ovn/controller/lflow.h index 2b5016e..4e1086e 100644 --- a/ovn/controller/lflow.h +++ b/ovn/controller/lflow.h @@ -174,6 +174,11 @@ bool lflow_handle_changed_ref( uint32_t *conj_id_ofs, bool *changed); +void lflow_handle_changed_neighbors( + struct ovsdb_idl_index *sbrec_port_binding_by_name, + const struct sbrec_mac_binding_table *, + struct ovn_desired_flow_table *); + void lflow_destroy(void); #endif /* ovn/lflow.h */ diff --git a/ovn/controller/ovn-controller.c b/ovn/controller/ovn-controller.c index fa94879..6019016 100644 --- a/ovn/controller/ovn-controller.c +++ b/ovn/controller/ovn-controller.c @@ -1329,6 +1329,29 @@ flow_output_sb_logical_flow_handler(struct engine_node *node) } static bool +flow_output_sb_mac_binding_handler(struct engine_node *node) +{ + struct ovsdb_idl_index *sbrec_port_binding_by_name = + engine_ovsdb_node_get_index( + engine_get_input("SB_port_binding", node), + "name"); + + struct sbrec_mac_binding_table *mac_binding_table = + (struct sbrec_mac_binding_table *)EN_OVSDB_GET( + engine_get_input("SB_mac_binding", node)); + + struct ed_type_flow_output *fo = + (struct ed_type_flow_output *)node->data; + struct ovn_desired_flow_table *flow_table = &fo->flow_table; + + lflow_handle_changed_neighbors(sbrec_port_binding_by_name, + mac_binding_table, flow_table); + + node->changed = true; + return true; +} + +static bool flow_output_sb_port_binding_handler(struct engine_node *node) { struct ed_type_runtime_data *data = @@ -1771,7 +1794,8 @@ main(int argc, char *argv[]) flow_output_sb_multicast_group_handler); engine_add_input(&en_flow_output, &en_sb_port_binding, flow_output_sb_port_binding_handler); - engine_add_input(&en_flow_output, &en_sb_mac_binding, NULL); + engine_add_input(&en_flow_output, &en_sb_mac_binding, + flow_output_sb_mac_binding_handler); engine_add_input(&en_flow_output, &en_sb_logical_flow, flow_output_sb_logical_flow_handler); engine_add_input(&en_flow_output, &en_sb_dhcp_options, NULL); -- 2.1.0 _______________________________________________ dev mailing list d...@openvswitch.org https://mail.openvswitch.org/mailman/listinfo/ovs-dev