ice: iavf: fix USO for 32-bit systems
Subsystems (2)
cover ice: iavf: fix USO for 32-bit systems
That USO works on these two cards for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using sizeof() a pointer instead of the sizeof() the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by using sizeof() the UDP header that the pointer points to instead.
This was found by an LLM while implementing something else that used USO.
v1: https://lore.kernel.org/netdev/[email protected]/
v1 -> v2:
- add missing prefixes on Fixes line (Eric)
- collected Reviewed-by tags from Eric and Maciej
Magnus Karlsson (2):
ice: fix USO for 32-bit systems
iavf: fix USO for 32-bit systems
drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
Signature · 1 line
2.38.1
PATCH 1/2 ice: fix USO for 32-bit systems
That USO works for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using sizeof() a pointer instead of the sizeof() the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by using sizeof() the UDP header that the pointer points to instead.
This was found by an LLM while implementing something else that used USO.
--- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_txrx.c +1 -1
@@ -1925,7 +1925,7 @@ int ice_tso(struct ice_tx_buf *first, struct ice_tx_offload_params *off)csum_replace_by_diff (&l4.udp->check, (__force __wsum )htonl (paylen));/* compute length of UDP segmentation header */ - off->header_len = (u8 )sizeof (l4.udp) + l4_start; + off->header_len =sizeof (*l4.udp) + l4_start; }else {csum_replace_by_diff (&l4.tcp->check, (__force __wsum )htonl (paylen));
Signature · 1 line
2.38.1
RE: [PATCH iwl-net 1/2] ice: fix USO for 32-bit systems
Quoted 46 lines
-----Original Message-----
From: Magnus Karlsson <[email protected]>
Sent: Thursday, October 29, 2026 11:02 AM
To: Karlsson, Magnus <[email protected]>; intel-wired- [email protected]; Nguyen, Anthony L <[email protected]>; Fijalkowski, Maciej <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: Eric Dumazet <[email protected]>
Subject: [PATCH iwl-net 1/2] ice: fix USO for 32-bit systemsThat USO works for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using
sizeof()a pointer instead of thesizeof()the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by usingsizeof()the UDP header that the pointer points to instead.This was found by an LLM while implementing something else that used USO.
Fixes a54e3b8cffd6 ("ice: Support UDP segmentation offload")Reviewed-by Eric Dumazet <[email protected]>Reviewed-by Maciej Fijalkowski <[email protected]>Signed-off-by Magnus Karlsson <[email protected]>--- drivers/net/ethernet/intel/ice/ice_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/ice/ice_txrx.c +1
-1@@ -1925,7 +1925,7 @@ int ice_tso(struct ice_tx_buf *first, struct ice_tx_offload_params *off) csum_replace_by_diff(&l4.udp->check, (__force __wsum)htonl(paylen));/* compute length of UDP segmentation header */ - off->header_len = (u8 )sizeof (l4.udp) + l4_start; + off->header_len =sizeof (*l4.udp) + l4_start; }else { csum_replace_by_diff(&l4.tcp->check,
Quoted 3 lines
(
__force__wsum)htonl(paylen));
--
2.38.1
PATCH 2/2 iavf: fix USO for 32-bit systems
In reply to Magnus KarlssonThat USO works for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using sizeof() a pointer instead of the sizeof() the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by using sizeof() the UDP header that the pointer points to instead.
This was found by an LLM while implementing something else that used USO.
--- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/iavf/iavf_txrx.c +1 -1
@@ -1807,7 +1807,7 @@ static int iavf_tso(struct iavf_tx_buffer *first, u8 *hdr_len,csum_replace_by_diff (&l4.udp->check, (__force __wsum )htonl (paylen));/* compute length of UDP segmentation header */ - *hdr_len = (u8 )sizeof (l4.udp) + l4_offset; + *hdr_len =sizeof (*l4.udp) + l4_offset; }else {csum_replace_by_diff (&l4.tcp->check, (__force __wsum )htonl (paylen));
Signature · 1 line
2.38.1
RE: [PATCH iwl-net 2/2] iavf: fix USO for 32-bit systems
Quoted 46 lines
-----Original Message-----
From: Magnus Karlsson <[email protected]>
Sent: Thursday, October 29, 2026 11:02 AM
To: Karlsson, Magnus <[email protected]>; intel-wired- [email protected]; Nguyen, Anthony L <[email protected]>; Fijalkowski, Maciej <[email protected]>; Kitszel, Przemyslaw <[email protected]>
Cc: Eric Dumazet <[email protected]>
Subject: [PATCH iwl-net 2/2] iavf: fix USO for 32-bit systemsThat USO works for 64-bit systems is just pure luck. Currently, the computation of the UDP segmentation header is performed using
sizeof()a pointer instead of thesizeof()the UDP header that the pointer points to. Since the UDP header happens to be 8 bytes long and a pointer is 8 bytes long on a 64-bit system, this works on all those systems. But no such luck for anyone using a 32-bit system as 8 bytes != 4 bytes. So fix this by usingsizeof()the UDP header that the pointer points to instead.This was found by an LLM while implementing something else that used USO.
Fixes c91a4f9feb67 ("iavf: add support for UDP Segmentation Offload")Reviewed-by Eric Dumazet <[email protected]>Reviewed-by Maciej Fijalkowski <[email protected]>Signed-off-by Magnus Karlsson <[email protected]>--- drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/ethernet/intel/iavf/iavf_txrx.c +1
-1@@ -1807,7 +1807,7 @@ static int iavf_tso(struct iavf_tx_buffer *first, u8 *hdr_len,csum_replace_by_diff (&l4.udp->check, (__force __wsum )htonl (paylen));/* compute length of UDP segmentation header */ - *hdr_len = (u8 )sizeof (l4.udp) + l4_offset; + *hdr_len =sizeof (*l4.udp) + l4_offset; }else { csum_replace_by_diff(&l4.tcp->check,
Quoted 3 lines
(
__force__wsum)htonl(paylen));
--
2.38.1