Re: [RFC net-next v2 11/18] net: ipxlat: add IPv4/IPv6 header and transport translation
From: Ralf Lici
Date: Sat Nov 14 2026 - 04:30:11 EST
On Fri, 06 Nov 2026 21:37:52 +0800, Xavier HSINYUAN <XavierHsinyuan@xxxxxxxxxxx> wrote:
> Hi Ralf,
>
> > +static int ipxlat_46_translate_tcp_csum(struct sk_buff *skb,
> > + const struct iphdr *in4)
> > +{
> > + const struct ipxlat_cb *cb = ipxlat_skb_cb(skb);
> > + const struct ipv6hdr *out6 = ipv6_hdr(skb);
> > + struct tcphdr *tcp = tcp_hdr(skb);
> > +
> > + /* CHECKSUM_PARTIAL contains a pseudo-header seed rather than a final
> > + * checksum. Replace it with the translated IPv6 pseudo-header and
> > + * leave completion to the later output path.
> > + */
> > + if (skb->ip_summed == CHECKSUM_PARTIAL) {
> > + tcp->check = ~tcp_v6_check(ipxlat_skb_l4_seg_len(skb, cb),
> > + &out6->saddr, &out6->daddr, 0);
> > + return ipxlat_set_partial_csum(skb,
> > + offsetof(struct tcphdr, check));
> > + }
> > +
> > + tcp->check = ipxlat_46_update_l4_csum(tcp->check, in4, out6);
> > + skb->ip_summed = CHECKSUM_NONE;
> > + return 0;
> > +}
> > +
> > +static int ipxlat_46_translate_udp_csum(struct sk_buff *skb,
> > + const struct iphdr *in4)
> > +{
> > + const struct ipxlat_cb *cb = ipxlat_skb_cb(skb);
> > + const struct ipv6hdr *out6 = ipv6_hdr(skb);
> > + struct udphdr *udp = udp_hdr(skb);
> > +
> > + if (skb->ip_summed == CHECKSUM_PARTIAL) {
> > + udp->check = ~udp_v6_check(ipxlat_skb_l4_seg_len(skb, cb),
> > + &out6->saddr, &out6->daddr, 0);
> > + return ipxlat_set_partial_csum(skb,
> > + offsetof(struct udphdr, check));
> > + }
> > +
> > + udp->check = ipxlat_46_update_l4_csum(udp->check, in4, out6);
> > + if (unlikely(!udp->check))
> > + udp->check = CSUM_MANGLED_0;
> > + skb->ip_summed = CHECKSUM_NONE;
> > + return 0;
> > +}
>
> Pseudo-header seed in CHECKSUM_PARTIAL uses per-segment length instead
> of the aggregate length, resulting in bad checksums for almost every
> segments.
>
You're right, just reproduced this locally. I confused the eventual
segment length with the length represented by the CHECKSUM_PARTIAL seed
on a GSO skb (the 6->4 path has the same bug). The current tests didn't
catch the bug because veth passes CHECKSUM_PARTIAL packets through, so
nothing ever computes or verifies the checksum.
> How about updating {tcp,udp}->check with a pseudo-header diff like
> inet_proto_csum_replace_by_diff() to preserve the existing seed?
>
Yes, the next revision will preserve the existing seed in both
directions by applying only the address delta, as the non-PARTIAL path
already does.
Thanks for catching this!
--
Ralf Lici
Mandelbit Srl