updates the lflows for newly created logical routers avoiding the need for a full database recompute.
This is built on Mark Michelson's patch series located here https://patchwork.ozlabs.org/project/ovn/list/?series=465828 this is required because the datapath refactor was required in order to accomplish incremental processing of the logical routers also built with the first two patches of this series by Lorenzo Bianconi located https://patchwork.ozlabs.org/project/ovn/list/?series=466579. He brought in some changes required to dynamically allocate the sizes of the datapaths array. Reported-by: Dumitru Ceara <[email protected]> Reported-at: https://issues.redhat.com/browse/FDP-757 Signed-off-by: Jacob Tanenbaum <[email protected]> diff --git a/northd/en-lflow.c b/northd/en-lflow.c index 719ccb1ae..4fcf3234b 100644 --- a/northd/en-lflow.c +++ b/northd/en-lflow.c @@ -132,9 +132,6 @@ lflow_northd_handler(struct engine_node *node, { struct northd_data *northd_data = engine_get_input_data("northd", node); if (!northd_has_tracked_data(&northd_data->trk_data)) { - } - if (!northd_has_tracked_data(&northd_data->trk_data) - || northd_has_lr_new_in_tracked_data(&northd_data->trk_data)) { return EN_UNHANDLED; } @@ -144,6 +141,13 @@ lflow_northd_handler(struct engine_node *node, struct lflow_input lflow_input; lflow_get_input_data(node, &lflow_input); + if (!lflow_handle_northd_lr_creation(eng_ctx->ovnsb_idl_txn, + &northd_data->trk_data.trk_new_lrs, + &lflow_input, + lflow_data->lflow_table)) { + return EN_UNHANDLED; + } + if (!lflow_handle_northd_port_changes(eng_ctx->ovnsb_idl_txn, &northd_data->trk_data.trk_lsps, &lflow_input, diff --git a/northd/northd.c b/northd/northd.c index 6d7b37238..3feebd73a 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -509,6 +509,9 @@ ovn_datapath_create(struct hmap *datapaths, const struct uuid *key, od->lb_with_stateless_mode = false; od->tunnel_key = sb->tunnel_key; init_mcast_info_for_datapath(od); + if (nbr) { + od->router_lflows = lflow_ref_create(); + } return od; } @@ -538,6 +541,9 @@ ovn_datapath_destroy(struct hmap *datapaths, struct ovn_datapath *od) destroy_mcast_info_for_datapath(od); destroy_ports_for_datapath(od); sset_destroy(&od->router_ips); + if (od->nbr) { + lflow_ref_destroy(od->router_lflows); + } free(od); } } @@ -13969,16 +13975,16 @@ build_default_route_flows_for_lrouter( struct simap *route_tables) { ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_IP_ROUTING_ECMP, - NULL); + od->router_lflows); ovn_lflow_add_default_drop(lflows, od, S_ROUTER_IN_IP_ROUTING, - NULL); + od->router_lflows); ovn_lflow_add(lflows, od, S_ROUTER_IN_IP_ROUTING_ECMP, 150, REG_ECMP_GROUP_ID" == 0", "next;", - NULL); + od->router_lflows); for (int i = 0; i < od->nbr->n_ports; i++) { build_route_table_lflow(od, lflows, od->nbr->ports[i], - route_tables, NULL); + route_tables, od->router_lflows); } } @@ -17743,40 +17749,48 @@ build_lswitch_and_lrouter_iterate_by_lr(struct ovn_datapath *od, struct lswitch_flow_build_info *lsi) { ovs_assert(od->nbr); - build_adm_ctrl_flows_for_lrouter(od, lsi->lflows, NULL); + build_adm_ctrl_flows_for_lrouter(od, lsi->lflows, od->router_lflows); build_neigh_learning_flows_for_lrouter(od, lsi->lflows, &lsi->match, &lsi->actions, - lsi->meter_groups, NULL); - build_ND_RA_flows_for_lrouter(od, lsi->lflows, NULL); - build_ip_routing_pre_flows_for_lrouter(od, lsi->lflows, NULL); + lsi->meter_groups, + od->router_lflows); + build_ND_RA_flows_for_lrouter(od, lsi->lflows, od->router_lflows); + build_ip_routing_pre_flows_for_lrouter(od, lsi->lflows, od->router_lflows); build_route_flows_for_lrouter(od, lsi->lflows, lsi->route_data, lsi->route_tables, lsi->bfd_ports); - build_mcast_lookup_flows_for_lrouter(od, lsi->lflows, &lsi->match, NULL); + build_mcast_lookup_flows_for_lrouter(od, lsi->lflows, &lsi->match, + od->router_lflows); build_ingress_policy_flows_for_lrouter(od, lsi->lflows, lsi->lr_ports, - lsi->route_policies, NULL); - build_arp_resolve_flows_for_lrouter(od, lsi->lflows, NULL); + lsi->route_policies, + od->router_lflows); + build_arp_resolve_flows_for_lrouter(od, lsi->lflows, od->router_lflows); build_check_pkt_len_flows_for_lrouter(od, lsi->lflows, lsi->lr_ports, &lsi->match, &lsi->actions, - lsi->meter_groups, NULL, + lsi->meter_groups, + od->router_lflows, lsi->features); build_gateway_redirect_flows_for_lrouter(od, lsi->lflows, &lsi->match, - &lsi->actions, NULL); + &lsi->actions, od->router_lflows); build_arp_request_flows_for_lrouter(od, lsi->lflows, &lsi->match, &lsi->actions, lsi->meter_groups, - NULL); + od->router_lflows); build_lrouter_network_id_flows(od, lsi->lflows, &lsi->match, - &lsi->actions, NULL); - build_misc_local_traffic_drop_flows_for_lrouter(od, lsi->lflows, NULL); + &lsi->actions, od->router_lflows); + build_misc_local_traffic_drop_flows_for_lrouter(od, lsi->lflows, + od->router_lflows); - build_lr_nat_defrag_and_lb_default_flows(od, lsi->lflows, NULL); - build_lrouter_lb_affinity_default_flows(od, lsi->lflows, NULL); + build_lr_nat_defrag_and_lb_default_flows(od, lsi->lflows, + od->router_lflows); + build_lrouter_lb_affinity_default_flows(od, lsi->lflows, + od->router_lflows); /* Default drop rule in lr_out_delivery stage. See * build_egress_delivery_flows_for_lrouter_port() which adds a rule * for each router port. */ - ovn_lflow_add_default_drop(lsi->lflows, od, S_ROUTER_OUT_DELIVERY, NULL); + ovn_lflow_add_default_drop(lsi->lflows, od, S_ROUTER_OUT_DELIVERY, + od->router_lflows); } /* Helper function to combine all lflow generation which is iterated by logical @@ -18374,6 +18388,44 @@ lflow_reset_northd_refs(struct lflow_input *lflow_input) } } +bool +lflow_handle_northd_lr_creation(struct ovsdb_idl_txn *ovnsb_txn, + struct hmapx *trk_new_lrs, + struct lflow_input *lflow_input, + struct lflow_table *lflows) +{ + bool handled = true; + struct lswitch_flow_build_info lsi = { + .lr_datapaths = lflow_input->lr_datapaths, + .lr_stateful_table = lflow_input->lr_stateful_table, + .lflows =lflows, + .route_data = lflow_input->route_data, + .route_tables = lflow_input->route_tables, + .route_policies = lflow_input->route_policies, + .match = DS_EMPTY_INITIALIZER, + .actions = DS_EMPTY_INITIALIZER, + }; + + struct hmapx_node *hmapx_node; + struct ovn_datapath *od; + HMAPX_FOR_EACH(hmapx_node, trk_new_lrs) { + od = hmapx_node->data; + build_lswitch_and_lrouter_iterate_by_lr(od, &lsi); + handled = lflow_ref_sync_lflows( + od->router_lflows, lflows, ovnsb_txn, lflow_input->ls_datapaths, + lflow_input->lr_datapaths, + lflow_input->ovn_internal_version_changed, + lflow_input->sbrec_logical_flow_table, + lflow_input->sbrec_logical_dp_group_table); + if (!handled) { + break; + } + } + ds_destroy(&lsi.actions); + ds_destroy(&lsi.match); + return handled; +} + bool lflow_handle_northd_port_changes(struct ovsdb_idl_txn *ovnsb_txn, struct tracked_ovn_ports *trk_lsps, diff --git a/northd/northd.h b/northd/northd.h index e9042cd5f..4ecd57e6b 100644 --- a/northd/northd.h +++ b/northd/northd.h @@ -431,6 +431,9 @@ struct ovn_datapath { /* Map of ovn_port objects belonging to this datapath. * This map doesn't include derived ports. */ struct hmap ports; + + /* reference to the router lflows beloning to this datapath */ + struct lflow_ref *router_lflows; }; const struct ovn_datapath *ovn_datapath_find(const struct hmap *datapaths, @@ -874,6 +877,10 @@ void build_route_data_flows_for_lrouter( const struct group_ecmp_datapath *route_node, const struct sset *bfd_ports); +bool lflow_handle_northd_lr_creation(struct ovsdb_idl_txn *ovnsh_txn, + struct hmapx *, + struct lflow_input *, + struct lflow_table *lflows); bool lflow_handle_northd_port_changes(struct ovsdb_idl_txn *ovnsb_txn, struct tracked_ovn_ports *, diff --git a/tests/ovn-northd.at b/tests/ovn-northd.at index 18ac13a92..f1017bd7f 100644 --- a/tests/ovn-northd.at +++ b/tests/ovn-northd.at @@ -12601,7 +12601,7 @@ check_engine_stats lr_nat norecompute compute check_engine_stats lr_stateful norecompute compute check_engine_stats sync_to_sb_pb recompute nocompute check_engine_stats sync_to_sb_lb norecompute compute -check_engine_stats lflow recompute nocompute +check_engine_stats lflow norecompute compute CHECK_NO_CHANGE_AFTER_RECOMPUTE # Adding a logical router port should result in recompute -- 2.50.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
