diff mbox series

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

Message ID 20220825084955.684637-1-casper.casan@gmail.com (mailing list archive)
State Accepted
Commit 7498a457ecf7ff2c4d379360aa8f24566bb1543e
Delegated to: Netdev Maintainers
Headers show
Series [net] net: sparx5: fix handling uneven length packets in manual extraction | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present success Fixes tag present in non-next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 85 this patch: 85
netdev/cc_maintainers warning 2 maintainers not CCed: linux-arm-kernel@lists.infradead.org horatiu.vultur@microchip.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 85 this patch: 85
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Casper Andersson Aug. 25, 2022, 8:49 a.m. UTC
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(+)

Comments

Steen Hegelund Aug. 26, 2022, 9:27 a.m. UTC | #1
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>
patchwork-bot+netdevbpf@kernel.org Aug. 27, 2022, 12:30 a.m. UTC | #2
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!
diff mbox series

Patch

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;