]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
net/mlx5e: Fix endianness handling in pedit mask
authorSebastian Hense <sebastian.hense1@ibm.com>
Wed, 6 May 2020 11:40:28 +0000 (13:40 +0200)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Mon, 25 May 2020 08:41:07 +0000 (10:41 +0200)
BugLink: https://bugs.launchpad.net/bugs/1872726
The mask value is provided as 64 bit and has to be casted in
either 32 or 16 bit. On big endian systems the wrong half was
casted which resulted in an all zero mask.

Fixes: 2b64beba0251 ("net/mlx5e: Support header re-write of partial fields in TC pedit offload")
Signed-off-by: Sebastian Hense <sebastian.hense1@ibm.com>
Reviewed-by: Roi Dayan <roid@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
(backported from commit 404402abd5f90aa90a134eb9604b1750c1941529)
Signed-off-by: Frank Heimes <frank.heimes@canonical.com>
Acked-by: Sultan Alsawaf <sultan.alsawaf@canonical.com>
Acked-by: Kleber Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/net/ethernet/mellanox/mlx5/core/en_tc.c

index ec117e4414250bbb61a08891a052fc5c174d66cc..a8817ded2959ecaa0f6666eff6303c59ff09ef7c 100644 (file)
@@ -2424,10 +2424,11 @@ static int offload_pedit_fields(struct pedit_headers_action *hdrs,
                field_bsize = f->size * BITS_PER_BYTE;
 
                if (field_bsize == 32) {
-                       mask_be32 = *(__be32 *)&mask;
+                       mask_be32 = (__be32)mask;
                        mask = (__force unsigned long)cpu_to_le32(be32_to_cpu(mask_be32));
                } else if (field_bsize == 16) {
-                       mask_be16 = *(__be16 *)&mask;
+                       mask_be32 = (__be32)mask;
+                       mask_be16 = *(__be16 *)&mask_be32;
                        mask = (__force unsigned long)cpu_to_le16(be16_to_cpu(mask_be16));
                }