mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xavier HSINYUAN <XavierHsinyuan@outlook.com>
To: ralf@mandelbit.com
Cc: antonio@mandelbit.com, davem@davemloft.net, dxld@darkboxed.org,
	edumazet@kernel.org, horms@kernel.org, kuba@kernel.org,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
	pabeni@redhat.com
Subject: Re: [RFC net-next v2 11/18] net: ipxlat: add IPv4/IPv6 header and transport translation
Date: Fri, 6 Nov 2026 21:37:52 +0800	[thread overview]
Message-ID: <TYCPR01MB1100852BD6000EFAFDF14A418CA762@TYCPR01MB11008.jpnprd01.prod.outlook.com> (raw)
In-Reply-To: <20261024092532.172005-12-ralf@mandelbit.com>

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

  reply	other threads:[~2026-11-06 13:38 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-24  9:25 [RFC net-next v2 00/18] net: introduce ipxlat stateless IPv4/IPv6 translation Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 01/18] lwtunnel: track callback dispatch separately from return value Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 02/18] ipv4/ipv6: add LWT receive helpers Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 03/18] ipv6: allow output fragmentation to reuse a Fragment Header Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 04/18] netfilter: preserve IPv6 refragmentation state across reassembly Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 05/18] net: ipxlat: add engine skeleton and configuration model Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 06/18] net: ipxlat: add RFC 6052 and EAM address translation Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 07/18] net: ipxlat: add packet metadata and header helpers Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 08/18] net: ipxlat: add IPv4 packet validation Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 09/18] net: ipxlat: add IPv6 " Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 10/18] net: ipxlat: add checksum and offload helpers Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 11/18] net: ipxlat: add IPv4/IPv6 header and transport translation Ralf Lici
2026-11-06 13:37   ` Xavier HSINYUAN [this message]
2026-11-14  9:28     ` Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 12/18] net: ipxlat: add translation preparation and dispatch Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 13/18] net: ipxlat: add translator-generated ICMP errors Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 14/18] net: ipxlat: add ICMP informational translation Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 15/18] net: ipxlat: add ICMP error and quoted-packet translation Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 16/18] net: ipxlat: add lightweight tunnel attachment Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 17/18] selftests: net: add ipxlat coverage Ralf Lici
2026-11-06 13:39   ` Xavier HSINYUAN
2026-11-14  9:31     ` Ralf Lici
2026-10-24  9:25 ` [RFC net-next v2 18/18] docs: networking: add ipxlat guide Ralf Lici
2026-11-06 14:17 ` [RFC net-next v2 00/18] net: introduce ipxlat stateless IPv4/IPv6 translation Xavier HSINYUAN
2026-11-14  9:47   ` Ralf Lici

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=TYCPR01MB1100852BD6000EFAFDF14A418CA762@TYCPR01MB11008.jpnprd01.prod.outlook.com \
    --to=xavierhsinyuan@outlook.com \
    --cc=antonio@mandelbit.com \
    --cc=davem@davemloft.net \
    --cc=dxld@darkboxed.org \
    --cc=edumazet@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ralf@mandelbit.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®