]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: fix segmentation of forwarding fraglist GRO
authorJibin Zhang <jibin.zhang@mediatek.com>
Mon, 26 Jan 2026 15:21:11 +0000 (23:21 +0800)
committerPaolo Abeni <pabeni@redhat.com>
Thu, 29 Jan 2026 13:40:12 +0000 (14:40 +0100)
This patch enhances GSO segment handling by properly checking
the SKB_GSO_DODGY flag for frag_list GSO packets, addressing
low throughput issues observed when a station accesses IPv4
servers via hotspots with an IPv6-only upstream interface.

Specifically, it fixes a bug in GSO segmentation when forwarding
GRO packets containing a frag_list. The function skb_segment_list
cannot correctly process GRO skbs that have been converted by XLAT,
since XLAT only translates the header of the head skb. Consequently,
skbs in the frag_list may remain untranslated, resulting in protocol
inconsistencies and reduced throughput.

To address this, the patch explicitly sets the SKB_GSO_DODGY flag
for GSO packets in XLAT's IPv4/IPv6 protocol translation helpers
(bpf_skb_proto_4_to_6 and bpf_skb_proto_6_to_4). This marks GSO
packets as potentially modified after protocol translation. As a
result, GSO segmentation will avoid using skb_segment_list and
instead falls back to skb_segment for packets with the SKB_GSO_DODGY
flag. This ensures that only safe and fully translated frag_list
packets are processed by skb_segment_list, resolving protocol
inconsistencies and improving throughput when forwarding GRO packets
converted by XLAT.

Signed-off-by: Jibin Zhang <jibin.zhang@mediatek.com>
Fixes: 9fd1ff5d2ac7 ("udp: Support UDP fraglist GRO/GSO.")
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260126152114.1211-1-jibin.zhang@mediatek.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
net/core/filter.c
net/ipv4/tcp_offload.c
net/ipv4/udp_offload.c
net/ipv6/tcpv6_offload.c

index 616e0520a0bb81a8a8df1bae09c3d0a110d9713c..bcd73d9bd764918052f6b33c01196419332cf58a 100644 (file)
@@ -3353,6 +3353,7 @@ static int bpf_skb_proto_4_to_6(struct sk_buff *skb)
                        shinfo->gso_type &= ~SKB_GSO_TCPV4;
                        shinfo->gso_type |=  SKB_GSO_TCPV6;
                }
+               shinfo->gso_type |=  SKB_GSO_DODGY;
        }
 
        bpf_skb_change_protocol(skb, ETH_P_IPV6);
@@ -3383,6 +3384,7 @@ static int bpf_skb_proto_6_to_4(struct sk_buff *skb)
                        shinfo->gso_type &= ~SKB_GSO_TCPV6;
                        shinfo->gso_type |=  SKB_GSO_TCPV4;
                }
+               shinfo->gso_type |=  SKB_GSO_DODGY;
        }
 
        bpf_skb_change_protocol(skb, ETH_P_IP);
index fdda18b1abda0f69226f6b59cec6d7d51b53555b..942a948f1a3109666ef66d7517e22f9e73122065 100644 (file)
@@ -107,7 +107,8 @@ static struct sk_buff *tcp4_gso_segment(struct sk_buff *skb,
        if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST) {
                struct tcphdr *th = tcp_hdr(skb);
 
-               if (skb_pagelen(skb) - th->doff * 4 == skb_shinfo(skb)->gso_size)
+               if ((skb_pagelen(skb) - th->doff * 4 == skb_shinfo(skb)->gso_size) &&
+                   !(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
                        return __tcp4_gso_segment_list(skb, features);
 
                skb->ip_summed = CHECKSUM_NONE;
index 19d0b5b09ffae6bc0cda0b67fc229fa01dc37e8e..589456bd8b5f1b8298d2e46079f95cbff64b4f89 100644 (file)
@@ -514,7 +514,8 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
 
        if (skb_shinfo(gso_skb)->gso_type & SKB_GSO_FRAGLIST) {
                 /* Detect modified geometry and pass those to skb_segment. */
-               if (skb_pagelen(gso_skb) - sizeof(*uh) == skb_shinfo(gso_skb)->gso_size)
+               if ((skb_pagelen(gso_skb) - sizeof(*uh) == skb_shinfo(gso_skb)->gso_size) &&
+                   !(skb_shinfo(gso_skb)->gso_type & SKB_GSO_DODGY))
                        return __udp_gso_segment_list(gso_skb, features, is_ipv6);
 
                ret = __skb_linearize(gso_skb);
index effeba58630b5ac2593b824bd8fc10a473954b6c..5670d32c27f80ec3102b0d50c5fc8443e732722f 100644 (file)
@@ -170,7 +170,8 @@ static struct sk_buff *tcp6_gso_segment(struct sk_buff *skb,
        if (skb_shinfo(skb)->gso_type & SKB_GSO_FRAGLIST) {
                struct tcphdr *th = tcp_hdr(skb);
 
-               if (skb_pagelen(skb) - th->doff * 4 == skb_shinfo(skb)->gso_size)
+               if ((skb_pagelen(skb) - th->doff * 4 == skb_shinfo(skb)->gso_size) &&
+                   !(skb_shinfo(skb)->gso_type & SKB_GSO_DODGY))
                        return __tcp6_gso_segment_list(skb, features);
 
                skb->ip_summed = CHECKSUM_NONE;