* [dpdk-dev] [PATCH] net/mlx5: fix offset calculation for modify field action
@ 2021-07-05 9:47 Alexander Kozyrev
2021-07-06 12:46 ` Raslan Darawsheh
0 siblings, 1 reply; 2+ messages in thread
From: Alexander Kozyrev @ 2021-07-05 9:47 UTC (permalink / raw)
To: dev; +Cc: stable, rasland, viacheslavo, matan
Offsets are not taken into account during MAC addresses
manipulation for the MODIFY_FIELD action. That leads to
a wrong split between 0-15 and 16-47 bits and corrupted
data being copied to/from MAC addresses. Use both source
and destination offsets to calcucate the proper modify
header action specification.
Fixes: fdd0c046f4 ("net/mlx5: fix modify field action order for MAC")
Cc: stable@dpdk.org
Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index a04a3c2bb8..4ddd3beb33 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -413,6 +413,7 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
{
uint32_t i = resource->actions_num;
struct mlx5_modification_cmd *actions = resource->actions;
+ uint32_t carry_b = 0;
/*
* The item and mask are provided in big-endian format.
@@ -422,8 +423,8 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
MLX5_ASSERT(item->mask);
MLX5_ASSERT(field->size);
do {
- unsigned int size_b;
- unsigned int off_b;
+ uint32_t size_b;
+ uint32_t off_b;
uint32_t mask;
uint32_t data;
bool next_field = true;
@@ -441,7 +442,7 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
continue;
}
/* Deduce actual data width in bits from mask value. */
- off_b = rte_bsf32(mask);
+ off_b = rte_bsf32(mask) + carry_b;
size_b = sizeof(uint32_t) * CHAR_BIT -
off_b - __builtin_clz(mask);
MLX5_ASSERT(size_b);
@@ -463,19 +464,23 @@ flow_dv_convert_modify_action(struct rte_flow_item *item,
* Destination field overflow. Copy leftovers of
* a source field to the next destination field.
*/
- if ((size_b > dcopy->size * CHAR_BIT) && dcopy->size) {
- actions[i].length = dcopy->size * CHAR_BIT;
- field->offset += dcopy->size;
+ carry_b = 0;
+ if ((size_b > dcopy->size * CHAR_BIT - dcopy->offset) &&
+ dcopy->size != 0) {
+ actions[i].length =
+ dcopy->size * CHAR_BIT - dcopy->offset;
+ carry_b = actions[i].length;
next_field = false;
}
/*
* Not enough bits in a source filed to fill a
* destination field. Switch to the next source.
*/
- if (dcopy->size > field->size &&
- (size_b == field->size * CHAR_BIT)) {
- actions[i].length = field->size * CHAR_BIT;
- dcopy->offset += field->size * CHAR_BIT;
+ if ((size_b < dcopy->size * CHAR_BIT - dcopy->offset) &&
+ (size_b == field->size * CHAR_BIT - off_b)) {
+ actions[i].length =
+ field->size * CHAR_BIT - off_b;
+ dcopy->offset += actions[i].length;
next_dcopy = false;
}
if (next_dcopy)
--
2.18.2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] net/mlx5: fix offset calculation for modify field action
2021-07-05 9:47 [dpdk-dev] [PATCH] net/mlx5: fix offset calculation for modify field action Alexander Kozyrev
@ 2021-07-06 12:46 ` Raslan Darawsheh
0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2021-07-06 12:46 UTC (permalink / raw)
To: Alexander Kozyrev, dev; +Cc: stable, Slava Ovsiienko, Matan Azrad
Hi,
> -----Original Message-----
> From: Alexander Kozyrev <akozyrev@nvidia.com>
> Sent: Monday, July 5, 2021 12:47 PM
> To: dev@dpdk.org
> Cc: stable@dpdk.org; Raslan Darawsheh <rasland@nvidia.com>; Slava
> Ovsiienko <viacheslavo@nvidia.com>; Matan Azrad <matan@nvidia.com>
> Subject: [PATCH] net/mlx5: fix offset calculation for modify field action
>
> Offsets are not taken into account during MAC addresses
> manipulation for the MODIFY_FIELD action. That leads to
> a wrong split between 0-15 and 16-47 bits and corrupted
> data being copied to/from MAC addresses. Use both source
> and destination offsets to calcucate the proper modify
> header action specification.
>
> Fixes: fdd0c046f4 ("net/mlx5: fix modify field action order for MAC")
> Cc: stable@dpdk.org
>
> Signed-off-by: Alexander Kozyrev <akozyrev@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-07-06 12:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-05 9:47 [dpdk-dev] [PATCH] net/mlx5: fix offset calculation for modify field action Alexander Kozyrev
2021-07-06 12:46 ` Raslan Darawsheh
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).