[1/6] app/dumpcap: add additional dump info
Checks
Commit Message
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(-)
Comments
On Mon, 2 Jan 2023 16:24:36 +0000
Ben Magistro <koncept1@gmail.com> wrote:
> 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>
The output format was designed to be the same as dumpcap,
if you want more info use procinfo.
$ dumpcap -D
1. enp2s0
2. any
3. lo (Loopback)
4. wlo1
5. bluetooth0
6. bluetooth-monitor
7. nflog
8. nfqueue
9. dbus-system
10. dbus-session
Testing a fix now for multiple interfaces.
On Mon, 2 Jan 2023 16:24:36 +0000
Ben Magistro <koncept1@gmail.com> wrote:
> 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>
I prefer to keep the similar output format to wireshark dumpcap
I.e:
$ dumpcap -D
1. enp2s0
2. any
3. lo (Loopback)
4. wlo1
5. bluetooth0
6. bluetooth-monitor
7. nflog
8. nfqueue
9. dbus-system
10. dbus-session
With testpmd running with three interfaces
# dpdk-dumpcap -D
0. net_null0
1. net_null1
2. net_null2
@@ -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);
@@ -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