DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/virtio: fix vectorized path receive oversized packets
@ 2021-09-26  9:28 Marvin Liu
  2021-10-15 12:20 ` Maxime Coquelin
  2021-10-21 12:28 ` Maxime Coquelin
  0 siblings, 2 replies; 3+ messages in thread
From: Marvin Liu @ 2021-09-26  9:28 UTC (permalink / raw)
  To: maxime.coquelin, chenbo.xia; +Cc: dev, Marvin Liu, stable

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/virtio: fix vectorized path receive oversized packets
  2021-09-26  9:28 [dpdk-dev] [PATCH] net/virtio: fix vectorized path receive oversized packets Marvin Liu
@ 2021-10-15 12:20 ` Maxime Coquelin
  2021-10-21 12:28 ` Maxime Coquelin
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2021-10-15 12:20 UTC (permalink / raw)
  To: Marvin Liu, chenbo.xia; +Cc: dev, 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 <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])) {
> 

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-dev] [PATCH] net/virtio: fix vectorized path receive oversized packets
  2021-09-26  9:28 [dpdk-dev] [PATCH] net/virtio: fix vectorized path receive oversized packets Marvin Liu
  2021-10-15 12:20 ` Maxime Coquelin
@ 2021-10-21 12:28 ` Maxime Coquelin
  1 sibling, 0 replies; 3+ messages in thread
From: Maxime Coquelin @ 2021-10-21 12:28 UTC (permalink / raw)
  To: Marvin Liu, chenbo.xia; +Cc: dev, 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 <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])) {
> 


Applied to dpdk-next-virtio/main.

Thanks,
Maxime


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-10-21 12:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-26  9:28 [dpdk-dev] [PATCH] net/virtio: fix vectorized path receive oversized packets Marvin Liu
2021-10-15 12:20 ` Maxime Coquelin
2021-10-21 12:28 ` Maxime Coquelin

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).