diff mbox series

[v3] net/mlx5: fix wrong segmented packet in Rx

Message ID 1614619190-3846-1-git-send-email-17826875952@163.com (mailing list archive)
State Accepted
Delegated to: Raslan Darawsheh
Headers show
Series [v3] net/mlx5: fix wrong segmented packet in Rx | expand

Checks

Context Check Description
ci/iol-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Jiawei Zhu March 1, 2021, 5:19 p.m. UTC
The issue occurred if mbuf starvation happened
in the middle of segmented packet reception.
In such a situation, after release the segments of
packet being received, code did not advance the
consumer index to the next stride. This caused
the receiving of the wrong segmented packet data.

The possible error scenario:
- we assume segs_n is 4 and we are receiving 4
  segments of multi-segment packet.
- we fail to allocate mbuf while receiving the 3rd segment,
  and this frees the mbufs of the packet chain we have built.
  There are the 1st and 2nd segments in the chain.
- the 1st and the 2nd segments of this stride of Rx queue
  are filled up (in elts array) with the new allocated
  mbufs and their data are random (the 3rd and 4th
  segments still contain the valid data of the packet though).
- on the next iteration of stride processing we get
  the wrong two segments of the multi-segment packet.

Hence, we should skip these mbufs in the stride and
we should advance the consumer index on loop exit.

Fixes: 15a756b63734 ("net/mlx5: fix possible NULL dereference in Rx path")
Cc: stable@dpdk.org

Signed-off-by: Jiawei Zhu <17826875952@163.com>
---
v3:
* Reword the commit message a little bit.

v2:
* Added extra explanation in commit message.
---
 drivers/net/mlx5/mlx5_rxtx.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Viacheslav Ovsiienko March 2, 2021, 5:18 p.m. UTC | #1
> -----Original Message-----
> From: Jiawei Zhu <17826875952@163.com>
> Sent: Monday, March 1, 2021 19:20
> To: dev@dpdk.org
> Cc: zhujiawei12@huawei.com; Matan Azrad <matan@nvidia.com>; Shahaf
> Shuler <shahafs@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>;
> Jiawei Zhu <17826875952@163.com>; stable@dpdk.org
> Subject: [PATCH v3] net/mlx5: fix wrong segmented packet in Rx
> 
> The issue occurred if mbuf starvation happened in the middle of segmented
> packet reception.
> In such a situation, after release the segments of packet being received, code
> did not advance the consumer index to the next stride. This caused the
> receiving of the wrong segmented packet data.
> 
> The possible error scenario:
> - we assume segs_n is 4 and we are receiving 4
>   segments of multi-segment packet.
> - we fail to allocate mbuf while receiving the 3rd segment,
>   and this frees the mbufs of the packet chain we have built.
>   There are the 1st and 2nd segments in the chain.
> - the 1st and the 2nd segments of this stride of Rx queue
>   are filled up (in elts array) with the new allocated
>   mbufs and their data are random (the 3rd and 4th
>   segments still contain the valid data of the packet though).
> - on the next iteration of stride processing we get
>   the wrong two segments of the multi-segment packet.
> 
> Hence, we should skip these mbufs in the stride and we should advance the
> consumer index on loop exit.
> 
> Fixes: 15a756b63734 ("net/mlx5: fix possible NULL dereference in Rx path")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jiawei Zhu <17826875952@163.com>
> ---
> v3:
> * Reword the commit message a little bit.
> 
> v2:
> * Added extra explanation in commit message.
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>

Thank you for the nice catch and working on the patch update.

With best regards, Slava
Raslan Darawsheh March 4, 2021, 9 a.m. UTC | #2
Hi,

> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Jiawei Zhu
> Sent: Monday, March 1, 2021 7:20 PM
> To: dev@dpdk.org
> Cc: zhujiawei12@huawei.com; Matan Azrad <matan@nvidia.com>; Shahaf
> Shuler <shahafs@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>;
> Jiawei Zhu <17826875952@163.com>; stable@dpdk.org
> Subject: [dpdk-dev] [PATCH v3] net/mlx5: fix wrong segmented packet in Rx
> 
> The issue occurred if mbuf starvation happened
> in the middle of segmented packet reception.
> In such a situation, after release the segments of
> packet being received, code did not advance the
> consumer index to the next stride. This caused
> the receiving of the wrong segmented packet data.
> 
> The possible error scenario:
> - we assume segs_n is 4 and we are receiving 4
>   segments of multi-segment packet.
> - we fail to allocate mbuf while receiving the 3rd segment,
>   and this frees the mbufs of the packet chain we have built.
>   There are the 1st and 2nd segments in the chain.
> - the 1st and the 2nd segments of this stride of Rx queue
>   are filled up (in elts array) with the new allocated
>   mbufs and their data are random (the 3rd and 4th
>   segments still contain the valid data of the packet though).
> - on the next iteration of stride processing we get
>   the wrong two segments of the multi-segment packet.
> 
> Hence, we should skip these mbufs in the stride and
> we should advance the consumer index on loop exit.
> 
> Fixes: 15a756b63734 ("net/mlx5: fix possible NULL dereference in Rx path")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Jiawei Zhu <17826875952@163.com>
> ---
> v3:
> * Reword the commit message a little bit.
> 
> v2:
> * Added extra explanation in commit message.
> ---
>  drivers/net/mlx5/mlx5_rxtx.c | 3 +++
>  1 file changed, 3 insertions(+)

Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
Thomas Monjalon March 13, 2021, 7:45 p.m. UTC | #3
> > Signed-off-by: Jiawei Zhu <17826875952@163.com>
> 
> Patch applied to next-net-mlx,

Any specific reason for using your email address @163.com?
Would your huawei address (Cc'ed) fit here?
If you are OK, I prefer recognizing your contributions with a single identity.
diff mbox series

Patch

diff --git a/drivers/net/mlx5/mlx5_rxtx.c b/drivers/net/mlx5/mlx5_rxtx.c
index 2e4b87c..e3ce9fd 100644
--- a/drivers/net/mlx5/mlx5_rxtx.c
+++ b/drivers/net/mlx5/mlx5_rxtx.c
@@ -1480,6 +1480,9 @@  enum mlx5_txcmp_code {
 				rte_mbuf_raw_free(pkt);
 				pkt = rep;
 			}
+			rq_ci >>= sges_n;
+			++rq_ci;
+			rq_ci <<= sges_n;
 			break;
 		}
 		if (!pkt) {