[PATCH v2] dumpcap: correctly disable promiscuous mode at exit

Stephen Hemminger stephen at networkplumber.org
Thu Mar 7 23:37:59 CET 2024


From: Isaac Boukris <iboukris at 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 at gmail.com>
Signed-off-by: Stephen Hemminger <stephen at 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



More information about the dev mailing list