netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net/mlx4_en: Fix endianness bug in IPV6 csum calculation
@ 2016-05-04 12:00 Tariq Toukan
  2016-05-06  3:27 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Tariq Toukan @ 2016-05-04 12:00 UTC (permalink / raw)
  To: David S. Miller; +Cc: netdev, Daniel Jurgens, Tariq Toukan

From: Daniel Jurgens <danielj@mellanox.com>

Use htons instead of unconditionally byte swapping nexthdr.  On a little
endian systems shifting the byte is correct behavior, but it results in
incorrect csums on big endian architectures.

Fixes: f8c6455bb04b ('net/mlx4_en: Extend checksum offloading by CHECKSUM COMPLETE')
Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
Reviewed-by: Carol Soto <clsoto@us.ibm.com>
Tested-by: Carol Soto <clsoto@us.ibm.com>
Signed-off-by: Tariq Toukan <tariqt@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_rx.c b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
index b723e3b..ca3a384 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_rx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_rx.c
@@ -707,7 +707,7 @@ static int get_fixed_ipv6_csum(__wsum hw_checksum, struct sk_buff *skb,
 
 	if (ipv6h->nexthdr == IPPROTO_FRAGMENT || ipv6h->nexthdr == IPPROTO_HOPOPTS)
 		return -1;
-	hw_checksum = csum_add(hw_checksum, (__force __wsum)(ipv6h->nexthdr << 8));
+	hw_checksum = csum_add(hw_checksum, (__force __wsum)htons(ipv6h->nexthdr));
 
 	csum_pseudo_hdr = csum_partial(&ipv6h->saddr,
 				       sizeof(ipv6h->saddr) + sizeof(ipv6h->daddr), 0);
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH net] net/mlx4_en: Fix endianness bug in IPV6 csum calculation
  2016-05-04 12:00 [PATCH net] net/mlx4_en: Fix endianness bug in IPV6 csum calculation Tariq Toukan
@ 2016-05-06  3:27 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2016-05-06  3:27 UTC (permalink / raw)
  To: tariqt; +Cc: netdev, danielj

From: Tariq Toukan <tariqt@mellanox.com>
Date: Wed,  4 May 2016 15:00:33 +0300

> From: Daniel Jurgens <danielj@mellanox.com>
> 
> Use htons instead of unconditionally byte swapping nexthdr.  On a little
> endian systems shifting the byte is correct behavior, but it results in
> incorrect csums on big endian architectures.
> 
> Fixes: f8c6455bb04b ('net/mlx4_en: Extend checksum offloading by CHECKSUM COMPLETE')
> Signed-off-by: Daniel Jurgens <danielj@mellanox.com>
> Reviewed-by: Carol Soto <clsoto@us.ibm.com>
> Tested-by: Carol Soto <clsoto@us.ibm.com>
> Signed-off-by: Tariq Toukan <tariqt@mellanox.com>

Applied and queued up for -stable, thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-05-06  3:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-05-04 12:00 [PATCH net] net/mlx4_en: Fix endianness bug in IPV6 csum calculation Tariq Toukan
2016-05-06  3:27 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).