From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 653B1A0C4E for ; Fri, 15 Oct 2021 14:20:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 48DB741225; Fri, 15 Oct 2021 14:20:15 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (usb-smtp-delivery-124.mimecast.com [170.10.153.124]) by mails.dpdk.org (Postfix) with ESMTP id 6F1B5411FE for ; Fri, 15 Oct 2021 14:20:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634300413; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bTufMkFx7PlR5QniCK2fSPIEgHsL0AgS5ypPwmNVz5o=; b=XRwWCZ7TFFrsae2DwgYu7Lx+MnC/by86+2gHJfc8bz68oHzrpJLHllAnMEhYErNbnLC//M d6irc7tTF24/0QCdQUZvLvZrflJPhRSYzVS6XfDrIFRvxBkmm7GmG/eF+SXZybOJHS/8q8 /HoZzguZ1yDNGtzVuBjMfXOBpsdUl2Y= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-wkwHlWwcO_aPdRpwNQ68sQ-1; Fri, 15 Oct 2021 08:20:09 -0400 X-MC-Unique: wkwHlWwcO_aPdRpwNQ68sQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AB0342E75; Fri, 15 Oct 2021 12:20:08 +0000 (UTC) Received: from [10.39.208.20] (unknown [10.39.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B0F3DB854C; Fri, 15 Oct 2021 12:20:07 +0000 (UTC) Message-ID: Date: Fri, 15 Oct 2021 14:20:06 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.1.0 To: Marvin Liu , chenbo.xia@intel.com Cc: dev@dpdk.org, stable@dpdk.org References: <20210926092842.26103-1-yong.liu@intel.com> From: Maxime Coquelin In-Reply-To: <20210926092842.26103-1-yong.liu@intel.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-stable] [PATCH] net/virtio: fix vectorized path receive oversized packets X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" On 9/26/21 11:28, Marvin Liu wrote: > 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])) { > Reviewed-by: Maxime Coquelin Thanks, Maxime