diff mbox series

[iwl-net,2/2] iavf: fix USO for 32-bit systems

Message ID 20261029100159.920118-3-magnus.karlsson@intel.com
State Under Review
Headers show
Series ice: iavf: fix USO for 32-bit systems | expand

Commit Message

Magnus Karlsson Oct. 29, 2026, 10:01 a.m. UTC
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.

Fixes: c91a4f9feb67 ("iavf: add support for UDP Segmentation Offload")
Reviewed-by: Eric Dumazet <edumazet@kernel.org>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
---
 drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Loktionov, Aleksandr Nov. 3, 2026, 10:39 a.m. UTC | #1
> -----Original Message-----
> From: Magnus Karlsson <magnus.karlsson@intel.com>
> Sent: Thursday, October 29, 2026 11:02 AM
> To: Karlsson, Magnus <magnus.karlsson@intel.com>; intel-wired-
> lan@lists.osuosl.org; Nguyen, Anthony L <anthony.l.nguyen@intel.com>;
> Fijalkowski, Maciej <maciej.fijalkowski@intel.com>; Kitszel, Przemyslaw
> <przemyslaw.kitszel@intel.com>
> Cc: Eric Dumazet <edumazet@kernel.org>
> Subject: [PATCH iwl-net 2/2] iavf: 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.
> 
> Fixes: c91a4f9feb67 ("iavf: add support for UDP Segmentation Offload")
> Reviewed-by: Eric Dumazet <edumazet@kernel.org>
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
> ---
>  drivers/net/ethernet/intel/iavf/iavf_txrx.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c
> b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
> index 8982cf75466f..2c290d7788d2 100644
> --- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c
> +++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
> @@ -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));
> --
> 2.38.1

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
diff mbox series

Patch

diff --git a/drivers/net/ethernet/intel/iavf/iavf_txrx.c b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
index 8982cf75466f..2c290d7788d2 100644
--- a/drivers/net/ethernet/intel/iavf/iavf_txrx.c
+++ b/drivers/net/ethernet/intel/iavf/iavf_txrx.c
@@ -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));