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 6E2DBA0547 for ; Mon, 8 Feb 2021 12:15:03 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5257E40693; Mon, 8 Feb 2021 12:15:03 +0100 (CET) Received: from youngberry.canonical.com (youngberry.canonical.com [91.189.89.112]) by mails.dpdk.org (Postfix) with ESMTP id 4D35B40147 for ; Mon, 8 Feb 2021 12:15:01 +0100 (CET) Received: from 2.general.paelzer.uk.vpn ([10.172.196.173] helo=localhost.localdomain) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l94VR-0001Ac-46; Mon, 08 Feb 2021 11:15:01 +0000 From: Christian Ehrhardt To: Ferruh Yigit Cc: Cian Ferriter , dpdk stable Date: Mon, 8 Feb 2021 12:14:26 +0100 Message-Id: <20210208111429.1875789-14-christian.ehrhardt@canonical.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210208111429.1875789-1-christian.ehrhardt@canonical.com> References: <20210204112954.2488123-1-christian.ehrhardt@canonical.com> <20210208111429.1875789-1-christian.ehrhardt@canonical.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-stable] patch 'net/pcap: fix infinite Rx with large files' has been queued to stable release 19.11.7 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" 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 --- >From 484d7fbe37f01174993cb3e73ff25d6fb492fc59 Mon Sep 17 00:00:00 2001 From: Ferruh Yigit 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 Signed-off-by: Ferruh Yigit Acked-by: Cian Ferriter --- 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@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,