patch 'net/pcap: fix blocking Rx' has been queued to stable release 22.11.7

luca.boccassi at gmail.com luca.boccassi at gmail.com
Wed Oct 23 23:16:46 CEST 2024


Hi,

FYI, your patch has been queued to stable release 22.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 10/25/24. 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/bluca/dpdk-stable

This queued commit can be viewed at:
https://github.com/bluca/dpdk-stable/commit/2012542358d3e38ab05a224418ed088670e3c701

Thanks.

Luca Boccassi

---
>From 2012542358d3e38ab05a224418ed088670e3c701 Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Thu, 5 Sep 2024 09:10:40 -0700
Subject: [PATCH] net/pcap: fix blocking Rx

[ upstream commit f5ead8f84f205babb320a1d805fb436ba31a5532 ]

Use pcap_next_ex rather than just pcap_next because pcap_next
always blocks if there is no packets to receive.

Bugzilla ID: 1526
Fixes: 4c173302c307 ("pcap: add new driver")

Reported-by: Ofer Dagan <ofer.d at claroty.com>
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
Tested-by: Ofer Dagan <ofer.d at claroty.com>
---
 .mailmap                       |  1 +
 drivers/net/pcap/pcap_ethdev.c | 33 +++++++++++++++++----------------
 2 files changed, 18 insertions(+), 16 deletions(-)

diff --git a/.mailmap b/.mailmap
index 629383cb25..025bd2daba 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1017,6 +1017,7 @@ Noa Ezra <noae at mellanox.com>
 Nobuhiro Miki <nmiki at yahoo-corp.jp>
 Norbert Ciosek <norbertx.ciosek at intel.com>
 Odi Assli <odia at nvidia.com>
+Ofer Dagan <ofer.d at claroty.com>
 Ognjen Joldzic <ognjen.joldzic at gmail.com>
 Ola Liljedahl <ola.liljedahl at arm.com>
 Oleg Polyakov <olegp123 at walla.co.il>
diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index 03729c0ca7..29664164b4 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -274,7 +274,7 @@ static uint16_t
 eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 {
 	unsigned int i;
-	struct pcap_pkthdr header;
+	struct pcap_pkthdr *header;
 	struct pmd_process_private *pp;
 	const u_char *packet;
 	struct rte_mbuf *mbuf;
@@ -294,9 +294,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 	 */
 	for (i = 0; i < nb_pkts; i++) {
 		/* Get the next PCAP packet */
-		packet = pcap_next(pcap, &header);
-		if (unlikely(packet == NULL))
+		int ret = pcap_next_ex(pcap, &header, &packet);
+		if (ret != 1) {
+			if (ret == PCAP_ERROR)
+				pcap_q->rx_stat.err_pkts++;
+
 			break;
+		}
 
 		mbuf = rte_pktmbuf_alloc(pcap_q->mb_pool);
 		if (unlikely(mbuf == NULL)) {
@@ -304,33 +308,30 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
 			break;
 		}
 
-		if (header.caplen <= rte_pktmbuf_tailroom(mbuf)) {
+		uint32_t len = header->caplen;
+		if (len <= rte_pktmbuf_tailroom(mbuf)) {
 			/* pcap packet will fit in the mbuf, can copy it */
-			rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), packet,
-					header.caplen);
-			mbuf->data_len = (uint16_t)header.caplen;
+			rte_memcpy(rte_pktmbuf_mtod(mbuf, void *), packet, len);
+			mbuf->data_len = len;
 		} else {
 			/* Try read jumbo frame into multi mbufs. */
 			if (unlikely(eth_pcap_rx_jumbo(pcap_q->mb_pool,
-						       mbuf,
-						       packet,
-						       header.caplen) == -1)) {
+						       mbuf, packet, len) == -1)) {
 				pcap_q->rx_stat.err_pkts++;
 				rte_pktmbuf_free(mbuf);
 				break;
 			}
 		}
 
-		mbuf->pkt_len = (uint16_t)header.caplen;
-		*RTE_MBUF_DYNFIELD(mbuf, timestamp_dynfield_offset,
-			rte_mbuf_timestamp_t *) =
-				(uint64_t)header.ts.tv_sec * 1000000 +
-				header.ts.tv_usec;
+		mbuf->pkt_len = len;
+		uint64_t us = (uint64_t)header->ts.tv_sec * US_PER_S + header->ts.tv_usec;
+
+		*RTE_MBUF_DYNFIELD(mbuf, timestamp_dynfield_offset, rte_mbuf_timestamp_t *) = us;
 		mbuf->ol_flags |= timestamp_rx_dynflag;
 		mbuf->port = pcap_q->port_id;
 		bufs[num_rx] = mbuf;
 		num_rx++;
-		rx_bytes += header.caplen;
+		rx_bytes += len;
 	}
 	pcap_q->rx_stat.pkts += num_rx;
 	pcap_q->rx_stat.bytes += rx_bytes;
-- 
2.45.2

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2024-10-23 22:16:43.019824863 +0100
+++ 0066-net-pcap-fix-blocking-Rx.patch	2024-10-23 22:16:40.527943830 +0100
@@ -1 +1 @@
-From f5ead8f84f205babb320a1d805fb436ba31a5532 Mon Sep 17 00:00:00 2001
+From 2012542358d3e38ab05a224418ed088670e3c701 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit f5ead8f84f205babb320a1d805fb436ba31a5532 ]
+
@@ -11 +12,0 @@
-Cc: stable at dpdk.org
@@ -22 +23 @@
-index 3e9e8b416e..bd7958652a 100644
+index 629383cb25..025bd2daba 100644
@@ -25 +26,2 @@
-@@ -1103,6 +1103,7 @@ Nobuhiro Miki <nmiki at yahoo-corp.jp>
+@@ -1017,6 +1017,7 @@ Noa Ezra <noae at mellanox.com>
+ Nobuhiro Miki <nmiki at yahoo-corp.jp>
@@ -27 +28,0 @@
- Norbert Zulinski <norbertx.zulinski at intel.com>
@@ -32 +33 @@
- Oleg Akhrem <oleg.akhrem at intel.com>
+ Oleg Polyakov <olegp123 at walla.co.il>
@@ -34 +35 @@
-index 1fb98e3d2b..728ef85d53 100644
+index 03729c0ca7..29664164b4 100644


More information about the stable mailing list