DPDK patches and discussions
 help / color / mirror / Atom feed
From: Marvin Liu <yong.liu@intel.com>
To: maxime.coquelin@redhat.com, chenbo.xia@intel.com
Cc: dev@dpdk.org, Marvin Liu <yong.liu@intel.com>, stable@dpdk.org
Subject: [dpdk-dev] [PATCH] net/virtio: fix vectorized path receive oversized packets
Date: Sun, 26 Sep 2021 17:28:42 +0800	[thread overview]
Message-ID: <20210926092842.26103-1-yong.liu@intel.com> (raw)

If packed ring size is not power of two, it is possible that remained
number less than one batch and meanwhile batch operation can pass.
This will cause incorrect remained number calculation and then lead to
receiving oversized packets. The patch fixed the issue by added
remained number check before batch operation.

Fixes: 77d66da83834 ("net/virtio: add vectorized packed ring Rx")
Cc: stable@dpdk.org

Signed-off-by: Marvin Liu <yong.liu@intel.com>

diff --git a/drivers/net/virtio/virtio_rxtx_packed.c b/drivers/net/virtio/virtio_rxtx_packed.c
index ab489a58af..45cf39df22 100644
--- a/drivers/net/virtio/virtio_rxtx_packed.c
+++ b/drivers/net/virtio/virtio_rxtx_packed.c
@@ -95,11 +95,13 @@ virtio_recv_pkts_packed_vec(void *rx_queue,
 		num = num - ((vq->vq_used_cons_idx + num) % PACKED_BATCH_SIZE);
 
 	while (num) {
-		if (!virtqueue_dequeue_batch_packed_vec(rxvq,
-					&rx_pkts[nb_rx])) {
-			nb_rx += PACKED_BATCH_SIZE;
-			num -= PACKED_BATCH_SIZE;
-			continue;
+		if (num >= PACKED_BATCH_SIZE) {
+			if (!virtqueue_dequeue_batch_packed_vec(rxvq,
+						&rx_pkts[nb_rx])) {
+				nb_rx += PACKED_BATCH_SIZE;
+				num -= PACKED_BATCH_SIZE;
+				continue;
+			}
 		}
 		if (!virtqueue_dequeue_single_packed_vec(rxvq,
 					&rx_pkts[nb_rx])) {
-- 
2.17.1


             reply	other threads:[~2021-09-26  2:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-26  9:28 Marvin Liu [this message]
2021-10-15 12:20 ` Maxime Coquelin
2021-10-21 12:28 ` Maxime Coquelin

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=20210926092842.26103-1-yong.liu@intel.com \
    --to=yong.liu@intel.com \
    --cc=chenbo.xia@intel.com \
    --cc=dev@dpdk.org \
    --cc=maxime.coquelin@redhat.com \
    --cc=stable@dpdk.org \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).