mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Oleksij Rempel <o.rempel@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Oleksij Rempel <o.rempel@pengutronix.de>
Subject: [PATCH v3 3/8] ethlog: option to enable/disable promisc mode
Date: Mon,  7 Nov 2022 12:16:56 +0100	[thread overview]
Message-ID: <20221107111701.2570303-3-o.rempel@pengutronix.de> (raw)
In-Reply-To: <20221107111701.2570303-1-o.rempel@pengutronix.de>

Add -p option to control promisc mode of the ethrnet device.
Example:
ethlog -p eth0 - will enable promisc mode and logging on the eth0
device
ethlog -rp eth0 - will disable promisc mode and logging on the eth0
device

All the same commands without "-p" option will not touch promisc
configuration.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 commands/ethlog.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

diff --git a/commands/ethlog.c b/commands/ethlog.c
index 0cc93ba808..7885d32c6b 100644
--- a/commands/ethlog.c
+++ b/commands/ethlog.c
@@ -29,11 +29,14 @@ static int do_ethlog(int argc, char *argv[])
 {
 	struct eth_device *edev;
 	const char *edevname;
-	bool remove = false;
-	int opt;
+	bool remove = false, promisc = false;
+	int opt, ret;
 
-	while ((opt = getopt(argc, argv, "r")) > 0) {
+	while ((opt = getopt(argc, argv, "pr")) > 0) {
 		switch (opt) {
+		case 'p':
+			promisc = true;
+			break;
 		case 'r':
 			remove = true;
 			break;
@@ -56,10 +59,19 @@ static int do_ethlog(int argc, char *argv[])
 	if (remove) {
 		edev->tx_monitor = NULL;
 		edev->rx_monitor = NULL;
+		if (promisc)
+			eth_set_promisc(edev, false);
 
 		return 0;
 	}
 
+	if (promisc) {
+		ret = eth_set_promisc(edev, true);
+		if (ret)
+			dev_warn(&edev->dev, "Failed to set promisc mode: %pe\n",
+				 ERR_PTR(ret));
+	}
+
 	edev->tx_monitor = ethlog_tx_monitor;
 	edev->rx_monitor = ethlog_rx_monitor;
 
@@ -69,12 +81,13 @@ static int do_ethlog(int argc, char *argv[])
 BAREBOX_CMD_HELP_START(ethlog)
 BAREBOX_CMD_HELP_TEXT("Options:")
 BAREBOX_CMD_HELP_OPT("-r", "remove log handler from Ethernet interface")
+BAREBOX_CMD_HELP_OPT("-p", "Enable promisc mode, or disable if -r is used")
 BAREBOX_CMD_HELP_END
 
 BAREBOX_CMD_START(ethlog)
 	.cmd		= do_ethlog,
 	BAREBOX_CMD_DESC("ETHLOG - tool to get dump of Ethernet packets")
-	BAREBOX_CMD_OPTS("[-r] [device]")
+	BAREBOX_CMD_OPTS("[-rp] [device]")
 	BAREBOX_CMD_GROUP(CMD_GRP_NET)
 	BAREBOX_CMD_COMPLETE(eth_complete)
 BAREBOX_CMD_END
-- 
2.30.2




  parent reply	other threads:[~2022-11-07 11:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-07 11:16 [PATCH v3 1/8] net: add promiscuous mode configuration support Oleksij Rempel
2022-11-07 11:16 ` [PATCH v3 2/8] net: usb: asix: add promisc mode support Oleksij Rempel
2022-11-07 11:16 ` Oleksij Rempel [this message]
2022-11-07 11:16 ` [PATCH v3 4/8] net: dsa: enable promiscuous mode for switch master edev Oleksij Rempel
2022-11-07 11:16 ` [PATCH v3 5/8] drivers: net: fec_imx: add promiscuous mode configuration support Oleksij Rempel
2022-11-07 13:04   ` Johannes Zink
2022-11-07 11:16 ` [PATCH v3 6/8] net: dsa: fix of_device_ensure_probed*() for switch ports Oleksij Rempel
2022-11-07 13:05   ` Johannes Zink
2022-11-07 11:17 ` [PATCH v3 7/8] ARM: boards: skov-imx6: convert all pr_ to dev_ prints Oleksij Rempel
2022-11-07 11:17 ` [PATCH v3 8/8] ARM: boards: skov-imx6: assigned separate MAC address to LAN2 Oleksij Rempel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221107111701.2570303-3-o.rempel@pengutronix.de \
    --to=o.rempel@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox