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>,
	koncept1@gmail.com, Reshma Pattan <reshma.pattan@intel.com>
Subject: [PATCH] dumpcap: fix list interfaces
Date: Sun, 25 Sep 2022 16:34:10 -0700	[thread overview]
Message-ID: <20220925233410.98051-1-stephen@networkplumber.org> (raw)

The change to do argument process before EAL init broke
the support of list-interfaces option. Fix by setting flag
and doing list-interfaces later.

Fixes: a8dde09f97df ("app/dumpcap: allow help/version without primary process")
Cc: koncept1@gmail.com
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
 app/dumpcap/main.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index a6041d4ff495..490a0f050bc8 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -63,6 +63,8 @@ static unsigned int ring_size = 2048;
 static const char *capture_comment;
 static uint32_t snaplen = RTE_MBUF_DEFAULT_BUF_SIZE;
 static bool dump_bpf;
+static bool show_interfaces;
+
 static struct {
 	uint64_t  duration;	/* nanoseconds */
 	unsigned long packets;  /* number of packets in file */
@@ -256,7 +258,7 @@ static void select_interface(const char *arg)
 }
 
 /* Display list of possible interfaces that can be used. */
-static void show_interfaces(void)
+static void dump_interfaces(void)
 {
 	char name[RTE_ETH_NAME_MAX_LEN];
 	uint16_t p;
@@ -266,6 +268,8 @@ static void show_interfaces(void)
 			continue;
 		printf("%u. %s\n", p, name);
 	}
+
+	exit(0);
 }
 
 static void compile_filter(void)
@@ -353,8 +357,8 @@ static void parse_opts(int argc, char **argv)
 			dump_bpf = true;
 			break;
 		case 'D':
-			show_interfaces();
-			exit(0);
+			show_interfaces = true;
+			break;
 		case 'f':
 			filter_str = optarg;
 			break;
@@ -529,9 +533,6 @@ static void dpdk_init(void)
 
 	if (rte_eal_init(eal_argc, eal_argv) < 0)
 		rte_exit(EXIT_FAILURE, "EAL init failed: is primary process running?\n");
-
-	if (rte_eth_dev_count_avail() == 0)
-		rte_exit(EXIT_FAILURE, "No Ethernet ports found\n");
 }
 
 /* Create packet ring shared between callbacks and process */
@@ -789,6 +790,12 @@ int main(int argc, char **argv)
 	parse_opts(argc, argv);
 	dpdk_init();
 
+	if (show_interfaces)
+		dump_interfaces();
+
+	if (rte_eth_dev_count_avail() == 0)
+		rte_exit(EXIT_FAILURE, "No Ethernet ports found\n");
+
 	if (filter_str)
 		compile_filter();
 
-- 
2.35.1


             reply	other threads:[~2022-09-25 23:34 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-25 23:34 Stephen Hemminger [this message]
2022-09-29 13:22 ` Pattan, Reshma
2022-10-10  0:04   ` Thomas Monjalon
2022-10-04 15:25 ` Kaur, Arshdeep

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=20220925233410.98051-1-stephen@networkplumber.org \
    --to=stephen@networkplumber.org \
    --cc=dev@dpdk.org \
    --cc=koncept1@gmail.com \
    --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).