Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider. Critical: 0 · High: 1 · Medium: 0 · Low: 2 If you believe none of the issues are legitimate, please reply to each issue of Medium severity or higher and explain why the AI is wrong. If any of them are legitimate and you plan to respin, please let patchwork know by including "pw-bot: cr" as a separate line at the end of your reply (one such reply per series is enough). - [High] The fix is incomplete: tunnels with the outer UDP checksum turned off are still corrupted after flow offload. - [Low] The new comment in nf_flow_nat_ip_udp() (net/netfilter/nf_flow_table_ip.c, lines 62-63) calls the reference… - [Low] netfilter: nf_flow_table: duplicated LCO toggle open-codes csum helper -- netfilter: nf_flow_table: Fix stale outer UDP checksum in the fastpath This patch changes the flowtable UDP NAT helpers nf_flow_nat_ip_udp(), nf_flow_nat_ipv6_udp() and nf_flow_nat_port_udp() to detect the LCO state. In that state the skb is CHECKSUM_PARTIAL and not GSO, and the offload target is not this udphdr->check. When it is detected, ip_summed is temporarily switched to CHECKSUM_NONE so the outer UDP checksum is updated on the complete-checksum path, mirroring the __udp_manip_pkt() fix. [ ... ]
> diff --git a/net/netfilter/nf_flow_table_ip.c b/net/netfilter/nf_flow_table_ip.c > index 19cafae748abe..4b69527942f6d 100644 > --- a/net/netfilter/nf_flow_table_ip.c > +++ b/net/netfilter/nf_flow_table_ip.c > @@ -59,8 +59,28 @@ static void nf_flow_nat_ip_udp(struct sk_buff *skb, unsigned int thoff, > > udph = (void *)(skb_network_header(skb) + thoff); > if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) { > + /* Same LCO state as __udp_manip_pkt() in the NAT > + * OUTPUT path: for encapsulated CHECKSUM_PARTIAL,
[Severity: Low] This isn't a bug, but is "in the NAT OUTPUT path" accurate here? __udp_manip_pkt() takes no hook argument. udp_manip_pkt() calls it for both SNAT and DNAT at every NAT hook, and the LCO case with MASQUERADE would run in POSTROUTING rather than OUTPUT.
> + * non-GSO packets, udp_set_csum() writes a complete > + * checksum into uh->check while csum_start points at > + * the inner transport header. inet_proto_csum_replace4() > + * would take the pseudohdr seed branch and apply the > + * address delta with the wrong sign. Temporarily flip > + * ip_summed so the complete-checksum path is used. > + */ > + bool lco = skb->ip_summed == CHECKSUM_PARTIAL && > + !skb_is_gso(skb) && > + (skb->head + skb->csum_start + skb->csum_offset) != > + (unsigned char *)&udph->check; > + > + if (lco) > + skb->ip_summed = CHECKSUM_NONE; > + > inet_proto_csum_replace4(&udph->check, skb, addr, > new_addr, true); > + > + if (lco) > + skb->ip_summed = CHECKSUM_PARTIAL; > if (!udph->check) > udph->check = CSUM_MANGLED_0; > }
[Severity: Low] This isn't a bug, but this patch open-codes the same lco predicate three times, along with the ip_summed save/restore around inet_proto_csum_replace*(): - nf_flow_nat_port_udp() - nf_flow_nat_ip_udp() - nf_flow_nat_ipv6_udp() Patch 1/2 adds a fourth copy in __udp_manip_pkt(). That is fairly subtle checksum state logic, and every copy has to be kept in sync. Any later fix to it would have to be applied in four places. All four copies also open-code skb->head + skb->csum_start. skb_checksum_start() in include/linux/skbuff.h already provides that. Could the detection and the temporary ip_summed flip be factored into a single shared helper built on skb_checksum_start()? More broadly, inet_proto_csum_replace4(), inet_proto_csum_replace16() and inet_proto_csum_replace_by_diff() in net/core/utils.c already receive both sum and skb. They could tell whether sum is the offload target themselves. Other in-tree users rewrite outer addresses or ports through these helpers: - net/sched/act_nat.c - net/openvswitch/actions.c - the BPF l4 csum helpers in net/core/filter.c They look like they would hit the same LCO state on UDP tunnel traffic, and would still produce a stale outer checksum after this series. Was handling this in the core helpers considered? Or is there a reason to keep the workaround local to the netfilter callers? [Severity: High] Does the lco predicate also match tunnels that have the outer UDP checksum disabled? In that case udp_set_csum() takes the nocheck branch: net/ipv4/udp.c:udp_set_csum() { if (nocheck) { uh->check = 0; ... } ip_summed stays CHECKSUM_PARTIAL, csum_start still points at the inner transport header, and uh->check is 0. This gate still admits that skb: if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) { lco then evaluates true, and csum_replace4() runs on *sum == 0. The result is ~fold(~from + to), which is nonzero whenever the address actually changes. The CSUM_MANGLED_0 fallback therefore never fires, and the packet goes out with a nonzero but wrong outer checksum. Won't the receiving VTEP drop it? The same seems to apply in two other places: - nf_flow_nat_ipv6_udp() via inet_proto_csum_replace16(). udp6_set_csum() has the same nocheck branch. - nf_flow_nat_port_udp() in nf_flow_table_core.c, where the port delta is now written into the zero checksum. The classic path this is meant to mirror never rewrites a zero checksum: net/netfilter/nf_nat_proto.c:udp_manip_pkt() { ... __udp_manip_pkt(skb, iphdroff, hdr, tuple, maniptype, !!hdr->check); ... } So these packets would pass before offload and still be dropped after offload. Several common setups are in this state: - Geneve over IPv4, by default. geneve_nl2info() only sets IP_TUNNEL_CSUM_BIT when IFLA_GENEVE_UDP_CSUM=1. - VXLAN created with noudpcsum. - IPv6 tunnels using udp6zerocsumtx. This state was already broken before the patch, so it isn't a new regression. Address updates went through the CHECKSUM_PARTIAL seed branch, and the port update was a no-op followed by CSUM_MANGLED_0. The commit message says this mirrors the __udp_manip_pkt() fix. Should these helpers skip the update when lco is set and udph->check is 0, to match the !!hdr->check gate in udp_manip_pkt()? [ ... ]
-- Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/2026…%40cmss.chinamobile.com