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

Kevin Traynor ktraynor at redhat.com
Thu Dec 7 12:21:01 CET 2023


Hi,

FYI, your patch has been queued to stable release 21.11.6

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/12/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://github.com/kevintraynor/dpdk-stable

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable/commit/952d7028792c77ad14e64bb596fb005c48f274ee

Thanks.

Kevin

---
>From 952d7028792c77ad14e64bb596fb005c48f274ee 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

[ 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 4a76cc3d05..74dd72b3ac 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -45,5 +45,4 @@
 #include <pcap/bpf.h>
 
-#define RING_NAME "capture-ring"
 #define MONITOR_INTERVAL  (500 * 1000)
 #define MBUF_POOL_CACHE_SIZE 32
@@ -540,4 +539,5 @@ static struct rte_ring *create_ring(void)
 {
 	struct rte_ring *ring;
+	char ring_name[RTE_RING_NAMESIZE];
 	size_t size, log2;
 
@@ -553,12 +553,14 @@ static struct rte_ring *create_ring(void)
 	}
 
-	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;
 }
@@ -566,11 +568,9 @@ static struct rte_ring *create_ring(void)
 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,
-- 
2.43.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-12-07 11:18:59.837862786 +0000
+++ 0009-app-dumpcap-allow-multiple-invocations.patch	2023-12-07 11:18:59.620873903 +0000
@@ -1 +1 @@
-From e0235c0e4d40a6d93dfef8b1316e03c32f2f8b43 Mon Sep 17 00:00:00 2001
+From 952d7028792c77ad14e64bb596fb005c48f274ee Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit e0235c0e4d40a6d93dfef8b1316e03c32f2f8b43 ]
+
@@ -19 +20,0 @@
-Cc: stable at dpdk.org
@@ -24,2 +25,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 +29 @@
-index 4f581bd341..d05dddac00 100644
+index 4a76cc3d05..74dd72b3ac 100644
@@ -37 +38 @@
-@@ -648,4 +647,5 @@ static struct rte_ring *create_ring(void)
+@@ -540,4 +539,5 @@ static struct rte_ring *create_ring(void)
@@ -43 +44 @@
-@@ -661,12 +661,14 @@ static struct rte_ring *create_ring(void)
+@@ -553,12 +553,14 @@ static struct rte_ring *create_ring(void)
@@ -66 +67,2 @@
-@@ -675,12 +677,10 @@ static struct rte_mempool *create_mempool(void)
+@@ -566,11 +568,9 @@ static struct rte_ring *create_ring(void)
+ static struct rte_mempool *create_mempool(void)
@@ -68 +69,0 @@
- 	const struct interface *intf;
@@ -73 +73,0 @@
- 	uint32_t data_size = 128;
@@ -80,8 +80 @@
- 	/* Common pool so size mbuf for biggest snap length */
-@@ -827,5 +827,5 @@ static void enable_pdump(struct rte_ring *r, struct rte_mempool *mp)
- 				"Packet dump enable on %u:%s failed %s\n",
- 				intf->port, intf->name,
--				rte_strerror(-ret));
-+				rte_strerror(rte_errno));
- 		}
- 
+ 	mp = rte_pktmbuf_pool_create_by_ops(pool_name, num_mbufs,



More information about the stable mailing list