DPDK patches and discussions
 help / color / mirror / Atom feed
From: Ben Magistro <koncept1@gmail.com>
To: dev@dpdk.org, stephen@networkplumber.org
Cc: ben.magistro@trinitycyber.com, Ben Magistro <koncept1@gmail.com>
Subject: [PATCH 1/6] app/dumpcap: add additional dump info
Date: Mon,  2 Jan 2023 16:24:36 +0000	[thread overview]
Message-ID: <20230102162441.6205-1-koncept1@gmail.com> (raw)

This change increases the information returned when listing interfaces
to include link state and promiscuous mode. Additionally, the
information is formatted to be easily consumed by a machine or a person.

This change is/was utilized while troubleshooting and developing the
subsequent patches to address the issues identified on the mailing
list [1].

[1] http://mails.dpdk.org/archives/dev/2022-December/258317.html

Signed-off-by: Ben Magistro <koncept1@gmail.com>
---
 app/dumpcap/main.c           | 27 ++++++++++++++++++++++++++-
 doc/guides/tools/dumpcap.rst |  9 ++++++---
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index 2eb8414efa..b9096f050c 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -266,11 +266,36 @@ static void dump_interfaces(void)
 {
 	char name[RTE_ETH_NAME_MAX_LEN];
 	uint16_t p;
+	struct rte_eth_link link_info;
+	char link_state[8];
+	char promisc_mode[9];
 
+	printf("%-4s\t%-40s\t%-8s\t%-12s\n",
+		"Port", "Name", "Link", "Promiscuous");
 	RTE_ETH_FOREACH_DEV(p) {
 		if (rte_eth_dev_get_name_by_port(p, name) < 0)
 			continue;
-		printf("%u. %s\n", p, name);
+
+		if (rte_eth_link_get_nowait(p, &link_info) < 0) {
+			rte_strscpy(link_state, "Unknown", sizeof(link_state));
+		}
+		else if (link_info.link_status == RTE_ETH_LINK_UP) {
+			rte_strscpy(link_state, "Up", sizeof(link_state));
+		}
+		else {
+			rte_strscpy(link_state, "Down", sizeof(link_state));
+		}
+
+		// not checking error here; should only error if given an invalid port id
+		if (rte_eth_promiscuous_get(p) == 1) {
+			rte_strscpy(promisc_mode, "Enabled", sizeof(promisc_mode));
+		}
+		else {
+			rte_strscpy(promisc_mode, "Disabled", sizeof(promisc_mode));
+		}
+
+		printf("%-4u\t%-40s\t%-8s\t%-12s\n",
+			p, name, link_state, promisc_mode);
 	}
 
 	exit(0);
diff --git a/doc/guides/tools/dumpcap.rst b/doc/guides/tools/dumpcap.rst
index d8a137b1cd..0f89e6c5ca 100644
--- a/doc/guides/tools/dumpcap.rst
+++ b/doc/guides/tools/dumpcap.rst
@@ -39,7 +39,7 @@ If ``-w`` option is specified, then that file is used.
 Running the Application
 -----------------------
 
-To list interfaces available for capture, use ``--list-interfaces``.
+To list interfaces available for capture, use ``-D`` or ``--list-interfaces``.
 
 To filter packets in style of *tshark*, use the ``-f`` flag.
 
@@ -52,8 +52,11 @@ Example
 .. code-block:: console
 
    # <build_dir>/app/dpdk-dumpcap --list-interfaces
-   0. 000:00:03.0
-   1. 000:00:03.1
+   Port    Name                                        Link        Promiscuous
+   0       0000:00:03.0                                Up          Enabled
+   1       0000:00:03.1                                Up          Disabled
+   2       0000:00:03.2                                Down        Disabled
+   3       0000:00:03.3                                Down        Disabled
 
    # <build_dir>/app/dpdk-dumpcap -i 0000:00:03.0 -c 6 -w /tmp/sample.pcapng
    Packets captured: 6
-- 
2.27.0


             reply	other threads:[~2023-01-02 16:25 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-02 16:24 Ben Magistro [this message]
2023-01-02 16:24 ` [PATCH 2/6] app/dumpcap: fix storing port identifier Ben Magistro
2023-01-02 16:58   ` Stephen Hemminger
2023-01-04  3:04   ` Stephen Hemminger
2023-01-02 16:24 ` [PATCH 3/6] app/dumpcap: fix preserving promiscuous mode Ben Magistro
2023-01-02 16:58   ` Stephen Hemminger
2023-01-04  3:04   ` Stephen Hemminger
2023-01-02 16:24 ` [PATCH 4/6] app/dumpcap: fix capturing on multiple interfaces Ben Magistro
2023-01-04  3:01   ` Stephen Hemminger
2023-01-02 16:24 ` [PATCH 5/6] app/dumpcap: improve per interface arg parsing Ben Magistro
2023-01-04  3:04   ` Stephen Hemminger
2023-01-02 16:24 ` [PATCH 6/6] app/dumpcap: refactor add all and default Ben Magistro
2023-01-02 16:57 ` [PATCH 1/6] app/dumpcap: add additional dump info Stephen Hemminger
2023-01-02 17:01 ` [RFT] dumpcap: fix multiple interface and promiscious handling Stephen Hemminger
2023-01-04  2:58 ` [PATCH 1/6] app/dumpcap: add additional dump info Stephen Hemminger
2023-01-04  3:38 ` [PATCH v2 0/6] dumpcap support multiple interfaces Stephen Hemminger
2023-01-04  3:38   ` [PATCH v2 1/6] app/dumpcap: fix storing port identifier Stephen Hemminger
2023-01-04  3:38   ` [PATCH v2 2/6] app/dumpcap: remove unused variable Stephen Hemminger
2023-01-04  3:38   ` [PATCH v2 3/6] app/dumpcap: check for invalid interface name Stephen Hemminger
2023-01-04  3:38   ` [PATCH v2 4/6] app/dumpcap: support multiple interfaces Stephen Hemminger
2023-01-04  3:38   ` [PATCH v2 5/6] pcapng: require per-interface information Stephen Hemminger
2023-01-04  3:38   ` [PATCH v2 6/6] app/dumpcap: support interface name and description Stephen Hemminger
2023-02-06 11:18   ` [PATCH v2 0/6] dumpcap support multiple interfaces 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=20230102162441.6205-1-koncept1@gmail.com \
    --to=koncept1@gmail.com \
    --cc=ben.magistro@trinitycyber.com \
    --cc=dev@dpdk.org \
    --cc=stephen@networkplumber.org \
    /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).