From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 73E13C433F5 for ; Sun, 26 Sep 2021 02:07:45 +0000 (UTC) Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by mail.kernel.org (Postfix) with ESMTP id 0A19261090 for ; Sun, 26 Sep 2021 02:07:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0A19261090 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=dpdk.org Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id EEBED4003D; Sun, 26 Sep 2021 04:07:43 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id E43D34003C; Sun, 26 Sep 2021 04:07:41 +0200 (CEST) X-IronPort-AV: E=McAfee;i="6200,9189,10118"; a="287973198" X-IronPort-AV: E=Sophos;i="5.85,322,1624345200"; d="scan'208";a="287973198" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Sep 2021 19:07:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.85,322,1624345200"; d="scan'208";a="552322990" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.118.197]) by FMSMGA003.fm.intel.com with ESMTP; 25 Sep 2021 19:07:39 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, Marvin Liu , stable@dpdk.org Date: Sun, 26 Sep 2021 17:28:42 +0800 Message-Id: <20210926092842.26103-1-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] net/virtio: fix vectorized path receive oversized packets X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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 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