DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jiawei Zhu <17826875952@163.com>
To: dev@dpdk.org
Cc: zhujiawei12@huawei.com, matan@nvidia.com, shahafs@nvidia.com,
	viacheslavo@nvidia.com, Jiawei Zhu <17826875952@163.com>,
	stable@dpdk.org
Subject: [dpdk-dev] [PATCH v2] net/mlx5: fix wrong segmented packet in Rx
Date: Mon,  1 Mar 2021 11:58:05 -0500
Message-ID: <1614617885-2650-1-git-send-email-17826875952@163.com> (raw)
In-Reply-To: <1613384114-17855-1-git-send-email-17826875952@163.com>

Fixed issue could occur when Mbuf starvation happens
in a middle of reception of a segmented packet.
In such a situation, after release the segments of that
packet, it does not align consumer index to the next stride.
This would cause receive a wrong segmented packet.

Here is a possible error.
- we assume segs_n is 4 and we are receiving 4
  segments multi-segment packet.
- we fail to alloc mbuf when receive the 3th segment
  so it will free the mbufs which packet chain we have
  built. Here are the 1st and 2nd segment.
- Rx queue in this stride, the 1st and the 2nd segment
  are fill the new mbuf and there data will be rand,
  but the 3th and 4th segment are still fill the last data.
  So next if still begin on this stride, it will receive
  wrong multi-segment packet.
- So we should discarded this packets and pass this stride.
  Before exit the loop, we should align the next consumer index.

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

Signed-off-by: Jiawei Zhu <17826875952@163.com>
---
v2:
* Added extra explanation in commit message.
---
 drivers/net/mlx5/mlx5_rxtx.c | 3 +++
 1 file changed, 3 insertions(+)

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) {
-- 
1.8.3.1


  parent reply	other threads:[~2021-03-01 16:58 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15 10:15 [dpdk-dev] [PATCH] " Jiawei Zhu
2021-02-24 13:20 ` Slava Ovsiienko
2021-02-26 16:11   ` Jiawei Zhu
2021-03-01  9:13     ` Slava Ovsiienko
2021-03-01 17:01       ` Jiawei Zhu
2021-03-02  8:10         ` Slava Ovsiienko
2021-03-02 16:44           ` Jiawei Zhu
2021-03-01 16:58 ` Jiawei Zhu [this message]
2021-03-01 17:19   ` [dpdk-dev] [PATCH v3] " Jiawei Zhu
2021-03-02 17:18     ` Slava Ovsiienko
2021-03-04  9:00     ` Raslan Darawsheh
2021-03-13 19:45       ` [dpdk-dev] [dpdk-stable] " Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1614617885-2650-1-git-send-email-17826875952@163.com \
    --to=17826875952@163.com \
    --cc=dev@dpdk.org \
    --cc=matan@nvidia.com \
    --cc=shahafs@nvidia.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@nvidia.com \
    --cc=zhujiawei12@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git