[v2] dumpcap: correctly disable promiscuous mode at exit

Message ID 20240307223851.5786-1-stephen@networkplumber.org (mailing list archive)
State Accepted, archived
Delegated to: Thomas Monjalon
Headers
Series [v2] dumpcap: correctly disable promiscuous mode at exit |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS

Commit Message

Stephen Hemminger March 7, 2024, 10:37 p.m. UTC
  From: Isaac Boukris <iboukris@gmail.com>

If request to set promiscious mode failed at startup,
then it is not necessary to disable it when shutting down.

This should only be issue if with a buggy driver because if
driver does not support setting promiscious it would just
ignore request to disable it as well.

Fixes: 6026bfae07d4 ("app/dumpcap: support multiple interfaces")
Signed-off-by: Isaac Boukris <iboukris@gmail.com>
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
---
v2 - add more to commit log, and simplify the logic

 app/dumpcap/main.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
  

Comments

Isaac Boukris March 8, 2024, 7:09 a.m. UTC | #1
On Fri, Mar 8, 2024 at 12:39 AM Stephen Hemminger
<stephen@networkplumber.org> wrote:
>
> From: Isaac Boukris <iboukris@gmail.com>
>
> If request to set promiscious mode failed at startup,
> then it is not necessary to disable it when shutting down.
>
> This should only be issue if with a buggy driver because if
> driver does not support setting promiscious it would just
> ignore request to disable it as well.
>
> Fixes: 6026bfae07d4 ("app/dumpcap: support multiple interfaces")
> Signed-off-by: Isaac Boukris <iboukris@gmail.com>
> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v2 - add more to commit log, and simplify the logic
>
>  app/dumpcap/main.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
> index 76c747511444..11e470391edb 100644
> --- a/app/dumpcap/main.c
> +++ b/app/dumpcap/main.c
> @@ -828,12 +828,9 @@ static void enable_pdump(struct rte_ring *r, struct rte_mempool *mp)
>                         if (rte_eth_promiscuous_get(intf->port) == 1) {
>                                 /* promiscuous already enabled */
>                                 intf->opts.promisc_mode = false;
> -                       } else {
> -                               ret = rte_eth_promiscuous_enable(intf->port);
> -                               if (ret != 0)
> -                                       fprintf(stderr,
> -                                               "port %u set promiscuous enable failed: %d\n",
> -                                               intf->port, ret);
> +                       } else if (rte_eth_promiscuous_enable(intf->port) < 0) {
> +                               fprintf(stderr, "port %u:%s set promiscuous failed\n",
> +                                       intf->port, intf->name);
>                                 intf->opts.promisc_mode = false;
>                         }
>                 }
> --
> 2.43.0
>

V2 looks good to me.

Thanks!
  
Thomas Monjalon March 18, 2024, 3:04 a.m. UTC | #2
08/03/2024 08:09, Isaac Boukris:
> On Fri, Mar 8, 2024 at 12:39 AM Stephen Hemminger
> <stephen@networkplumber.org> wrote:
> >
> > From: Isaac Boukris <iboukris@gmail.com>
> >
> > If request to set promiscious mode failed at startup,
> > then it is not necessary to disable it when shutting down.
> >
> > This should only be issue if with a buggy driver because if
> > driver does not support setting promiscious it would just
> > ignore request to disable it as well.
> >
> > Fixes: 6026bfae07d4 ("app/dumpcap: support multiple interfaces")
> > Signed-off-by: Isaac Boukris <iboukris@gmail.com>
> > Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> 
> V2 looks good to me.
> 
> Thanks!

Applied, thanks.
  

Patch

diff --git a/app/dumpcap/main.c b/app/dumpcap/main.c
index 76c747511444..11e470391edb 100644
--- a/app/dumpcap/main.c
+++ b/app/dumpcap/main.c
@@ -828,12 +828,9 @@  static void enable_pdump(struct rte_ring *r, struct rte_mempool *mp)
 			if (rte_eth_promiscuous_get(intf->port) == 1) {
 				/* promiscuous already enabled */
 				intf->opts.promisc_mode = false;
-			} else {
-				ret = rte_eth_promiscuous_enable(intf->port);
-				if (ret != 0)
-					fprintf(stderr,
-						"port %u set promiscuous enable failed: %d\n",
-						intf->port, ret);
+			} else if (rte_eth_promiscuous_enable(intf->port) < 0) {
+				fprintf(stderr, "port %u:%s set promiscuous failed\n",
+					intf->port, intf->name);
 				intf->opts.promisc_mode = false;
 			}
 		}