[2/6] app/dumpcap: fix storing port identifier

Message ID 20230102162441.6205-2-koncept1@gmail.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series [1/6] app/dumpcap: add additional dump info |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Ben Magistro Jan. 2, 2023, 4:24 p.m. UTC
  When dumpcap adds an interface, the port was not being preserved. This
results in the structure being initialized and the port field being set
to 0 regardless of what port was actually selected. This unset field is
then used in both the enable and cleanup calls. This could result in the
capture occurring on the wrong interface.

Fixes: d59fb4d ("app/dumpcap: add new packet capture application")
Cc: stephen@networkplumber.org
Cc: stable@dpdk.org

Signed-off-by: Ben Magistro <koncept1@gmail.com>
---
 app/dumpcap/main.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Stephen Hemminger Jan. 2, 2023, 4:58 p.m. UTC | #1
On Mon,  2 Jan 2023 16:24:37 +0000
Ben Magistro <koncept1@gmail.com> wrote:

> When dumpcap adds an interface, the port was not being preserved. This
> results in the structure being initialized and the port field being set
> to 0 regardless of what port was actually selected. This unset field is
> then used in both the enable and cleanup calls. This could result in the
> capture occurring on the wrong interface.
> 
> Fixes: d59fb4d ("app/dumpcap: add new packet capture application")
> Cc: stephen@networkplumber.org
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ben Magistro <koncept1@gmail.com>
> ---
>  app/dumpcap/main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
> index b9096f050c..aaee9349b1 100644
> --- a/app/dumpcap/main.c
> +++ b/app/dumpcap/main.c
> @@ -202,6 +202,7 @@ static void add_interface(uint16_t port, const char *name)
>  		rte_exit(EXIT_FAILURE, "no memory for interface\n");
>  
>  	memset(intf, 0, sizeof(*intf));
> +	intf->port = port;
>  	rte_strscpy(intf->name, name, sizeof(intf->name));
>  
>  	printf("Capturing on '%s'\n", name);

Will be superseded by my fixes to port setup.
  
Stephen Hemminger Jan. 4, 2023, 3:04 a.m. UTC | #2
On Mon,  2 Jan 2023 16:24:37 +0000
Ben Magistro <koncept1@gmail.com> wrote:

> When dumpcap adds an interface, the port was not being preserved. This
> results in the structure being initialized and the port field being set
> to 0 regardless of what port was actually selected. This unset field is
> then used in both the enable and cleanup calls. This could result in the
> capture occurring on the wrong interface.
> 
> Fixes: d59fb4d ("app/dumpcap: add new packet capture application")
> Cc: stephen@networkplumber.org
> Cc: stable@dpdk.org
> 
> Signed-off-by: Ben Magistro <koncept1@gmail.com>
> ---
>  app/dumpcap/main.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
> index b9096f050c..aaee9349b1 100644
> --- a/app/dumpcap/main.c
> +++ b/app/dumpcap/main.c
> @@ -202,6 +202,7 @@ static void add_interface(uint16_t port, const char *name)
>  		rte_exit(EXIT_FAILURE, "no memory for interface\n");
>  
>  	memset(intf, 0, sizeof(*intf));
> +	intf->port = port;
>  	rte_strscpy(intf->name, name, sizeof(intf->name));
>  
>  	printf("Capturing on '%s'\n", name);

LGTM
Already set in the fix patch set
  

Patch

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index b9096f050c..aaee9349b1 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -202,6 +202,7 @@  static void add_interface(uint16_t port, const char *name)
 		rte_exit(EXIT_FAILURE, "no memory for interface\n");
 
 	memset(intf, 0, sizeof(*intf));
+	intf->port = port;
 	rte_strscpy(intf->name, name, sizeof(intf->name));
 
 	printf("Capturing on '%s'\n", name);