On 9/29/26 1:56 AM, JayGue Lee wrote: > From: Jaygue Lee <[email protected]> >
Hi Jaygue Lee, Sorry for the very long delay in reviewing this. > On a router with a distributed gateway port (DGP), load balanced traffic > that leaves the router through the DGP is broken as soon as either > options:lb_force_snat_ip is set on the router or options:skip_snat is set > on the load balancer. There are three problems. > > The reply is never unDNATed. For such routers the unDNAT is done by the > lr_out_undnat flow that build_distr_lrouter_nat_flows_for_lb() adds per > backend, but for the FORCE_SNAT and SKIP_SNAT variants that flow only sets > flags.force_snat_for_lb or flags.skip_snat_for_lb and moves on, without > ct_dnat. With SNAT and DNAT in separate zones, which is the default, no > other flow reverses the DNAT, so the reply reaches the client with the > backend address as source and the client resets the connection. Do the > unDNAT in these variants as well. Stop setting flags.force_snat_for_lb on > the reply: if the reply also leaves through the DGP, as it does when a > backend connects to its own VIP, the flag makes the force SNAT consumer > SNAT the reply too. flags.skip_snat_for_lb is still needed on the reply to > keep it from being matched by a subnet SNAT entry. > > The force SNAT consumer is missing. The lr_out_snat flows that consume > flags.force_snat_for_lb are only built for gateway routers, so on a DGP > router the flag is produced but never consumed and the option is ignored. > Build them for routers with DGPs as well, one per DGP, applied on the > chassis where the DGP is resident, consistent with how dnat_and_snat and > subnet SNAT entries are handled on such routers. > > The consumers are outranked by regular SNAT entries. Routers with DGPs > shift their lr_out_snat NAT priorities up by 128, so a subnet SNAT entry on > a /24 lands at 153, above both the force SNAT consumer at 100 and the > skip_snat consumer at 120. Shift both consumers by the same amount on such > routers so that they keep the ordering they have on a gateway router. I just realized that this was already broken for IPv6 SNAT rules with longer prefixes, e.g., the out_snat rule for /128 NATs will always be hit before the skip_snat rule is hit. The problem was already there before your patch but now that you're changing this code, would you have time to send a follow up patch about that too? If not, I'll try to find some time on my side. > > flags.force_snat_for_dnat is only ever produced on gateway routers > (build_lrouter_in_dnat_flow() sets it under od->is_gw_router), so the > dnat_force_snat_ip consumer is left unchanged. > > The system tests check that the client actually gets a response, both for > a client behind another router and for a backend connecting to its own > VIP, with a competing subnet SNAT entry configured. The test in the > reverted version only checked the SNAT conntrack entry on the backend side, > which looked correct even though every connection was reset. > > Assisted-by: Claude Opus 5, Claude Code > Signed-off-by: Jaygue Lee <[email protected]> > --- > v4: - Fix the unDNAT of load balanced replies on routers with DGPs when > lb_force_snat_ip or skip_snat is used. The FORCE_SNAT and SKIP_SNAT > variants of the lr_out_undnat flow only set the flag and never did > ct_dnat, so v3 never worked end to end: every connection was reset > by the client. Don't set flags.force_snat_for_lb on the reply. > - Shift the skip_snat consumer on routers with DGPs like the force > SNAT one; it was outranked by subnet SNAT entries as well. > - Rework the system test to require that the client actually gets a > response, add the hairpin case, and add a skip_snat system test. > The v3 test only checked the backend-side SNAT conntrack entry. > - Check the lr_out_undnat actions and the skip_snat consumer > priority in ovn-northd.at. The rest looks good to me so I applied the patch to main, 26.09 and 26.03. Thanks again! Regards, Dumitru _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
