dumpcap: fix list interfaces

Message ID 20220925233410.98051-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series dumpcap: fix list interfaces |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-aarch64-unit-testing fail Testing issues
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/github-robot: build fail github build: failed
ci/iol-aarch64-compile-testing fail Testing issues
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/intel-Testing success Testing PASS

Commit Message

Stephen Hemminger Sept. 25, 2022, 11:34 p.m. UTC
  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(-)
  

Comments

Pattan, Reshma Sept. 29, 2022, 1:22 p.m. UTC | #1
> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, September 26, 2022 12:34 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>;
> koncept1@gmail.com; Pattan, Reshma <reshma.pattan@intel.com>
> Subject: [PATCH] dumpcap: fix list interfaces
> 
Acked-by: Reshma Pattan <reshma.pattan@intel.com>
  
Kaur, Arshdeep Oct. 4, 2022, 3:25 p.m. UTC | #2
Hi Stephen,

I tested the patch. "-D" option is now working properly.

But I am facing an issue in this.

Using "-D" provides me with the interfaces available. For me these are "0000:18:01.0" and "0000:18:09.0":
./dpdk-dumpcap -D --file-prefix wls_1
FlexRAN SDK bblib_lte_ldpc_decoder version #DIRTY#
FlexRAN SDK bblib_lte_ldpc_encoder version #DIRTY#
FlexRAN SDK bblib_lte_LDPC_ratematch version #DIRTY#
FlexRAN SDK bblib_lte_rate_dematching_5gnr version #DIRTY#
FlexRAN SDK bblib_lte_turbo version #DIRTY#
FlexRAN SDK bblib_lte_crc version #DIRTY#
FlexRAN SDK bblib_lte_rate_matching version #DIRTY#
FlexRAN SDK bblib_common version #DIRTY#
FlexRAN SDK bblib_srs_fft_cestimate_5gnr version #DIRTY#
FlexRAN SDK bblib_mldts_process_5gnr version #DIRTY#
EAL: 0000:18:01.1 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:18:01.1 cannot be used
EAL: 0000:18:09.1 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:18:09.1 cannot be used
EAL: 0000:18:11.0 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:18:11.0 cannot be used
EAL: 0000:18:11.1 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:18:11.1 cannot be used
EAL: 0000:18:19.0 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:18:19.0 cannot be used
EAL: 0000:18:19.1 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:18:19.1 cannot be used
EAL: 0000:af:01.0 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:af:01.0 cannot be used
EAL: 0000:af:01.1 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:af:01.1 cannot be used
EAL: 0000:af:09.0 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:af:09.0 cannot be used
EAL: 0000:af:09.1 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:af:09.1 cannot be used
EAL: 0000:af:11.0 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:af:11.0 cannot be used
EAL: 0000:af:11.1 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:af:11.1 cannot be used
EAL: 0000:af:19.0 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:af:19.0 cannot be used
EAL: 0000:af:19.1 cannot find TAILQ entry for PCI device!
EAL: Requested device 0000:af:19.1 cannot be used
0. 0000:18:01.0
1. 0000:18:09.0

But when I use these same interfaces to capture, they are not available:
./dpdk-dumpcap -i 0000:18:01.0 -c 500 -s 9600 -w capture1.pacp --file-prefix wls_1
FlexRAN SDK bblib_lte_ldpc_decoder version #DIRTY#
FlexRAN SDK bblib_lte_ldpc_encoder version #DIRTY#
FlexRAN SDK bblib_lte_LDPC_ratematch version #DIRTY#
FlexRAN SDK bblib_lte_rate_dematching_5gnr version #DIRTY#
FlexRAN SDK bblib_lte_turbo version #DIRTY#
FlexRAN SDK bblib_lte_crc version #DIRTY#
FlexRAN SDK bblib_lte_rate_matching version #DIRTY#
FlexRAN SDK bblib_common version #DIRTY#
FlexRAN SDK bblib_srs_fft_cestimate_5gnr version #DIRTY#
FlexRAN SDK bblib_mldts_process_5gnr version #DIRTY#
EAL: Error - exiting with code: 1
  Cause: Specified port_number "0000:18:01.0" is not a valid number

./dpdk-dumpcap -i 0000:18:09.0 -c 500 -s 9600 -w capture2.pacp --file-prefix wls_1
FlexRAN SDK bblib_lte_ldpc_decoder version #DIRTY#
FlexRAN SDK bblib_lte_ldpc_encoder version #DIRTY#
FlexRAN SDK bblib_lte_LDPC_ratematch version #DIRTY#
FlexRAN SDK bblib_lte_rate_dematching_5gnr version #DIRTY#
FlexRAN SDK bblib_lte_turbo version #DIRTY#
FlexRAN SDK bblib_lte_crc version #DIRTY#
FlexRAN SDK bblib_lte_rate_matching version #DIRTY#
FlexRAN SDK bblib_common version #DIRTY#
FlexRAN SDK bblib_srs_fft_cestimate_5gnr version #DIRTY#
FlexRAN SDK bblib_mldts_process_5gnr version #DIRTY#
EAL: Error - exiting with code: 1
  Cause: Specified port_number "0000:18:09.0" is not a valid number

According to me, select_interface() has same issue that dump_interfaces() had. So we need to add a flag for this in similar way and handle select_interface() in main after parse_opts, dpdk_init and dump_interfaces.

I tested this changes and it works for me. But I am not sure how it will affect entire dumpcap. Please let me know your thoughts about it.

Thanks and regards,
Arshdeep Kaur

> -----Original Message-----
> From: Stephen Hemminger <stephen@networkplumber.org>
> Sent: Monday, September 26, 2022 5:04 AM
> To: dev@dpdk.org
> Cc: Stephen Hemminger <stephen@networkplumber.org>;
> koncept1@gmail.com; Pattan, Reshma <reshma.pattan@intel.com>
> Subject: [PATCH] dumpcap: fix list interfaces
> 
> 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
  
Thomas Monjalon Oct. 10, 2022, 12:04 a.m. UTC | #3
> Acked-by: Reshma Pattan <reshma.pattan@intel.com>

Applied, thanks.
  

Patch

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();