Re: [RFC net-next v2 11/18] net: ipxlat: add IPv4/IPv6 header and transport translation
From: Xavier HSINYUAN
Date: Fri Nov 06 2026 - 08:38:36 EST
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.
How about updating {tcp,udp}->check with a pseudo-header diff like
inet_proto_csum_replace_by_diff() to preserve the existing seed?
Best regards,
Xavier