[dpdk-stable] patch 'net/pcap: fix infinite Rx with large files' has been queued to stable release 19.11.7

Christian Ehrhardt christian.ehrhardt at canonical.com
Mon Feb 8 12:14:26 CET 2021


Hi,

FYI, your patch has been queued to stable release 19.11.7

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 02/10/21. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://github.com/cpaelzer/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/cpaelzer/dpdk-stable-queue/commit/484d7fbe37f01174993cb3e73ff25d6fb492fc59

Thanks.

Christian Ehrhardt <christian.ehrhardt at canonical.com>

---
>From 484d7fbe37f01174993cb3e73ff25d6fb492fc59 Mon Sep 17 00:00:00 2001
From: Ferruh Yigit <ferruh.yigit at intel.com>
Date: Thu, 4 Feb 2021 16:51:03 +0000
Subject: [PATCH] net/pcap: fix infinite Rx with large files

[ upstream commit f62490e64d60cb564240721d55f8b51d2bd719a9 ]

Packet forwarding is not working when infinite Rx feature is used with
large .pcap files that has high number of packets.

The problem is number of allocated mbufs are less than the infinite Rx
ring size, and all mbufs consumed to fill the ring, so there is no mbuf
left for forwarding.

Current logic can not detect that infinite Rx ring is not filled
completely and no more mbufs left, and setup continues which leads
silent fail on packet forwarding.

There isn't much can be done when there is not enough mbuf for the given
.pcap file, so additional checks added to detect the case and fail
explicitly with an error log.

Bugzilla ID: 595
Fixes: a3f5252e5cbd ("net/pcap: enable infinitely Rx a pcap file")

Reported-by: Cian Ferriter <cian.ferriter at intel.com>
Signed-off-by: Ferruh Yigit <ferruh.yigit at intel.com>
Acked-by: Cian Ferriter <cian.ferriter at intel.com>
---
 drivers/net/pcap/rte_eth_pcap.c | 40 ++++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/net/pcap/rte_eth_pcap.c b/drivers/net/pcap/rte_eth_pcap.c
index 6fbf61f819..f4afe67116 100644
--- a/drivers/net/pcap/rte_eth_pcap.c
+++ b/drivers/net/pcap/rte_eth_pcap.c
@@ -723,6 +723,17 @@ eth_stats_reset(struct rte_eth_dev *dev)
 	return 0;
 }
 
+static inline void
+infinite_rx_ring_free(struct rte_ring *pkts)
+{
+	struct rte_mbuf *bufs;
+
+	while (!rte_ring_dequeue(pkts, (void **)&bufs))
+		rte_pktmbuf_free(bufs);
+
+	rte_ring_free(pkts);
+}
+
 static void
 eth_dev_close(struct rte_eth_dev *dev)
 {
@@ -733,7 +744,6 @@ eth_dev_close(struct rte_eth_dev *dev)
 	if (internals->infinite_rx) {
 		for (i = 0; i < dev->data->nb_rx_queues; i++) {
 			struct pcap_rx_queue *pcap_q = &internals->rx_queue[i];
-			struct rte_mbuf *pcap_buf;
 
 			/*
 			 * 'pcap_q->pkts' can be NULL if 'eth_dev_close()'
@@ -742,11 +752,7 @@ eth_dev_close(struct rte_eth_dev *dev)
 			if (pcap_q->pkts == NULL)
 				continue;
 
-			while (!rte_ring_dequeue(pcap_q->pkts,
-					(void **)&pcap_buf))
-				rte_pktmbuf_free(pcap_buf);
-
-			rte_ring_free(pcap_q->pkts);
+			infinite_rx_ring_free(pcap_q->pkts);
 		}
 	}
 
@@ -810,21 +816,25 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,
 		while (eth_pcap_rx(pcap_q, bufs, 1)) {
 			/* Check for multiseg mbufs. */
 			if (bufs[0]->nb_segs != 1) {
-				rte_pktmbuf_free(*bufs);
-
-				while (!rte_ring_dequeue(pcap_q->pkts,
-						(void **)bufs))
-					rte_pktmbuf_free(*bufs);
-
-				rte_ring_free(pcap_q->pkts);
-				PMD_LOG(ERR, "Multiseg mbufs are not supported in infinite_rx "
-						"mode.");
+				infinite_rx_ring_free(pcap_q->pkts);
+				PMD_LOG(ERR,
+					"Multiseg mbufs are not supported in infinite_rx mode.");
 				return -EINVAL;
 			}
 
 			rte_ring_enqueue_bulk(pcap_q->pkts,
 					(void * const *)bufs, 1, NULL);
 		}
+
+		if (rte_ring_count(pcap_q->pkts) < pcap_pkt_count) {
+			infinite_rx_ring_free(pcap_q->pkts);
+			PMD_LOG(ERR,
+				"Not enough mbufs to accommodate packets in pcap file. "
+				"At least %" PRIu64 " mbufs per queue is required.",
+				pcap_pkt_count);
+			return -EINVAL;
+		}
+
 		/*
 		 * Reset the stats for this queue since eth_pcap_rx calls above
 		 * didn't result in the application receiving packets.
-- 
2.30.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2021-02-08 12:04:30.069798711 +0100
+++ 0014-net-pcap-fix-infinite-Rx-with-large-files.patch	2021-02-08 12:04:29.551496794 +0100
@@ -1 +1 @@
-From f62490e64d60cb564240721d55f8b51d2bd719a9 Mon Sep 17 00:00:00 2001
+From 484d7fbe37f01174993cb3e73ff25d6fb492fc59 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit f62490e64d60cb564240721d55f8b51d2bd719a9 ]
+
@@ -23 +24,0 @@
-Cc: stable at dpdk.org
@@ -33 +34 @@
-index c7751b7ba7..90f5d75ea8 100644
+index 6fbf61f819..f4afe67116 100644
@@ -36 +37 @@
-@@ -735,6 +735,17 @@ eth_stats_reset(struct rte_eth_dev *dev)
+@@ -723,6 +723,17 @@ eth_stats_reset(struct rte_eth_dev *dev)
@@ -51 +52 @@
- static int
+ static void
@@ -54 +55 @@
-@@ -753,7 +764,6 @@ eth_dev_close(struct rte_eth_dev *dev)
+@@ -733,7 +744,6 @@ eth_dev_close(struct rte_eth_dev *dev)
@@ -62 +63 @@
-@@ -762,11 +772,7 @@ eth_dev_close(struct rte_eth_dev *dev)
+@@ -742,11 +752,7 @@ eth_dev_close(struct rte_eth_dev *dev)
@@ -75 +76 @@
-@@ -835,21 +841,25 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,
+@@ -810,21 +816,25 @@ eth_rx_queue_setup(struct rte_eth_dev *dev,


More information about the stable mailing list