net: ipv6: fix TCP GSO segmentation with NAT

[ Upstream commit daa624d3c2ddffdcbad140a9625a4064371db44f ]

When updating the source/destination address, the TCP/UDP checksum needs to
be updated as well.

Fixes: bee88cd5bd ("net: add support for segmenting TCP fraglist GSO packets")
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Link: https://patch.msgid.link/20250311212530.91519-1-nbd@nbd.name
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Felix Fietkau
2025-03-11 22:25:30 +01:00
committed by Greg Kroah-Hartman
parent d4bf956547
commit 8940e6168b
+15 -6
View File
@@ -94,14 +94,23 @@ INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int thoff)
} }
static void __tcpv6_gso_segment_csum(struct sk_buff *seg, static void __tcpv6_gso_segment_csum(struct sk_buff *seg,
struct in6_addr *oldip,
const struct in6_addr *newip,
__be16 *oldport, __be16 newport) __be16 *oldport, __be16 newport)
{ {
struct tcphdr *th; struct tcphdr *th = tcp_hdr(seg);
if (!ipv6_addr_equal(oldip, newip)) {
inet_proto_csum_replace16(&th->check, seg,
oldip->s6_addr32,
newip->s6_addr32,
true);
*oldip = *newip;
}
if (*oldport == newport) if (*oldport == newport)
return; return;
th = tcp_hdr(seg);
inet_proto_csum_replace2(&th->check, seg, *oldport, newport, false); inet_proto_csum_replace2(&th->check, seg, *oldport, newport, false);
*oldport = newport; *oldport = newport;
} }
@@ -129,10 +138,10 @@ static struct sk_buff *__tcpv6_gso_segment_list_csum(struct sk_buff *segs)
th2 = tcp_hdr(seg); th2 = tcp_hdr(seg);
iph2 = ipv6_hdr(seg); iph2 = ipv6_hdr(seg);
iph2->saddr = iph->saddr; __tcpv6_gso_segment_csum(seg, &iph2->saddr, &iph->saddr,
iph2->daddr = iph->daddr; &th2->source, th->source);
__tcpv6_gso_segment_csum(seg, &th2->source, th->source); __tcpv6_gso_segment_csum(seg, &iph2->daddr, &iph->daddr,
__tcpv6_gso_segment_csum(seg, &th2->dest, th->dest); &th2->dest, th->dest);
} }
return segs; return segs;