netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: sparx5: fix handling uneven length packets in manual extraction
@ 2022-08-25  8:49 Casper Andersson
  2022-08-26  9:27 ` Steen Hegelund
  2022-08-27  0:30 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Casper Andersson @ 2022-08-25  8:49 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Lars Povlsen, Steen Hegelund, UNGLinuxDriver, Bjarni Jonasson,
	netdev

Packets that are not of length divisible by 4 (e.g. 77, 78, 79) would
have the checksum included up to next multiple of 4 (a 77 bytes packet
would have 3 bytes of ethernet checksum included). The check for the
value expects it in host (Little) endian.

Fixes: f3cad2611a77 ("net: sparx5: add hostmode with phylink support")
Signed-off-by: Casper Andersson <casper.casan@gmail.com>
---
 drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
index 304f84aadc36..21844beba72d 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
@@ -113,6 +113,8 @@ static void sparx5_xtr_grp(struct sparx5 *sparx5, u8 grp, bool byte_swap)
 			/* This assumes STATUS_WORD_POS == 1, Status
 			 * just after last data
 			 */
+			if (!byte_swap)
+				val = ntohl((__force __be32)val);
 			byte_cnt -= (4 - XTR_VALID_BYTES(val));
 			eof_flag = true;
 			break;
-- 
2.34.1


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

* Re: [PATCH net] net: sparx5: fix handling uneven length packets in manual extraction
  2022-08-25  8:49 [PATCH net] net: sparx5: fix handling uneven length packets in manual extraction Casper Andersson
@ 2022-08-26  9:27 ` Steen Hegelund
  2022-08-27  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Steen Hegelund @ 2022-08-26  9:27 UTC (permalink / raw)
  To: Casper Andersson, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni
  Cc: Lars Povlsen, UNGLinuxDriver, Bjarni Jonasson, netdev

Hi Casper,

Good Catch.

On Thu, 2022-08-25 at 10:49 +0200, Casper Andersson wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
> 
> Packets that are not of length divisible by 4 (e.g. 77, 78, 79) would
> have the checksum included up to next multiple of 4 (a 77 bytes packet
> would have 3 bytes of ethernet checksum included). The check for the
> value expects it in host (Little) endian.
> 
> Fixes: f3cad2611a77 ("net: sparx5: add hostmode with phylink support")
> Signed-off-by: Casper Andersson <casper.casan@gmail.com>
> ---
>  drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
> b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
> index 304f84aadc36..21844beba72d 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_packet.c
> @@ -113,6 +113,8 @@ static void sparx5_xtr_grp(struct sparx5 *sparx5, u8 grp, bool byte_swap)
>                         /* This assumes STATUS_WORD_POS == 1, Status
>                          * just after last data
>                          */
> +                       if (!byte_swap)
> +                               val = ntohl((__force __be32)val);
>                         byte_cnt -= (4 - XTR_VALID_BYTES(val));
>                         eof_flag = true;
>                         break;
> --
> 2.34.1
> 
Reviewed-by: Steen Hegelund <Steen.Hegelund@microchip.com>

-- 
Best Regards
Steen

-=-=-=-=-=-=-=-=-=-=-=-=-=-=
steen.hegelund@microchip.com


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

* Re: [PATCH net] net: sparx5: fix handling uneven length packets in manual extraction
  2022-08-25  8:49 [PATCH net] net: sparx5: fix handling uneven length packets in manual extraction Casper Andersson
  2022-08-26  9:27 ` Steen Hegelund
@ 2022-08-27  0:30 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-08-27  0:30 UTC (permalink / raw)
  To: Casper Andersson
  Cc: davem, edumazet, kuba, pabeni, lars.povlsen, Steen.Hegelund,
	UNGLinuxDriver, bjarni.jonasson, netdev

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu, 25 Aug 2022 10:49:55 +0200 you wrote:
> Packets that are not of length divisible by 4 (e.g. 77, 78, 79) would
> have the checksum included up to next multiple of 4 (a 77 bytes packet
> would have 3 bytes of ethernet checksum included). The check for the
> value expects it in host (Little) endian.
> 
> Fixes: f3cad2611a77 ("net: sparx5: add hostmode with phylink support")
> Signed-off-by: Casper Andersson <casper.casan@gmail.com>
> 
> [...]

Here is the summary with links:
  - [net] net: sparx5: fix handling uneven length packets in manual extraction
    https://git.kernel.org/netdev/net/c/7498a457ecf7

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-08-27  0:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-25  8:49 [PATCH net] net: sparx5: fix handling uneven length packets in manual extraction Casper Andersson
2022-08-26  9:27 ` Steen Hegelund
2022-08-27  0:30 ` patchwork-bot+netdevbpf

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).