public inbox for dev@dpdk.org
 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>
Subject: [PATCH v7 7/7] dumpcap: improve pcapng error reporting
Date: Fri, 13 Feb 2026 11:18:24 -0800	[thread overview]
Message-ID: <20260213192039.221213-8-stephen@networkplumber.org> (raw)
In-Reply-To: <20260213192039.221213-1-stephen@networkplumber.org>

Print meaningful error messages when rte_pcapng_add_interface()
or rte_pcapng_write_stats() fails instead of silently ignoring
the error or printing a generic message.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/dumpcap/main.c | 36 ++++++++++++++++++++++--------------
 1 file changed, 22 insertions(+), 14 deletions(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index 46a6cb251e..f105ee92c2 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -587,9 +587,16 @@ report_packet_stats(dumpcap_out_t out)
 		ifrecv = pdump_stats.accepted + pdump_stats.filtered;
 		ifdrop = pdump_stats.nombuf + pdump_stats.ringfull;
 
-		if (use_pcapng)
-			rte_pcapng_write_stats(out.pcapng, intf->port,
-					       ifrecv, ifdrop, NULL);
+		if (use_pcapng) {
+			ssize_t written;
+
+			written = rte_pcapng_write_stats(out.pcapng, intf->port,
+							 ifrecv, ifdrop, NULL);
+			if (written < 0) {
+				fprintf(stderr, "Failed to write stats for %s: %s\n",
+					intf->name, rte_strerror(-written));
+			}
+		}
 
 		if (ifrecv == 0)
 			percent = 0;
@@ -760,7 +767,7 @@ static char *get_os_info(void)
 
 static dumpcap_out_t create_output(void)
 {
-	dumpcap_out_t ret;
+	dumpcap_out_t out;
 	static char tmp_path[PATH_MAX];
 	int fd;
 
@@ -802,19 +809,20 @@ static dumpcap_out_t create_output(void)
 		struct interface *intf;
 		char *os = get_os_info();
 
-		ret.pcapng = rte_pcapng_fdopen(fd, os, NULL,
+		out.pcapng = rte_pcapng_fdopen(fd, os, NULL,
 					   version(), capture_comment);
-		if (ret.pcapng == NULL)
+		if (out.pcapng == NULL)
 			rte_exit(EXIT_FAILURE, "pcapng_fdopen failed: %s\n",
 				 strerror(rte_errno));
 		free(os);
 
 		TAILQ_FOREACH(intf, &interfaces, next) {
-			if (rte_pcapng_add_interface(ret.pcapng, intf->port, DLT_EN10MB,
-						     intf->ifname, intf->ifdescr,
-						     intf->opts.filter) < 0)
-				rte_exit(EXIT_FAILURE, "rte_pcapng_add_interface %u failed\n",
-					intf->port);
+			int ret = rte_pcapng_add_interface(out.pcapng, intf->port, DLT_EN10MB,
+						       intf->ifname, intf->ifdescr,
+						       intf->opts.filter);
+			if (ret < 0)
+				rte_exit(EXIT_FAILURE, "rte_pcapng_add_interface %u failed: %s\n",
+					 intf->port, rte_strerror(-ret));
 		}
 	} else {
 		pcap_t *pcap;
@@ -825,13 +833,13 @@ static dumpcap_out_t create_output(void)
 		if (pcap == NULL)
 			rte_exit(EXIT_FAILURE, "pcap_open_dead failed\n");
 
-		ret.dumper = pcap_dump_fopen(pcap, fdopen(fd, "w"));
-		if (ret.dumper == NULL)
+		out.dumper = pcap_dump_fopen(pcap, fdopen(fd, "w"));
+		if (out.dumper == NULL)
 			rte_exit(EXIT_FAILURE, "pcap_dump_fopen failed: %s\n",
 				 pcap_geterr(pcap));
 	}
 
-	return ret;
+	return out;
 }
 
 static void enable_pdump(struct rte_ring *r, struct rte_mempool *mp)
-- 
2.51.0


  parent reply	other threads:[~2026-02-13 19:21 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26  5:12 [RFC] pcapng: improve performance of timestamping Stephen Hemminger
2025-12-29 23:01 ` [PATCH v2 0/6] pcapng: timestamping and comment fixes Stephen Hemminger
2025-12-29 23:01   ` [PATCH v2 1/6] pcapng: use alloca instead of fixed buffer Stephen Hemminger
2025-12-29 23:01   ` [PATCH v2 2/6] pcapng: add additional mbuf if space required on copy Stephen Hemminger
2025-12-29 23:01   ` [PATCH v2 3/6] test: add more tests for comments in pcapng Stephen Hemminger
2025-12-29 23:01   ` [PATCH v2 4/6] test: vary size of packets in pcapng test Stephen Hemminger
2025-12-29 23:01   ` [PATCH v2 5/6] test: increase gap " Stephen Hemminger
2025-12-29 23:01   ` [PATCH v2 6/6] pcapng: improve performance of timestamping Stephen Hemminger
2026-01-12  4:50 ` [PATCH v3 0/7] pcapng: fixes and improvements Stephen Hemminger
2026-01-12  4:50   ` [PATCH v3 1/7] pcapng: add length checks to string arguments Stephen Hemminger
2026-01-12  4:50   ` [PATCH v3 2/7] pcapng: use malloc instead of fixed buffer size Stephen Hemminger
2026-01-12  4:50   ` [PATCH v3 3/7] pcapng: add additional mbuf if space required on copy Stephen Hemminger
2026-01-12  4:50   ` [PATCH v3 4/7] test: add more tests for comments in pcapng Stephen Hemminger
2026-01-12  4:50   ` [PATCH v3 5/7] test: vary size of packets in pcapng test Stephen Hemminger
2026-01-12  4:50   ` [PATCH v3 6/7] test: increase gap " Stephen Hemminger
2026-01-12  4:50   ` [PATCH v3 7/7] pcapng: improve performance of timestamping Stephen Hemminger
2026-01-13  0:51 ` [PATCH v4 0/7] pcapng: fixes and improvements Stephen Hemminger
2026-01-13  0:51   ` [PATCH v4 1/7] pcapng: add length checks to string arguments Stephen Hemminger
2026-01-13  0:51   ` [PATCH v4 2/7] pcapng: use malloc instead of fixed buffer size Stephen Hemminger
2026-01-13  0:51   ` [PATCH v4 3/7] pcapng: add additional mbuf if space required on copy Stephen Hemminger
2026-01-13  0:51   ` [PATCH v4 4/7] test: add more tests for comments in pcapng Stephen Hemminger
2026-01-13  0:51   ` [PATCH v4 5/7] test: vary size of packets in pcapng test Stephen Hemminger
2026-01-13  0:51   ` [PATCH v4 6/7] test: increase gap " Stephen Hemminger
2026-01-13  0:51   ` [PATCH v4 7/7] pcapng: improve performance of timestamping Stephen Hemminger
2026-01-19 18:18 ` [PATCH v5 0/5] pcapng: fixes and improvements Stephen Hemminger
2026-01-19 18:18   ` [PATCH v5 1/5] pcapng: add length checks to string arguments Stephen Hemminger
2026-01-19 18:19   ` [PATCH v5 2/5] pcapng: use malloc instead of fixed buffer size Stephen Hemminger
2026-01-19 18:19   ` [PATCH v5 3/5] pcapng: add additional mbuf if space required on copy Stephen Hemminger
2026-01-19 18:19   ` [PATCH v5 4/5] pcapng: improve performance of timestamping Stephen Hemminger
2026-01-19 18:19   ` [PATCH v5 5/5] test: add more tests for pcapng Stephen Hemminger
2026-01-26 21:04 ` [PATCH v6 0/5] pcapng: fixes and improvements Stephen Hemminger
2026-01-26 21:04   ` [PATCH v6 1/5] pcapng: add length checks to string arguments Stephen Hemminger
2026-01-26 21:04   ` [PATCH v6 2/5] pcapng: use malloc instead of fixed buffer size Stephen Hemminger
2026-01-26 21:04   ` [PATCH v6 3/5] pcapng: chain additional mbuf when comment exceeds tailroom Stephen Hemminger
2026-01-26 21:04   ` [PATCH v6 4/5] pcapng: improve performance of timestamping Stephen Hemminger
2026-01-26 21:04   ` [PATCH v6 5/5] test/pcapng: add tests for comments Stephen Hemminger
2026-02-13 19:18   ` [PATCH v7 0/7] pcapng: fixes and improvements Stephen Hemminger
2026-02-13 19:18     ` [PATCH v7 1/7] pcapng: add length checks to string arguments Stephen Hemminger
2026-02-13 19:18     ` [PATCH v7 2/7] pcapng: use malloc instead of fixed buffer size Stephen Hemminger
2026-02-13 19:18     ` [PATCH v7 3/7] pcapng: chain additional mbuf when comment exceeds tailroom Stephen Hemminger
2026-02-13 19:18     ` [PATCH v7 4/7] pcapng: improve performance of timestamping Stephen Hemminger
2026-02-13 19:18     ` [PATCH v7 5/7] test/pcapng: add tests for comments Stephen Hemminger
2026-02-13 19:18     ` [PATCH v7 6/7] test/pcapng: skip test if null driver missing Stephen Hemminger
2026-02-16 10:01       ` David Marchand
2026-02-16 16:26         ` Stephen Hemminger
2026-02-16 16:43           ` David Marchand
2026-02-13 19:18     ` Stephen Hemminger [this message]
2026-02-16 21:37   ` [PATCH v8 0/8] pcapng: fixes and improvements Stephen Hemminger
2026-02-16 21:37     ` [PATCH v8 1/8] pcapng: correct typo in comment Stephen Hemminger
2026-02-16 21:37     ` [PATCH v8 2/8] pcapng: document return values Stephen Hemminger
2026-02-16 21:38     ` [PATCH v8 3/8] pcapng: add length checks to string arguments Stephen Hemminger
2026-02-17 14:34       ` Thomas Monjalon
2026-02-16 21:38     ` [PATCH v8 4/8] pcapng: use malloc instead of fixed buffer size Stephen Hemminger
2026-02-16 21:38     ` [PATCH v8 5/8] pcapng: chain additional mbuf when comment exceeds tailroom Stephen Hemminger
2026-02-16 21:38     ` [PATCH v8 6/8] pcapng: improve performance of timestamping Stephen Hemminger
2026-02-16 21:38     ` [PATCH v8 7/8] test/pcapng: skip test if null driver missing Stephen Hemminger
2026-02-16 21:38     ` [PATCH v8 8/8] test/pcapng: add tests for comments Stephen Hemminger
2026-02-17 16:39     ` [PATCH v8 0/8] pcapng: fixes and improvements Thomas Monjalon

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=20260213192039.221213-8-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --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