net: gro: avoid nesting TCP GSO skbs in skb_gro_receive_list()
Subsystems (4)
PATCH v2 1/1 net: gro: avoid nesting TCP GSO skbs in skb_gro_receive_list()
From: HW He <[email protected]>
On devices that support both NETIF_F_GRO_HW and NETIF_F_GRO_FRAGLIST, the hardware or driver may deliver packets that have already been aggregated into a TCP GSO skb with frags[]. GRO may then aggregate the skb again in skb_gro_receive_list().
This can create a nested GSO skb, which is not handled correctly by the later GSO segmentation paths. When the skb is segmented by skb_segment_list(), it not be fully restored to the original packets.
Avoid this by setting NAPI_GRO_CB(skb)->flush for GSO skbs before aggregation.
---
v2: Take Antoine Tenart's suggestion
v1: https://lore.kernel.org/netdev/amB7wb1A2Oo2dv5d@kwain/
--- net/ipv4/tcp_offload.c | 1 + 1 file changed, 1 insertion(+)
net/ipv4/tcp_offload.c +1 -0
@@ -332,6 +332,7 @@ struct sk_buff *tcp_gro_receive(struct list_head *head, struct sk_buff *skb, flush |= skb->ip_summed != p->ip_summed; flush |= skb->csum_level != p->csum_level; flush |=NAPI_GRO_CB (p)->count >=64 ; +NAPI_GRO_CB (skb)->flush |=skb_is_gso (skb);skb_set_network_header (skb,skb_gro_receive_network_offset (skb));if (flush ||skb_gro_receive_list (p, skb))
Signature · 1 line
2.17.0
Jakub Kicinski
maintainerQuoted 3 lines · On Thu, 23 Jul 2026 17:16:01 +0800 [email protected] wrote:
From: HW He <[email protected]>
On devices that support both
NETIF_F_GRO_HWandNETIF_F_GRO_FRAGLIST,
"devices that support FRAGLIST"? Isn't it a software feature?
Quoted 1 line
the hardware or driver may deliver packets that have already been
If you have a driver in mind please name it.
Quoted 9 lines
aggregated into a TCP GSO skb with frags[]. GRO may then aggregate the skb again in
skb_gro_receive_list().This can create a nested GSO skb, which is not handled correctly by the later GSO segmentation paths. When the skb is segmented by
skb_segment_list(), it not be fully restored to the original packets.Avoid this by setting NAPI_GRO_CB(skb)->flush for GSO skbs before aggregation.
I don't think we can do this. For GRO_HW devices re-aggregating in SW is quite helpful, HW often runs out of contexts or times out too soon, generating skbs with 16kB..32kB of data, the SW can help bring it up to full TSO.
Also - you're missing a Fixes tag.
Quoted 19 lines · Jakub Kicinski
Quoted 3 lines · On Thu, 23 Jul 2026 17:16:01 +0800 [email protected] wrote:
From: HW He <[email protected]>
On devices that support both
NETIF_F_GRO_HWandNETIF_F_GRO_FRAGLIST,"devices that support FRAGLIST"? Isn't it a software feature?
Quoted 1 line
the hardware or driver may deliver packets that have already been
If you have a driver in mind please name it.
Quoted 7 lines
aggregated into a TCP GSO skb with frags[]. GRO may then aggregate the skb again in
skb_gro_receive_list().This can create a nested GSO skb, which is not handled correctly by the later GSO segmentation paths. When the skb is segmented by
skb_segment_list(), it not be fully restored to the original packets.
Quoted 7 lines
Quoted 2 lines
Avoid this by setting NAPI_GRO_CB(skb)->flush for GSO skbs before aggregation.
I don't think we can do this. For
GRO_HWdevices re-aggregating in SW is quite helpful, HW often runs out of contexts or times out too soon, generating skbs with 16kB..32kB of data, the SW can help bring it up to full TSO.
Also, after e751256486d0 ("net: gro: fix double aggregation of flush-marked skbs"), it's not clear an another bug remains.
If it is: as said "nested GRO" of hw + sw GRO is intentional, e.g., for BIG-TCP.
But it may not be anticipated for skb_gro_receive_list. One option would be to skip the fraglist GSO optimization for such packets.
First I'd like to understand better what exact bug remains.
Quoted 10 lines · Willem de Bruijn
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 23 Jul 2026 17:16:01 +0800 [email protected] wrote:
From: HW He <[email protected]>
On devices that support both
NETIF_F_GRO_HWandNETIF_F_GRO_FRAGLIST,"devices that support FRAGLIST"? Isn't it a software feature?
Sorry for not making it clear. The test environment is:
device supports GRO_HW, and enable NETIF_F_GRO_FRAGLIST in driver.
Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
the hardware or driver may deliver packets that have already been
If you have a driver in mind please name it.
Quoted 9 lines
aggregated into a TCP GSO skb with frags[]. GRO may then aggregate the skb again in
skb_gro_receive_list().This can create a nested GSO skb, which is not handled correctly by the
later GSO segmentation paths. When the skb is segmented byskb_segment_list(), it not be fully restored to the original packets.
Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Avoid this by setting NAPI_GRO_CB(skb)->flush for GSO skbs before aggregation.
I don't think we can do this. For
GRO_HWdevices re-aggregating in SW is quite helpful, HW often runs out of contexts or times out too soon, generating skbs with 16kB..32kB of data, the SW can help bring it up to full TSO.
I'll try to explain this issue below.
Quoted 11 lines
Also, after
e751256486d0("net: gro: fix double aggregation of flush-marked skbs"), it's not clear an another bug remains.If it is: as said "nested GRO" of hw + sw GRO is intentional, e.g., for BIG-TCP.
But it may not be anticipated for
skb_gro_receive_list. One option would be to skip the fraglist GSO optimization for such packets.First I'd like to understand better what exact bug remains.
I agree that re-aggregation is useful for improving GRO efficiency.
However, as a general rule, a GSO skb must be segment back to the exact original packets stream. In tethering test, skb_segment_list() cannot correctly segment a nested GSO skb produced by this path.
This issue can reproduce in the following scenario:
1.Driver submits a single TCP packet, P1. P1 is kept in the gro_list as the first packet.
2. The driver submits a TCP GSO skb, P2. P2 has already aggregated multiple TCP packets by HW_GRO, and its non-linear data is stored in frags[].
3. P1 and P2 match the GRO rules, and since there is no local socket, they are aggregated by skb_gro_receive_list(). The resulting skb, P3, has a frag_list entry that still contains frags[]:
P3: [ Linear Data ] -> frag_list -> [ Linear Data ]
[ frag[1] ]
[ frag[2] ]
...4. Later, tcp4_gso_segment() or tcp6_gso_segment() calls skb_segment_list() to segment P3. However, skb_segment_list() only segments the entries in frag_list. It does not segment the frags[] inside P2, so P3 is not restored to the original packets, which leads to IP fragmentation or packet drop in the following path.
The patch only prevents that nested case before skb_gro_receive_list() aggregation. It does not affect packets that are re-aggregated by skb_gro_receive().
Quoted 50 lines · Zhaoping Shu (舒召平)
Quoted 10 lines · Willem de Bruijn
Quoted 8 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 23 Jul 2026 17:16:01 +0800 [email protected] wrote:
From: HW He <[email protected]>
On devices that support both
NETIF_F_GRO_HWandNETIF_F_GRO_FRAGLIST,"devices that support FRAGLIST"? Isn't it a software feature?
Sorry for not making it clear. The test environment is:
device supportsGRO_HW, and enableNETIF_F_GRO_FRAGLISTin driver.Quoted 14 lines
Quoted 14 lines
Quoted 2 lines
the hardware or driver may deliver packets that have already been
If you have a driver in mind please name it.
Quoted 9 lines
aggregated into a TCP GSO skb with frags[]. GRO may then aggregate the skb again in
skb_gro_receive_list().This can create a nested GSO skb, which is not handled correctly by the
later GSO segmentation paths. When the skb is segmented byskb_segment_list(), it not be fully restored to the original packets.Quoted 7 lines
Quoted 7 lines
Quoted 2 lines
Avoid this by setting NAPI_GRO_CB(skb)->flush for GSO skbs before aggregation.
I don't think we can do this. For
GRO_HWdevices re-aggregating in SW is quite helpful, HW often runs out of contexts or times out too soon, generating skbs with 16kB..32kB of data, the SW can help bring it up to full TSO.I'll try to explain this issue below.
Quoted 10 lines
Also, after
e751256486d0("net: gro: fix double aggregation of flush-marked skbs"), it's not clear an another bug remains.If it is: as said "nested GRO" of hw + sw GRO is intentional, e.g., for BIG-TCP.
But it may not be anticipated for
skb_gro_receive_list. One option would be to skip the fraglist GSO optimization for such packets.
Quoted 7 lines
Quoted 1 line
First I'd like to understand better what exact bug remains.
I agree that re-aggregation is useful for improving GRO efficiency.
However, as a general rule, a GSO skb must be segment back to the exact original packets stream. In tethering test,
skb_segment_list()cannot correctly segment a nested GSO skb produced by this path.
So the specific issue is a driver that builds a regular (HW) GSO packet followed by software GSO that uses fraglist?
Then I see three paths to fixing this
1. decline to further apply SW GRO if skb is GSO and in fraglist mode
2. if in fraglist mode, further apply SW GRO, but do not use fraglist
3. in skb_segment_list detect this case and fall back onto skb_segment
We already apply option 3 to various cases where skb_segment_list cannot handle complex use-cases of fraglist.
This patch chooses option 1, which is fine. Alternatively it could fall through to the regular skb_gro_receive path below.
Quoted 22 lines
This issue can reproduce in the following scenario:
1.Driver submits a single TCP packet, P1. P1 is kept in thegro_listas the first packet.2. The driver submits a TCP GSO skb, P2. P2 has already aggregated multiple TCP packets by
HW_GRO, and its non-linear data is stored in frags[].3. P1 and P2 match the GRO rules, and since there is no local socket, they are aggregated by
skb_gro_receive_list(). The resulting skb, P3, has afrag_listentry that still contains frags[]:
P3: [ Linear Data ] ->frag_list-> [ Linear Data ][ frag[1] ] [ frag[2] ] ...4. Later,
tcp4_gso_segment()ortcp6_gso_segment()callsskb_segment_list()to segment P3. However,skb_segment_list()only segments the entries infrag_list. It does not segment the frags[] inside P2, so P3 is not restored to the original packets, which leads to IP fragmentation or packet drop in the following path.
Quoted 3 lines
The patch only prevents that nested case before
skb_gro_receive_list()aggregation. It does not affect packets that are re-aggregated byskb_gro_receive().
Thanks for the detailed explanation.
Quoted 80 lines · Willem de Bruijn
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 56 lines · Zhaoping Shu (舒召平)
Quoted 11 lines · Willem de Bruijn
Quoted 9 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 23 Jul 2026 17:16:01 +0800 [email protected] wrote:
From: HW He <[email protected]>
On devices that support both
NETIF_F_GRO_HWandNETIF_F_GRO_FRAGLIST,"devices that support FRAGLIST"? Isn't it a software feature?
Sorry for not making it clear. The test environment is:
device supportsGRO_HW, and enableNETIF_F_GRO_FRAGLISTin driver.Quoted 16 lines
Quoted 16 lines
Quoted 3 lines
the hardware or driver may deliver packets that have already been
If you have a driver in mind please name it.
Quoted 10 lines
aggregated into a TCP GSO skb with frags[]. GRO may then aggregate the skb again in
skb_gro_receive_list().This can create a nested GSO skb, which is not handled correctly
by the
later GSO segmentation paths. When the skb is segmented byskb_segment_list(), it not be fully restored to the original packets.Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Avoid this by setting NAPI_GRO_CB(skb)->flush for GSO skbs before
aggregation.I don't think we can do this. For
GRO_HWdevices re-aggregating in SW is quite helpful, HW often runs out of contexts or times out too soon, generating skbs with 16kB..32kB of data, the SW can help bring it up to full TSO.I'll try to explain this issue below.
Quoted 12 lines
Also, after
e751256486d0("net: gro: fix double aggregation of flush-marked skbs"), it's not clear an another bug remains.If it is: as said "nested GRO" of hw + sw GRO is intentional, e.g.,
for BIG-TCP.But it may not be anticipated for
skb_gro_receive_list. One option
would be to skip the fraglist GSO optimization for such packets.Quoted 8 lines
Quoted 1 line
First I'd like to understand better what exact bug remains.
I agree that re-aggregation is useful for improving GRO efficiency.
However, as a general rule, a GSO skb must be segment back to the exact original packets stream. In tethering test,
skb_segment_list()
cannot correctly segment a nested GSO skb produced by this path.So the specific issue is a driver that builds a regular (HW) GSO packet followed by software GSO that uses fraglist?
Then I see three paths to fixing this
1. decline to further apply SW GRO if skb is GSO and in fraglist mode
2. if in fraglist mode, further apply SW GRO, but do not use fraglist
3. inskb_segment_listdetect this case and fall back ontoskb_segment
Quoted 6 lines
We already apply option 3 to various cases where
skb_segment_listcannot handle complex use-cases of fraglist.This patch chooses option 1, which is fine. Alternatively it could fall through to the regular
skb_gro_receivepath below.
Thanks for the feedback.
Patch (option 1) is a minimal fix for the reported issue.
For the other options, my initial thought is to handle this in tcp4_check_fraglist_gro()/tcp6_check_fraglist_gro(): if the netdev has both NETIF_F_GRO_HW and NETIF_F_GRO_FRAGLIST enabled, do not set NAPI_GRO_CB(skb)->is_flist, so that this tethering/forwarding case can keep using SW GRO and fall through to the regular skb_gro_receive() path instead of skb_gro_receive_list().
If that direction makes sense, I can work on it,
or send a follow-up patch to fix the reported issue with option 1.
Quoted 33 lines
Quoted 25 lines
This issue can reproduce in the following scenario:
1.Driver submits a single TCP packet, P1. P1 is kept in thegro_listas the first packet.2. The driver submits a TCP GSO skb, P2. P2 has already aggregated multiple TCP packets by
HW_GRO, and its non-linear data is stored in
frags[].3. P1 and P2 match the GRO rules, and since there is no local socket,
they are aggregated byskb_gro_receive_list(). The resulting skb, P3, has afrag_listentry that still contains frags[]:
P3: [ Linear Data ] ->frag_list-> [ Linear Data ][ frag[1] ] [ frag[2] ] ...4. Later,
tcp4_gso_segment()ortcp6_gso_segment()callsskb_segment_list()to segment P3. However,skb_segment_list()only segments the entries infrag_list. It does not segment the frags[] inside P2, so P3 is not restored to the original packets, which leads
to IP fragmentation or packet drop in the following path.Quoted 4 lines
The patch only prevents that nested case before
skb_gro_receive_list()
aggregation. It does not affect packets that are re-aggregated byskb_gro_receive().Thanks for the detailed explanation.
Quoted 84 lines · Zhaoping Shu (舒召平)
Quoted 83 lines · Willem de Bruijn
External email : Please do not click links or open attachments until you have verified the sender or the content.
Quoted 56 lines · Zhaoping Shu (舒召平)
Quoted 11 lines · Willem de Bruijn
Quoted 9 lines · Jakub Kicinski
Quoted 4 lines · On Thu, 23 Jul 2026 17:16:01 +0800 [email protected] wrote:
From: HW He <[email protected]>
On devices that support both
NETIF_F_GRO_HWandNETIF_F_GRO_FRAGLIST,"devices that support FRAGLIST"? Isn't it a software feature?
Sorry for not making it clear. The test environment is:
device supportsGRO_HW, and enableNETIF_F_GRO_FRAGLISTin driver.Quoted 16 lines
Quoted 16 lines
Quoted 3 lines
the hardware or driver may deliver packets that have already been
If you have a driver in mind please name it.
Quoted 10 lines
aggregated into a TCP GSO skb with frags[]. GRO may then aggregate the skb again in
skb_gro_receive_list().This can create a nested GSO skb, which is not handled correctly
by the
later GSO segmentation paths. When the skb is segmented byskb_segment_list(), it not be fully restored to the original packets.Quoted 8 lines
Quoted 8 lines
Quoted 3 lines
Avoid this by setting NAPI_GRO_CB(skb)->flush for GSO skbs before
aggregation.I don't think we can do this. For
GRO_HWdevices re-aggregating in SW is quite helpful, HW often runs out of contexts or times out too soon, generating skbs with 16kB..32kB of data, the SW can help bring it up to full TSO.I'll try to explain this issue below.
Quoted 12 lines
Also, after
e751256486d0("net: gro: fix double aggregation of flush-marked skbs"), it's not clear an another bug remains.If it is: as said "nested GRO" of hw + sw GRO is intentional, e.g.,
for BIG-TCP.But it may not be anticipated for
skb_gro_receive_list. One option
would be to skip the fraglist GSO optimization for such packets.Quoted 8 lines
Quoted 1 line
First I'd like to understand better what exact bug remains.
I agree that re-aggregation is useful for improving GRO efficiency.
However, as a general rule, a GSO skb must be segment back to the exact original packets stream. In tethering test,
skb_segment_list()
cannot correctly segment a nested GSO skb produced by this path.So the specific issue is a driver that builds a regular (HW) GSO packet followed by software GSO that uses fraglist?
Then I see three paths to fixing this
1. decline to further apply SW GRO if skb is GSO and in fraglist mode
2. if in fraglist mode, further apply SW GRO, but do not use fraglist
3. inskb_segment_listdetect this case and fall back ontoskb_segmentWe already apply option 3 to various cases where
skb_segment_listcannot handle complex use-cases of fraglist.
Quoted 7 lines
Quoted 3 lines
This patch chooses option 1, which is fine. Alternatively it could fall through to the regular
skb_gro_receivepath below.Thanks for the feedback.
Patch (option 1) is a minimal fix for the reported issue.
And that would be sufficient.
Quoted 6 lines
For the other options, my initial thought is to handle this in tcp4_check_fraglist_gro()/tcp6_check_fraglist_gro(): if the netdev has both
NETIF_F_GRO_HWandNETIF_F_GRO_FRAGLISTenabled, do not set NAPI_GRO_CB(skb)->is_flist, so that this tethering/forwarding case can keep using SW GRO and fall through to the regularskb_gro_receive()path instead ofskb_gro_receive_list().
Yes, that sounds good. And then the above option 1 is not needed.
No HW-GRO implementation generates fraglist GRO packets, so the two are fundamentally at odds anyway.
Ignoring the fraglist hint for HW-GRO skbs sounds good to me, thanks.
Quoted 37 lines
If that direction makes sense, I can work on it,
or send a follow-up patch to fix the reported issue with option 1.Quoted 33 lines
Quoted 25 lines
This issue can reproduce in the following scenario:
1.Driver submits a single TCP packet, P1. P1 is kept in thegro_listas the first packet.2. The driver submits a TCP GSO skb, P2. P2 has already aggregated multiple TCP packets by
HW_GRO, and its non-linear data is stored in
frags[].3. P1 and P2 match the GRO rules, and since there is no local socket,
they are aggregated byskb_gro_receive_list(). The resulting skb, P3, has afrag_listentry that still contains frags[]:
P3: [ Linear Data ] ->frag_list-> [ Linear Data ][ frag[1] ] [ frag[2] ] ...4. Later,
tcp4_gso_segment()ortcp6_gso_segment()callsskb_segment_list()to segment P3. However,skb_segment_list()only segments the entries infrag_list. It does not segment the frags[] inside P2, so P3 is not restored to the original packets, which leads
to IP fragmentation or packet drop in the following path.Quoted 4 lines
The patch only prevents that nested case before
skb_gro_receive_list()
aggregation. It does not affect packets that are re-aggregated byskb_gro_receive().Thanks for the detailed explanation.