DPDK patches and discussions
 help / color / mirror / Atom feed
From: Stephen Hemminger <stephen@networkplumber.org>
To: dev@dpdk.org
Cc: Stephen Hemminger <stephen@networkplumber.org>,
	Reshma Pattan <reshma.pattan@intel.com>,
	Khadem Ullah <14pwcse1224@uetpeshawar.edu.pk>,
	Bruce Richardson <bruce.richardson@intel.com>
Subject: [PATCH 1/2] pdump: avoid integer issues
Date: Wed, 12 Nov 2025 12:05:09 -0800	[thread overview]
Message-ID: <20251112200510.332651-1-stephen@networkplumber.org> (raw)

There are warnings from Coverity and other tools that handling
of intermediate bursts may wraparound. Shouldn't be possible but
use unsigned int to avoid any issues, and just as fast.

Coverity issue: 499471
Fixes: 0dea03ef2e8c ("pdump: remove use of VLA")

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 lib/pdump/rte_pdump.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/lib/pdump/rte_pdump.c b/lib/pdump/rte_pdump.c
index 039a4013dd..c3d0ffa779 100644
--- a/lib/pdump/rte_pdump.c
+++ b/lib/pdump/rte_pdump.c
@@ -27,7 +27,7 @@ RTE_LOG_REGISTER_DEFAULT(pdump_logtype, NOTICE);
 /* Used for the multi-process communication */
 #define PDUMP_MP	"mp_pdump"
 
-#define PDUMP_BURST_SIZE	32
+#define PDUMP_BURST_SIZE	32u
 
 /* Overly generous timeout for secondary to respond */
 #define MP_TIMEOUT_S 5
@@ -139,13 +139,11 @@ pdump_cb_release(struct pdump_rxtx_cbs *cbs)
 static void
 pdump_copy_burst(uint16_t port_id, uint16_t queue_id,
 		 enum rte_pcapng_direction direction,
-		 struct rte_mbuf **pkts, uint16_t nb_pkts,
+		 struct rte_mbuf **pkts, unsigned int nb_pkts,
 		 const struct pdump_rxtx_cbs *cbs,
 		 struct rte_pdump_stats *stats)
 {
-	unsigned int i;
-	int ring_enq;
-	uint16_t d_pkts = 0;
+	unsigned int i, ring_enq, d_pkts = 0;
 	struct rte_mbuf *dup_bufs[PDUMP_BURST_SIZE]; /* duplicated packets */
 	struct rte_ring *ring;
 	struct rte_mempool *mp;
@@ -188,7 +186,7 @@ pdump_copy_burst(uint16_t port_id, uint16_t queue_id,
 			dup_bufs[d_pkts++] = p;
 	}
 
-	if (unlikely(d_pkts == 0))
+	if (d_pkts == 0)
 		return;
 
 	rte_atomic_fetch_add_explicit(&stats->accepted, d_pkts, rte_memory_order_relaxed);
@@ -210,10 +208,10 @@ pdump_copy(uint16_t port_id, uint16_t queue_id,
 	   const struct pdump_rxtx_cbs *cbs,
 	   struct rte_pdump_stats *stats)
 {
-	uint16_t offs = 0;
+	unsigned int offs = 0;
 
 	do {
-		uint16_t n = RTE_MIN(nb_pkts - offs, PDUMP_BURST_SIZE);
+		unsigned int n = RTE_MIN(nb_pkts - offs, PDUMP_BURST_SIZE);
 
 		pdump_copy_burst(port_id, queue_id, direction, &pkts[offs], n, cbs, stats);
 		offs += n;
-- 
2.51.0


             reply	other threads:[~2025-11-12 20:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-12 20:05 Stephen Hemminger [this message]
2025-11-12 20:05 ` [PATCH 2/2] pdump: fix race in pdump disabling Stephen Hemminger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251112200510.332651-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=14pwcse1224@uetpeshawar.edu.pk \
    --cc=bruce.richardson@intel.com \
    --cc=dev@dpdk.org \
    --cc=reshma.pattan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).