kernel: update fraglist GRO patch to the latest upstream submission
authorFelix Fietkau <nbd@nbd.name>
Sat, 27 Apr 2024 18:34:53 +0000 (20:34 +0200)
committerFelix Fietkau <nbd@nbd.name>
Sat, 27 Apr 2024 18:39:07 +0000 (20:39 +0200)
Cosmetic fixes + IPv6 NAT support

Signed-off-by: Felix Fietkau <nbd@nbd.name>
target/linux/ath79/patches-6.1/900-unaligned_access_hacks.patch
target/linux/generic/pending-6.1/680-net-add-TCP-fraglist-GRO-support.patch
target/linux/generic/pending-6.6/680-net-add-TCP-fraglist-GRO-support.patch

index da56bc306d2233b2f0e12dfdea5ce0d408589a42..2763b16bf5a89c41047598d03af723ed9786e9d3 100644 (file)
@@ -858,16 +858,16 @@ SVN-Revision: 35130
  
 --- a/net/ipv4/tcp_offload.c
 +++ b/net/ipv4/tcp_offload.c
-@@ -60,7 +60,7 @@ static struct sk_buff *__tcpv4_gso_segme
+@@ -62,7 +62,7 @@ static struct sk_buff *__tcpv4_gso_segme
        th2 = tcp_hdr(seg->next);
        iph2 = ip_hdr(seg->next);
  
--      if (!(*(u32 *)&th->source ^ *(u32 *)&th2->source) &&
+-      if (!(*(const u32 *)&th->source ^ *(const u32 *)&th2->source) &&
 +      if (!(net_hdr_word(&th->source) ^ net_hdr_word(&th2->source)) &&
            iph->daddr == iph2->daddr && iph->saddr == iph2->saddr)
                return segs;
  
-@@ -252,7 +252,7 @@ struct sk_buff *tcp_gro_lookup(struct li
+@@ -254,7 +254,7 @@ struct sk_buff *tcp_gro_lookup(struct li
                        continue;
  
                th2 = tcp_hdr(p);
@@ -876,7 +876,7 @@ SVN-Revision: 35130
                        NAPI_GRO_CB(p)->same_flow = 0;
                        continue;
                }
-@@ -318,8 +318,8 @@ struct sk_buff *tcp_gro_receive(struct l
+@@ -320,8 +320,8 @@ struct sk_buff *tcp_gro_receive(struct l
                  ~(TCP_FLAG_CWR | TCP_FLAG_FIN | TCP_FLAG_PSH));
        flush |= (__force int)(th->ack_seq ^ th2->ack_seq);
        for (i = sizeof(*th); i < thlen; i += 4)
index 13043729c3ab23c5734b6611748a5a5a687c2bc6..841c0de3e1b8a4f3537fdc839432c5fb7ccdd8f3 100644 (file)
@@ -130,36 +130,38 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  {
 --- a/net/ipv4/tcp_offload.c
 +++ b/net/ipv4/tcp_offload.c
-@@ -27,6 +27,68 @@ static void tcp_gso_tstamp(struct sk_buf
+@@ -27,6 +27,70 @@ static void tcp_gso_tstamp(struct sk_buf
        }
  }
  
 +static void __tcpv4_gso_segment_csum(struct sk_buff *seg,
-+                                   __be32 *oldip, __be32 *newip,
-+                                   __be16 *oldport, __be16 *newport)
++                                   __be32 *oldip, __be32 newip,
++                                   __be16 *oldport, __be16 newport)
 +{
 +      struct tcphdr *th;
 +      struct iphdr *iph;
 +
-+      if (*oldip == *newip && *oldport == *newport)
++      if (*oldip == newip && *oldport == newport)
 +              return;
 +
 +      th = tcp_hdr(seg);
 +      iph = ip_hdr(seg);
 +
-+      inet_proto_csum_replace4(&th->check, seg, *oldip, *newip, true);
-+      inet_proto_csum_replace2(&th->check, seg, *oldport, *newport, false);
-+      *oldport = *newport;
++      inet_proto_csum_replace4(&th->check, seg, *oldip, newip, true);
++      inet_proto_csum_replace2(&th->check, seg, *oldport, newport, false);
++      *oldport = newport;
 +
-+      csum_replace4(&iph->check, *oldip, *newip);
-+      *oldip = *newip;
++      csum_replace4(&iph->check, *oldip, newip);
++      *oldip = newip;
 +}
 +
 +static struct sk_buff *__tcpv4_gso_segment_list_csum(struct sk_buff *segs)
 +{
++      const struct tcphdr *th;
++      const struct iphdr *iph;
 +      struct sk_buff *seg;
-+      struct tcphdr *th, *th2;
-+      struct iphdr *iph, *iph2;
++      struct tcphdr *th2;
++      struct iphdr *iph2;
 +
 +      seg = segs;
 +      th = tcp_hdr(seg);
@@ -167,7 +169,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +      th2 = tcp_hdr(seg->next);
 +      iph2 = ip_hdr(seg->next);
 +
-+      if (!(*(u32 *)&th->source ^ *(u32 *)&th2->source) &&
++      if (!(*(const u32 *)&th->source ^ *(const u32 *)&th2->source) &&
 +          iph->daddr == iph2->daddr && iph->saddr == iph2->saddr)
 +              return segs;
 +
@@ -176,11 +178,11 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +              iph2 = ip_hdr(seg);
 +
 +              __tcpv4_gso_segment_csum(seg,
-+                                       &iph2->saddr, &iph->saddr,
-+                                       &th2->source, &th->source);
++                                       &iph2->saddr, iph->saddr,
++                                       &th2->source, th->source);
 +              __tcpv4_gso_segment_csum(seg,
-+                                       &iph2->daddr, &iph->daddr,
-+                                       &th2->dest, &th->dest);
++                                       &iph2->daddr, iph->daddr,
++                                       &th2->dest, th->dest);
 +      }
 +
 +      return segs;
@@ -199,7 +201,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  static struct sk_buff *tcp4_gso_segment(struct sk_buff *skb,
                                        netdev_features_t features)
  {
-@@ -36,6 +98,9 @@ static struct sk_buff *tcp4_gso_segment(
+@@ -36,6 +100,9 @@ static struct sk_buff *tcp4_gso_segment(
        if (!pskb_may_pull(skb, sizeof(struct tcphdr)))
                return ERR_PTR(-EINVAL);
  
@@ -209,7 +211,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
                const struct iphdr *iph = ip_hdr(skb);
                struct tcphdr *th = tcp_hdr(skb);
-@@ -177,61 +242,76 @@ out:
+@@ -177,61 +244,76 @@ out:
        return segs;
  }
  
@@ -316,15 +318,14 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        flush = NAPI_GRO_CB(p)->flush;
        flush |= (__force int)(flags & TCP_FLAG_CWR);
        flush |= (__force int)((flags ^ tcp_flag_word(th2)) &
-@@ -268,6 +348,19 @@ found:
+@@ -268,6 +350,18 @@ found:
        flush |= p->decrypted ^ skb->decrypted;
  #endif
  
-+      if (NAPI_GRO_CB(p)->is_flist) {
++      if (unlikely(NAPI_GRO_CB(p)->is_flist)) {
 +              flush |= (__force int)(flags ^ tcp_flag_word(th2));
 +              flush |= skb->ip_summed != p->ip_summed;
 +              flush |= skb->csum_level != p->csum_level;
-+              flush |= !pskb_may_pull(skb, skb_gro_offset(skb));
 +              flush |= NAPI_GRO_CB(p)->count >= 64;
 +
 +              if (flush || skb_gro_receive_list(p, skb))
@@ -336,7 +337,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        if (flush || skb_gro_receive(p, skb)) {
                mss = 1;
                goto out_check_final;
-@@ -289,7 +382,6 @@ out_check_final:
+@@ -289,7 +383,6 @@ out_check_final:
        if (p && (!NAPI_GRO_CB(skb)->same_flow || flush))
                pp = p;
  
@@ -344,17 +345,17 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        NAPI_GRO_CB(skb)->flush |= (flush != 0);
  
        return pp;
-@@ -315,18 +407,56 @@ int tcp_gro_complete(struct sk_buff *skb
+@@ -315,18 +408,58 @@ int tcp_gro_complete(struct sk_buff *skb
  }
  EXPORT_SYMBOL(tcp_gro_complete);
  
 +static void tcp4_check_fraglist_gro(struct list_head *head, struct sk_buff *skb,
 +                                  struct tcphdr *th)
 +{
-+      const struct iphdr *iph = skb_gro_network_header(skb);
-+      struct net *net = dev_net(skb->dev);
++      const struct iphdr *iph;
 +      struct sk_buff *p;
 +      struct sock *sk;
++      struct net *net;
 +      int iif, sdif;
 +
 +      if (!(skb->dev->features & NETIF_F_GRO_FRAGLIST))
@@ -367,6 +368,8 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +      }
 +
 +      inet_get_iif_sdif(skb, &iif, &sdif);
++      iph = skb_gro_network_header(skb);
++      net = dev_net(skb->dev);
 +      sk = __inet_lookup_established(net, net->ipv4.tcp_death_row.hashinfo,
 +                                     iph->saddr, th->source,
 +                                     iph->daddr, ntohs(th->dest),
@@ -406,11 +409,11 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  }
  
  INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff)
-@@ -334,6 +464,15 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_com
+@@ -334,6 +467,15 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_com
        const struct iphdr *iph = ip_hdr(skb);
        struct tcphdr *th = tcp_hdr(skb);
  
-+      if (NAPI_GRO_CB(skb)->is_flist) {
++      if (unlikely(NAPI_GRO_CB(skb)->is_flist)) {
 +              skb_shinfo(skb)->gso_type |= SKB_GSO_FRAGLIST | SKB_GSO_TCPV4;
 +              skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
 +
@@ -460,7 +463,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
 --- a/net/ipv6/tcpv6_offload.c
 +++ b/net/ipv6/tcpv6_offload.c
-@@ -7,24 +7,65 @@
+@@ -7,24 +7,67 @@
   */
  #include <linux/indirect_call_wrapper.h>
  #include <linux/skbuff.h>
@@ -475,10 +478,10 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +                                  struct tcphdr *th)
 +{
 +#if IS_ENABLED(CONFIG_IPV6)
-+      const struct ipv6hdr *hdr = skb_gro_network_header(skb);
-+      struct net *net = dev_net(skb->dev);
++      const struct ipv6hdr *hdr;
 +      struct sk_buff *p;
 +      struct sock *sk;
++      struct net *net;
 +      int iif, sdif;
 +
 +      if (!(skb->dev->features & NETIF_F_GRO_FRAGLIST))
@@ -491,6 +494,8 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +      }
 +
 +      inet6_get_iif_sdif(skb, &iif, &sdif);
++      hdr = skb_gro_network_header(skb);
++      net = dev_net(skb->dev);
 +      sk = __inet6_lookup_established(net, net->ipv4.tcp_death_row.hashinfo,
 +                                      &hdr->saddr, th->source,
 +                                      &hdr->daddr, ntohs(th->dest),
@@ -531,11 +536,11 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  }
  
  INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int thoff)
-@@ -32,6 +73,15 @@ INDIRECT_CALLABLE_SCOPE int tcp6_gro_com
+@@ -32,6 +75,15 @@ INDIRECT_CALLABLE_SCOPE int tcp6_gro_com
        const struct ipv6hdr *iph = ipv6_hdr(skb);
        struct tcphdr *th = tcp_hdr(skb);
  
-+      if (NAPI_GRO_CB(skb)->is_flist) {
++      if (unlikely(NAPI_GRO_CB(skb)->is_flist)) {
 +              skb_shinfo(skb)->gso_type |= SKB_GSO_FRAGLIST | SKB_GSO_TCPV6;
 +              skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
 +
@@ -547,12 +552,74 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        th->check = ~tcp_v6_check(skb->len - thoff, &iph->saddr,
                                  &iph->daddr, 0);
        skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6;
-@@ -50,6 +100,9 @@ static struct sk_buff *tcp6_gso_segment(
+@@ -39,6 +91,61 @@ INDIRECT_CALLABLE_SCOPE int tcp6_gro_com
+       return tcp_gro_complete(skb);
+ }
++static void __tcpv6_gso_segment_csum(struct sk_buff *seg,
++                                   __be16 *oldport, __be16 newport)
++{
++      struct tcphdr *th;
++
++      if (*oldport == newport)
++              return;
++
++      th = tcp_hdr(seg);
++      inet_proto_csum_replace2(&th->check, seg, *oldport, newport, false);
++      *oldport = newport;
++}
++
++static struct sk_buff *__tcpv6_gso_segment_list_csum(struct sk_buff *segs)
++{
++      const struct tcphdr *th;
++      const struct ipv6hdr *iph;
++      struct sk_buff *seg;
++      struct tcphdr *th2;
++      struct ipv6hdr *iph2;
++
++      seg = segs;
++      th = tcp_hdr(seg);
++      iph = ipv6_hdr(seg);
++      th2 = tcp_hdr(seg->next);
++      iph2 = ipv6_hdr(seg->next);
++
++      if (!(*(const u32 *)&th->source ^ *(const u32 *)&th2->source) &&
++          ipv6_addr_equal(&iph->saddr, &iph2->saddr) &&
++          ipv6_addr_equal(&iph->daddr, &iph2->daddr))
++              return segs;
++
++      while ((seg = seg->next)) {
++              th2 = tcp_hdr(seg);
++              iph2 = ipv6_hdr(seg);
++
++              iph2->saddr = iph->saddr;
++              iph2->daddr = iph->daddr;
++              __tcpv6_gso_segment_csum(seg, &th2->source, th->source);
++              __tcpv6_gso_segment_csum(seg, &th2->dest, th->dest);
++      }
++
++      return segs;
++}
++
++static struct sk_buff *__tcp6_gso_segment_list(struct sk_buff *skb,
++                                            netdev_features_t features)
++{
++      skb = skb_segment_list(skb, features, skb_mac_header_len(skb));
++      if (IS_ERR(skb))
++              return skb;
++
++      return __tcpv6_gso_segment_list_csum(skb);
++}
++
+ static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb,
+                                       netdev_features_t features)
+ {
+@@ -50,6 +157,9 @@ static struct sk_buff *tcp6_gso_segment(
        if (!pskb_may_pull(skb, sizeof(*th)))
                return ERR_PTR(-EINVAL);
  
 +      if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST)
-+              return skb_segment_list(skb, features, skb_mac_header_len(skb));
++              return __tcp6_gso_segment_list(skb, features);
 +
        if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
                const struct ipv6hdr *ipv6h = ipv6_hdr(skb);
index 11255afbdaca7b43be9b5ab9c1fb132bdb8918cc..6205901707a24aec0d0045bd8b16ebbf4a9f47df 100644 (file)
@@ -81,36 +81,38 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  {
 --- a/net/ipv4/tcp_offload.c
 +++ b/net/ipv4/tcp_offload.c
-@@ -28,6 +28,68 @@ static void tcp_gso_tstamp(struct sk_buf
+@@ -28,6 +28,70 @@ static void tcp_gso_tstamp(struct sk_buf
        }
  }
  
 +static void __tcpv4_gso_segment_csum(struct sk_buff *seg,
-+                                   __be32 *oldip, __be32 *newip,
-+                                   __be16 *oldport, __be16 *newport)
++                                   __be32 *oldip, __be32 newip,
++                                   __be16 *oldport, __be16 newport)
 +{
 +      struct tcphdr *th;
 +      struct iphdr *iph;
 +
-+      if (*oldip == *newip && *oldport == *newport)
++      if (*oldip == newip && *oldport == newport)
 +              return;
 +
 +      th = tcp_hdr(seg);
 +      iph = ip_hdr(seg);
 +
-+      inet_proto_csum_replace4(&th->check, seg, *oldip, *newip, true);
-+      inet_proto_csum_replace2(&th->check, seg, *oldport, *newport, false);
-+      *oldport = *newport;
++      inet_proto_csum_replace4(&th->check, seg, *oldip, newip, true);
++      inet_proto_csum_replace2(&th->check, seg, *oldport, newport, false);
++      *oldport = newport;
 +
-+      csum_replace4(&iph->check, *oldip, *newip);
-+      *oldip = *newip;
++      csum_replace4(&iph->check, *oldip, newip);
++      *oldip = newip;
 +}
 +
 +static struct sk_buff *__tcpv4_gso_segment_list_csum(struct sk_buff *segs)
 +{
++      const struct tcphdr *th;
++      const struct iphdr *iph;
 +      struct sk_buff *seg;
-+      struct tcphdr *th, *th2;
-+      struct iphdr *iph, *iph2;
++      struct tcphdr *th2;
++      struct iphdr *iph2;
 +
 +      seg = segs;
 +      th = tcp_hdr(seg);
@@ -118,7 +120,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +      th2 = tcp_hdr(seg->next);
 +      iph2 = ip_hdr(seg->next);
 +
-+      if (!(*(u32 *)&th->source ^ *(u32 *)&th2->source) &&
++      if (!(*(const u32 *)&th->source ^ *(const u32 *)&th2->source) &&
 +          iph->daddr == iph2->daddr && iph->saddr == iph2->saddr)
 +              return segs;
 +
@@ -127,11 +129,11 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +              iph2 = ip_hdr(seg);
 +
 +              __tcpv4_gso_segment_csum(seg,
-+                                       &iph2->saddr, &iph->saddr,
-+                                       &th2->source, &th->source);
++                                       &iph2->saddr, iph->saddr,
++                                       &th2->source, th->source);
 +              __tcpv4_gso_segment_csum(seg,
-+                                       &iph2->daddr, &iph->daddr,
-+                                       &th2->dest, &th->dest);
++                                       &iph2->daddr, iph->daddr,
++                                       &th2->dest, th->dest);
 +      }
 +
 +      return segs;
@@ -150,7 +152,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  static struct sk_buff *tcp4_gso_segment(struct sk_buff *skb,
                                        netdev_features_t features)
  {
-@@ -37,6 +99,9 @@ static struct sk_buff *tcp4_gso_segment(
+@@ -37,6 +101,9 @@ static struct sk_buff *tcp4_gso_segment(
        if (!pskb_may_pull(skb, sizeof(struct tcphdr)))
                return ERR_PTR(-EINVAL);
  
@@ -160,7 +162,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
                const struct iphdr *iph = ip_hdr(skb);
                struct tcphdr *th = tcp_hdr(skb);
-@@ -178,61 +243,76 @@ out:
+@@ -178,61 +245,76 @@ out:
        return segs;
  }
  
@@ -267,15 +269,14 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        flush = NAPI_GRO_CB(p)->flush;
        flush |= (__force int)(flags & TCP_FLAG_CWR);
        flush |= (__force int)((flags ^ tcp_flag_word(th2)) &
-@@ -269,6 +349,19 @@ found:
+@@ -269,6 +351,18 @@ found:
        flush |= p->decrypted ^ skb->decrypted;
  #endif
  
-+      if (NAPI_GRO_CB(p)->is_flist) {
++      if (unlikely(NAPI_GRO_CB(p)->is_flist)) {
 +              flush |= (__force int)(flags ^ tcp_flag_word(th2));
 +              flush |= skb->ip_summed != p->ip_summed;
 +              flush |= skb->csum_level != p->csum_level;
-+              flush |= !pskb_may_pull(skb, skb_gro_offset(skb));
 +              flush |= NAPI_GRO_CB(p)->count >= 64;
 +
 +              if (flush || skb_gro_receive_list(p, skb))
@@ -287,7 +288,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        if (flush || skb_gro_receive(p, skb)) {
                mss = 1;
                goto out_check_final;
-@@ -290,7 +383,6 @@ out_check_final:
+@@ -290,7 +384,6 @@ out_check_final:
        if (p && (!NAPI_GRO_CB(skb)->same_flow || flush))
                pp = p;
  
@@ -295,17 +296,17 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        NAPI_GRO_CB(skb)->flush |= (flush != 0);
  
        return pp;
-@@ -314,18 +406,56 @@ void tcp_gro_complete(struct sk_buff *sk
+@@ -314,18 +407,58 @@ void tcp_gro_complete(struct sk_buff *sk
  }
  EXPORT_SYMBOL(tcp_gro_complete);
  
 +static void tcp4_check_fraglist_gro(struct list_head *head, struct sk_buff *skb,
 +                                  struct tcphdr *th)
 +{
-+      const struct iphdr *iph = skb_gro_network_header(skb);
-+      struct net *net = dev_net(skb->dev);
++      const struct iphdr *iph;
 +      struct sk_buff *p;
 +      struct sock *sk;
++      struct net *net;
 +      int iif, sdif;
 +
 +      if (!(skb->dev->features & NETIF_F_GRO_FRAGLIST))
@@ -318,6 +319,8 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +      }
 +
 +      inet_get_iif_sdif(skb, &iif, &sdif);
++      iph = skb_gro_network_header(skb);
++      net = dev_net(skb->dev);
 +      sk = __inet_lookup_established(net, net->ipv4.tcp_death_row.hashinfo,
 +                                     iph->saddr, th->source,
 +                                     iph->daddr, ntohs(th->dest),
@@ -357,11 +360,11 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  }
  
  INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff)
-@@ -333,6 +463,15 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_com
+@@ -333,6 +466,15 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_com
        const struct iphdr *iph = ip_hdr(skb);
        struct tcphdr *th = tcp_hdr(skb);
  
-+      if (NAPI_GRO_CB(skb)->is_flist) {
++      if (unlikely(NAPI_GRO_CB(skb)->is_flist)) {
 +              skb_shinfo(skb)->gso_type |= SKB_GSO_FRAGLIST | SKB_GSO_TCPV4;
 +              skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
 +
@@ -411,7 +414,7 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  static struct sk_buff *udp_gro_receive_segment(struct list_head *head,
 --- a/net/ipv6/tcpv6_offload.c
 +++ b/net/ipv6/tcpv6_offload.c
-@@ -7,24 +7,65 @@
+@@ -7,24 +7,67 @@
   */
  #include <linux/indirect_call_wrapper.h>
  #include <linux/skbuff.h>
@@ -426,10 +429,10 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +                                  struct tcphdr *th)
 +{
 +#if IS_ENABLED(CONFIG_IPV6)
-+      const struct ipv6hdr *hdr = skb_gro_network_header(skb);
-+      struct net *net = dev_net(skb->dev);
++      const struct ipv6hdr *hdr;
 +      struct sk_buff *p;
 +      struct sock *sk;
++      struct net *net;
 +      int iif, sdif;
 +
 +      if (!(skb->dev->features & NETIF_F_GRO_FRAGLIST))
@@ -442,6 +445,8 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
 +      }
 +
 +      inet6_get_iif_sdif(skb, &iif, &sdif);
++      hdr = skb_gro_network_header(skb);
++      net = dev_net(skb->dev);
 +      sk = __inet6_lookup_established(net, net->ipv4.tcp_death_row.hashinfo,
 +                                      &hdr->saddr, th->source,
 +                                      &hdr->daddr, ntohs(th->dest),
@@ -482,11 +487,11 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
  }
  
  INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int thoff)
-@@ -32,6 +73,15 @@ INDIRECT_CALLABLE_SCOPE int tcp6_gro_com
+@@ -32,6 +75,15 @@ INDIRECT_CALLABLE_SCOPE int tcp6_gro_com
        const struct ipv6hdr *iph = ipv6_hdr(skb);
        struct tcphdr *th = tcp_hdr(skb);
  
-+      if (NAPI_GRO_CB(skb)->is_flist) {
++      if (unlikely(NAPI_GRO_CB(skb)->is_flist)) {
 +              skb_shinfo(skb)->gso_type |= SKB_GSO_FRAGLIST | SKB_GSO_TCPV6;
 +              skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
 +
@@ -498,12 +503,74 @@ Signe-off-by: Felix Fietkau <nbd@nbd.name>
        th->check = ~tcp_v6_check(skb->len - thoff, &iph->saddr,
                                  &iph->daddr, 0);
        skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6;
-@@ -51,6 +101,9 @@ static struct sk_buff *tcp6_gso_segment(
+@@ -40,6 +92,61 @@ INDIRECT_CALLABLE_SCOPE int tcp6_gro_com
+       return 0;
+ }
++static void __tcpv6_gso_segment_csum(struct sk_buff *seg,
++                                   __be16 *oldport, __be16 newport)
++{
++      struct tcphdr *th;
++
++      if (*oldport == newport)
++              return;
++
++      th = tcp_hdr(seg);
++      inet_proto_csum_replace2(&th->check, seg, *oldport, newport, false);
++      *oldport = newport;
++}
++
++static struct sk_buff *__tcpv6_gso_segment_list_csum(struct sk_buff *segs)
++{
++      const struct tcphdr *th;
++      const struct ipv6hdr *iph;
++      struct sk_buff *seg;
++      struct tcphdr *th2;
++      struct ipv6hdr *iph2;
++
++      seg = segs;
++      th = tcp_hdr(seg);
++      iph = ipv6_hdr(seg);
++      th2 = tcp_hdr(seg->next);
++      iph2 = ipv6_hdr(seg->next);
++
++      if (!(*(const u32 *)&th->source ^ *(const u32 *)&th2->source) &&
++          ipv6_addr_equal(&iph->saddr, &iph2->saddr) &&
++          ipv6_addr_equal(&iph->daddr, &iph2->daddr))
++              return segs;
++
++      while ((seg = seg->next)) {
++              th2 = tcp_hdr(seg);
++              iph2 = ipv6_hdr(seg);
++
++              iph2->saddr = iph->saddr;
++              iph2->daddr = iph->daddr;
++              __tcpv6_gso_segment_csum(seg, &th2->source, th->source);
++              __tcpv6_gso_segment_csum(seg, &th2->dest, th->dest);
++      }
++
++      return segs;
++}
++
++static struct sk_buff *__tcp6_gso_segment_list(struct sk_buff *skb,
++                                            netdev_features_t features)
++{
++      skb = skb_segment_list(skb, features, skb_mac_header_len(skb));
++      if (IS_ERR(skb))
++              return skb;
++
++      return __tcpv6_gso_segment_list_csum(skb);
++}
++
+ static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb,
+                                       netdev_features_t features)
+ {
+@@ -51,6 +158,9 @@ static struct sk_buff *tcp6_gso_segment(
        if (!pskb_may_pull(skb, sizeof(*th)))
                return ERR_PTR(-EINVAL);
  
 +      if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST)
-+              return skb_segment_list(skb, features, skb_mac_header_len(skb));
++              return __tcp6_gso_segment_list(skb, features);
 +
        if (unlikely(skb->ip_summed != CHECKSUM_PARTIAL)) {
                const struct ipv6hdr *ipv6h = ipv6_hdr(skb);