patch 'app/dumpcap: allow multiple invocations' has been queued to stable release 22.11.4

Xueming Li xuemingl at nvidia.com
Mon Dec 11 11:12:12 CET 2023


Hi,

FYI, your patch has been queued to stable release 22.11.4

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/13/23. 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://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=3ca387345f4a14e7cc51f3a3458581760a87361e

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From 3ca387345f4a14e7cc51f3a3458581760a87361e Mon Sep 17 00:00:00 2001
From: Stephen Hemminger <stephen at networkplumber.org>
Date: Fri, 17 Nov 2023 08:35:56 -0800
Subject: [PATCH] app/dumpcap: allow multiple invocations
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit e0235c0e4d40a6d93dfef8b1316e03c32f2f8b43 ]

If dumpcap is run twice with each instance pointing a different
interface, it would fail because of overlap in ring a pool names.
Fix by putting process id in the name.

It is still not allowed to do multiple invocations on the same
interface because only one callback is allowed and only one copy
of mbuf is done. Dumpcap will fail with error in this case:

   pdump_prepare_client_request(): client request for pdump enable/disable failed
   EAL: Error - exiting with code: 1
     Cause: Packet dump enable on 0:net_null0 failed File exists

Fixes: cbb44143be74 ("app/dumpcap: add new packet capture application")

Reported-by: Isaac Boukris <iboukris at gmail.com>
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
 app/dumpcap/main.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index fbe47c476a..0c8e647598 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -44,7 +44,6 @@
 #include <pcap/pcap.h>
 #include <pcap/bpf.h>
 
-#define RING_NAME "capture-ring"
 #define MONITOR_INTERVAL  (500 * 1000)
 #define MBUF_POOL_CACHE_SIZE 32
 #define BURST_SIZE 32
@@ -555,6 +554,7 @@ static void dpdk_init(void)
 static struct rte_ring *create_ring(void)
 {
 	struct rte_ring *ring;
+	char ring_name[RTE_RING_NAMESIZE];
 	size_t size, log2;
 
 	/* Find next power of 2 >= size. */
@@ -568,26 +568,26 @@ static struct rte_ring *create_ring(void)
 		ring_size = size;
 	}
 
-	ring = rte_ring_lookup(RING_NAME);
-	if (ring == NULL) {
-		ring = rte_ring_create(RING_NAME, ring_size,
-					rte_socket_id(), 0);
-		if (ring == NULL)
-			rte_exit(EXIT_FAILURE, "Could not create ring :%s\n",
-				 rte_strerror(rte_errno));
-	}
+	/* Want one ring per invocation of program */
+	snprintf(ring_name, sizeof(ring_name),
+		 "dumpcap-%d", getpid());
+
+	ring = rte_ring_create(ring_name, ring_size,
+			       rte_socket_id(), 0);
+	if (ring == NULL)
+		rte_exit(EXIT_FAILURE, "Could not create ring :%s\n",
+			 rte_strerror(rte_errno));
+
 	return ring;
 }
 
 static struct rte_mempool *create_mempool(void)
 {
-	static const char pool_name[] = "capture_mbufs";
+	char pool_name[RTE_MEMPOOL_NAMESIZE];
 	size_t num_mbufs = 2 * ring_size;
 	struct rte_mempool *mp;
 
-	mp = rte_mempool_lookup(pool_name);
-	if (mp)
-		return mp;
+	snprintf(pool_name, sizeof(pool_name), "capture_%d", getpid());
 
 	mp = rte_pktmbuf_pool_create_by_ops(pool_name, num_mbufs,
 					    MBUF_POOL_CACHE_SIZE, 0,
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-12-11 17:56:26.557008900 +0800
+++ 0107-app-dumpcap-allow-multiple-invocations.patch	2023-12-11 17:56:23.217652300 +0800
@@ -1 +1 @@
-From e0235c0e4d40a6d93dfef8b1316e03c32f2f8b43 Mon Sep 17 00:00:00 2001
+From 3ca387345f4a14e7cc51f3a3458581760a87361e Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit e0235c0e4d40a6d93dfef8b1316e03c32f2f8b43 ]
@@ -19 +21,0 @@
-Cc: stable at dpdk.org
@@ -24,2 +26,2 @@
- app/dumpcap/main.c | 28 ++++++++++++++--------------
- 1 file changed, 14 insertions(+), 14 deletions(-)
+ app/dumpcap/main.c | 26 +++++++++++++-------------
+ 1 file changed, 13 insertions(+), 13 deletions(-)
@@ -28 +30 @@
-index 4f581bd341..d05dddac00 100644
+index fbe47c476a..0c8e647598 100644
@@ -39 +41 @@
-@@ -647,6 +646,7 @@ static void dpdk_init(void)
+@@ -555,6 +554,7 @@ static void dpdk_init(void)
@@ -47 +49 @@
-@@ -660,28 +660,28 @@ static struct rte_ring *create_ring(void)
+@@ -568,26 +568,26 @@ static struct rte_ring *create_ring(void)
@@ -74 +75,0 @@
- 	const struct interface *intf;
@@ -79 +79,0 @@
- 	uint32_t data_size = 128;
@@ -86,11 +86,2 @@
- 	/* Common pool so size mbuf for biggest snap length */
- 	TAILQ_FOREACH(intf, &interfaces, next) {
-@@ -826,7 +826,7 @@ static void enable_pdump(struct rte_ring *r, struct rte_mempool *mp)
- 			rte_exit(EXIT_FAILURE,
- 				"Packet dump enable on %u:%s failed %s\n",
- 				intf->port, intf->name,
--				rte_strerror(-ret));
-+				rte_strerror(rte_errno));
- 		}
- 
- 		if (intf->opts.promisc_mode) {
+ 	mp = rte_pktmbuf_pool_create_by_ops(pool_name, num_mbufs,
+ 					    MBUF_POOL_CACHE_SIZE, 0,


More information about the stable mailing list