Similar to skip_snat counterpart, move force_nat gw router where a given lb is installed in a dedicated routine. This is a preliminary patch to reduce load balancer logical flows computation cost.
Signed-off-by: Lorenzo Bianconi <[email protected]> --- northd/northd.c | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/northd/northd.c b/northd/northd.c index d90879eeb..27be74ea7 100644 --- a/northd/northd.c +++ b/northd/northd.c @@ -9987,12 +9987,18 @@ build_lrouter_nat_flows_for_lb(struct ovn_lb_vip *lb_vip, skip_snat_new_action, est_match, skip_snat_est_action, lflows, prio, meter_groups); + char *new_actions = xasprintf("flags.force_snat_for_lb = 1; %s", + ds_cstr(action)); + build_gw_lrouter_nat_flows_for_lb(lb, gw_router_force_snat, + n_gw_router_force_snat, reject, new_match, + new_actions, est_match, + "flags.force_snat_for_lb = 1; next;", + lflows, prio, meter_groups); for (size_t i = 0; i < lb->n_nb_lr; i++) { struct ovn_datapath *od = lb->nb_lr[i]; char *new_match_p = new_match; char *est_match_p = est_match; - char *est_actions = NULL; const char *meter = NULL; if (reject) { @@ -10036,19 +10042,16 @@ build_lrouter_nat_flows_for_lb(struct ovn_lb_vip *lb_vip, &lb->nlb->header_); } } else if (snat_type == FORCE_SNAT) { - char *new_actions = xasprintf("flags.force_snat_for_lb = 1; %s", - ds_cstr(action)); - ovn_lflow_add_with_hint__(lflows, od, S_ROUTER_IN_DNAT, prio, - new_match_p, new_actions, NULL, - meter, &lb->nlb->header_); - free(new_actions); - - est_actions = xasprintf("flags.force_snat_for_lb = 1; " - "next;"); - ovn_lflow_add_with_hint(lflows, od, S_ROUTER_IN_DNAT, prio, - est_match_p, est_actions, - &lb->nlb->header_); - } else { + if (od->n_l3dgw_ports) { + ovn_lflow_add_with_hint__(lflows, od, S_ROUTER_IN_DNAT, prio, + new_match_p, new_actions, NULL, + meter, &lb->nlb->header_); + ovn_lflow_add_with_hint(lflows, od, S_ROUTER_IN_DNAT, prio, + est_match_p, + "flags.force_snat_for_lb = 1; next;", + &lb->nlb->header_); + } + } else if (snat_type == NO_FORCE_SNAT) { ovn_lflow_add_with_hint__(lflows, od, S_ROUTER_IN_DNAT, prio, new_match_p, ds_cstr(action), NULL, meter, &lb->nlb->header_); @@ -10065,7 +10068,7 @@ build_lrouter_nat_flows_for_lb(struct ovn_lb_vip *lb_vip, } if (!od->n_l3dgw_ports || !lb_vip->n_backends) { - goto next; + continue; } char *undnat_match_p = xasprintf( @@ -10079,7 +10082,8 @@ build_lrouter_nat_flows_for_lb(struct ovn_lb_vip *lb_vip, &lb->nlb->header_); } else if (snat_type == FORCE_SNAT) { ovn_lflow_add_with_hint(lflows, od, S_ROUTER_OUT_UNDNAT, 120, - undnat_match_p, est_actions, + undnat_match_p, + "flags.force_snat_for_lb = 1; next;", &lb->nlb->header_); } else { ovn_lflow_add_with_hint( @@ -10088,8 +10092,6 @@ build_lrouter_nat_flows_for_lb(struct ovn_lb_vip *lb_vip, &lb->nlb->header_); } free(undnat_match_p); -next: - free(est_actions); } ds_destroy(&unsnat_match); @@ -10099,6 +10101,7 @@ next: free(skip_snat_est_action); free(est_match); free(new_match); + free(new_actions); free(gw_router_force_snat); free(gw_router_skip_snat); -- 2.35.1 _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
