patch 'net/pcap: fix blocking Rx' has been queued to stable release 21.11.9
Kevin Traynor
ktraynor at redhat.com
Wed Nov 27 18:18:05 CET 2024
Hi,
FYI, your patch has been queued to stable release 21.11.9
Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/02/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/kevintraynor/dpdk-stable
This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/614cecd1fde8a6546360cdb557c6c4da237ba857
Thanks.
Kevin
---
>From 614cecd1fde8a6546360cdb557c6c4da237ba857 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 13eacdbc33..5e0de73ae0 100644
--- a/.mailmap
+++ b/.mailmap
@@ -1017,4 +1017,5 @@ 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>
diff --git a/drivers/net/pcap/pcap_ethdev.c b/drivers/net/pcap/pcap_ethdev.c
index 4d79565460..0d837835d1 100644
--- a/drivers/net/pcap/pcap_ethdev.c
+++ b/drivers/net/pcap/pcap_ethdev.c
@@ -274,5 +274,5 @@ 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;
@@ -294,7 +294,11 @@ 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);
@@ -304,15 +308,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
}
- 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);
@@ -321,14 +323,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
}
- 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;
--
2.47.0
---
Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- - 2024-11-27 17:17:40.086325511 +0000
+++ 0058-net-pcap-fix-blocking-Rx.patch 2024-11-27 17:17:38.233269414 +0000
@@ -1 +1 @@
-From f5ead8f84f205babb320a1d805fb436ba31a5532 Mon Sep 17 00:00:00 2001
+From 614cecd1fde8a6546360cdb557c6c4da237ba857 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 13eacdbc33..5e0de73ae0 100644
@@ -25,2 +26,2 @@
-@@ -1104,4 +1104,5 @@ Norbert Ciosek <norbertx.ciosek at intel.com>
- Norbert Zulinski <norbertx.zulinski at intel.com>
+@@ -1017,4 +1017,5 @@ Nobuhiro Miki <nmiki at yahoo-corp.jp>
+ Norbert Ciosek <norbertx.ciosek at intel.com>
@@ -32 +33 @@
-index 1fb98e3d2b..728ef85d53 100644
+index 4d79565460..0d837835d1 100644
@@ -35 +36 @@
-@@ -275,5 +275,5 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+@@ -274,5 +274,5 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
@@ -42 +43 @@
-@@ -295,7 +295,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+@@ -294,7 +294,11 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
@@ -56 +57 @@
-@@ -305,15 +309,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+@@ -304,15 +308,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
@@ -77 +78 @@
-@@ -322,14 +324,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
+@@ -321,14 +323,13 @@ eth_pcap_rx(void *queue, struct rte_mbuf **bufs, uint16_t nb_pkts)
More information about the stable
mailing list