Skip to contentSkip to conversation

net: sparx5: fix handling uneven length packets in manual extraction

PATCH Applied Casper Andersson 3 participants 3 messages Aug 25, 2022 – Aug 27, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: sparx5: fix handling uneven length packets in manual extraction

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")
---
 drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/net/ethernet/microchip/sparx5/sparx5_packet.c +2 -0
index 304f84aadc36..21844beba72d 100644
@@ -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;
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi Casper,

Good Catch.

Quoted 28 lines · Casper Andersson

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

---
 drivers/net/ethernet/microchip/sparx5/sparx5_packet.c | 2 ++

 1 file changed, 2 insertions(+)
drivers/net/ethernet/microchip/sparx5/sparx5_packet.c +2 -1
index 304f84aadc36..21844beba72d 100644
@@ -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;
--
Quoted 2 lines

2.34.1

Signature · 5 lines
Best Regards
Steen

-=-=-=-=-=-=-=-=-=-=-=-=-=-=
[email protected]
#2 lore raw
In reply to Casper Andersson
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · 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")

[...]

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!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html