net: Clear old fragment checksum value in napi_reuse_skb
Subsystems (2)
PATCH v3 1/1 net: Clear old fragment checksum value in napi_reuse_skb
In certain cases, napi_get_frags() returns an skb that points to an old received fragment, This skb may have its skb->ip_summed, csum, and other fields set from previous fragment handling.
Some network drivers set skb->ip_summed to either CHECKSUM_COMPLETE or CHECKSUM_UNNECESSARY when getting skb from napi_get_frags(), while others only set skb->ip_summed when RX checksum offload is enabled on the device, and do not set any value for skb->ip_summed when hardware checksum offload is disabled, assuming that the skb->ip_summed initiated to zero by napi_reuse_skb, ionic driver for example will ignore/unset any value for the ip_summed filed if HW checksum offload is disabled, and if we have a situation where the user disables the checksum offload during a traffic that could lead to the following errors shown in the kernel logs:
<IRQ> dump_stack_lvl+0x34/0x48 __skb_gro_checksum_complete+0x7e/0x90 tcp6_gro_receive+0xc6/0x190 ipv6_gro_receive+0x1ec/0x430 dev_gro_receive+0x188/0x360 ? ionic_rx_clean+0x25a/0x460 [ionic] napi_gro_frags+0x13c/0x300 ? __pfx_ionic_rx_service+0x10/0x10 [ionic] ionic_rx_service+0x67/0x80 [ionic] ionic_cq_service+0x58/0x90 [ionic] ionic_txrx_napi+0x64/0x1b0 [ionic] __napi_poll+0x27/0x170 net_rx_action+0x29c/0x370 handle_softirqs+0xce/0x270 __irq_exit_rcu+0xa3/0xc0 common_interrupt+0x80/0xa0 </IRQ>
This inconsistency sometimes leads to checksum validation issues in the upper layers of the network stack.
To resolve this, this patch clears the skb->ip_summed value for each reused skb in by napi_reuse_skb(), ensuring that the caller is responsible for setting the correct checksum status. This eliminates potential checksum validation issues caused by improper handling of skb->ip_summed.
--- net/core/gro.c | 1 + 1 file changed, 1 insertion(+)
net/core/gro.c +1 -0
@@ -653,6 +653,7 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) skb->pkt_type =PACKET_HOST ; skb->encapsulation =0 ; + skb->ip_summed =CHECKSUM_NONE ;skb_shinfo (skb)->gso_type =0 ;skb_shinfo (skb)->gso_size =0 ;if (unlikely (skb->slow_gro)) {
Signature · 1 line
2.48.1
Quoted 37 lines · Mohammad Heib
In certain cases,
napi_get_frags()returns an skb that points to an old received fragment, This skb may have itsskb->ip_summed, csum, and other fields set from previous fragment handling.Some network drivers set
skb->ip_summedto eitherCHECKSUM_COMPLETEorCHECKSUM_UNNECESSARYwhen getting skb fromnapi_get_frags(), while others only setskb->ip_summedwhen RX checksum offload is enabled on the device, and do not set any value forskb->ip_summedwhen hardware checksum offload is disabled, assuming that theskb->ip_summedinitiated to zero bynapi_reuse_skb, ionic driver for example will ignore/unset any value for theip_summedfiled if HW checksum offload is disabled, and if we have a situation where the user disables the checksum offload during a traffic that could lead to the following errors shown in the kernel logs:<IRQ> dump_stack_lvl+0x34/0x48 __skb_gro_checksum_complete+0x7e/0x90 tcp6_gro_receive+0xc6/0x190 ipv6_gro_receive+0x1ec/0x430 dev_gro_receive+0x188/0x360 ? ionic_rx_clean+0x25a/0x460 [ionic] napi_gro_frags+0x13c/0x300 ? __pfx_ionic_rx_service+0x10/0x10 [ionic] ionic_rx_service+0x67/0x80 [ionic] ionic_cq_service+0x58/0x90 [ionic] ionic_txrx_napi+0x64/0x1b0 [ionic] __napi_poll+0x27/0x170 net_rx_action+0x29c/0x370 handle_softirqs+0xce/0x270 __irq_exit_rcu+0xa3/0xc0 common_interrupt+0x80/0xa0 </IRQ>This inconsistency sometimes leads to checksum validation issues in the upper layers of the network stack.
Quoted 8 lines
To resolve this, this patch clears the
skb->ip_summedvalue for each reused skb in bynapi_reuse_skb(), ensuring that the caller is responsible for setting the correct checksum status. This eliminates potential checksum validation issues caused by improper handling ofskb->ip_summed.Fixes 76620aafd66f ("gro: New frags interface to avoid copying shinfo")Signed-off-by Mohammad Heib <[email protected]>
Thanks!
Quoted 20 lines
--- net/core/gro.c | 1 + 1 file changed, 1 insertion(+)net/core/gro.c +1
-1@@ -653,6 +653,7 @@ static void napi_reuse_skb(struct napi_struct *napi, struct sk_buff *skb) skb->pkt_type =PACKET_HOST ; skb->encapsulation =0 ; + skb->ip_summed =CHECKSUM_NONE ;skb_shinfo (skb)->gso_type =0 ;skb_shinfo (skb)->gso_size =0 ;if (unlikely (skb->slow_gro)) { --2.48.1
Quoted 5 lines · Mohammad Heib
In certain cases,
napi_get_frags()returns an skb that points to an old received fragment, This skb may have itsskb->ip_summed, csum, and other fields set from previous fragment handling.
Quoted 10 lines
Some network drivers set
skb->ip_summedto eitherCHECKSUM_COMPLETEorCHECKSUM_UNNECESSARYwhen getting skb fromnapi_get_frags(), while others only setskb->ip_summedwhen RX checksum offload is enabled on the device, and do not set any value forskb->ip_summedwhen hardware checksum offload is disabled, assuming that theskb->ip_summedinitiated to zero bynapi_reuse_skb, ionic driver for example will ignore/unset any value for theip_summedfiled if HW checksum offload is disabled, and if we have a situation where the user disables the checksum offload during a traffic that could lead to the following errors shown in the kernel logs:
It would be nice if you could get symbols with this trace ( scripts/decode_stacktrace.sh )
Quoted 10 lines
<IRQ> dump_stack_lvl+0x34/0x48 __skb_gro_checksum_complete+0x7e/0x90 tcp6_gro_receive+0xc6/0x190 ipv6_gro_receive+0x1ec/0x430 dev_gro_receive+0x188/0x360 ? ionic_rx_clean+0x25a/0x460 [ionic] napi_gro_frags+0x13c/0x300 ? __pfx_ionic_rx_service+0x10/0x10 [ionic] ionic_rx_service+0x67/0x80 [ionic]
Quoted 9 lines
ionic_cq_service+0x58/0x90 [ionic] ionic_txrx_napi+0x64/0x1b0 [ionic] __napi_poll+0x27/0x170 net_rx_action+0x29c/0x370 handle_softirqs+0xce/0x270 __irq_exit_rcu+0xa3/0xc0 common_interrupt+0x80/0xa0 </IRQ>
Note : This suggests ionic driver could add oneskb_checksum_none_assert() as other drivers did
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 33 lines · On Tue, 25 Feb 2025 13:28:52 +0200 you wrote:
In certain cases,
napi_get_frags()returns an skb that points to an old received fragment, This skb may have itsskb->ip_summed, csum, and other fields set from previous fragment handling.Some network drivers set
skb->ip_summedto eitherCHECKSUM_COMPLETEorCHECKSUM_UNNECESSARYwhen getting skb fromnapi_get_frags(), while others only setskb->ip_summedwhen RX checksum offload is enabled on the device, and do not set any value forskb->ip_summedwhen hardware checksum offload is disabled, assuming that theskb->ip_summedinitiated to zero bynapi_reuse_skb, ionic driver for example will ignore/unset any value for theip_summedfiled if HW checksum offload is disabled, and if we have a situation where the user disables the checksum offload during a traffic that could lead to the following errors shown in the kernel logs:<IRQ> dump_stack_lvl+0x34/0x48 __skb_gro_checksum_complete+0x7e/0x90 tcp6_gro_receive+0xc6/0x190 ipv6_gro_receive+0x1ec/0x430 dev_gro_receive+0x188/0x360 ? ionic_rx_clean+0x25a/0x460 [ionic] napi_gro_frags+0x13c/0x300 ? __pfx_ionic_rx_service+0x10/0x10 [ionic] ionic_rx_service+0x67/0x80 [ionic] ionic_cq_service+0x58/0x90 [ionic] ionic_txrx_napi+0x64/0x1b0 [ionic] __napi_poll+0x27/0x170 net_rx_action+0x29c/0x370 handle_softirqs+0xce/0x270 __irq_exit_rcu+0xa3/0xc0 common_interrupt+0x80/0xa0 </IRQ>
Quoted 1 line
[...]
Here is the summary with links:
- [net,v3] net: Clear old fragment checksum value in napi_reuse_skb
https://git.kernel.org/netdev/net/c/49806fe6e61b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html