mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Johannes Zink <j.zink@pengutronix.de>
To: Oleksij Rempel <o.rempel@pengutronix.de>, barebox@lists.infradead.org
Subject: Re: [PATCH v4 3/8] ethlog: option to enable/disable promisc mode
Date: Tue, 08 Nov 2022 07:57:04 +0100	[thread overview]
Message-ID: <9ada8e3bb9efdd25273eeea6c381abf63385c620.camel@pengutronix.de> (raw)
In-Reply-To: <20221108061009.4168735-3-o.rempel@pengutronix.de>

Hi Oleksij,

On Tue, 2022-11-08 at 07:10 +0100, Oleksij Rempel wrote:
> Add -p option to control promisc mode of the ethrnet device.
> 
just found a small typo: s/ethrnet/ethernet/

Best regards
Johannes

> 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

-- 
Pengutronix e.K.                | Johannes Zink                  |
Steuerwalder Str. 21            | https://www.pengutronix.de/    |
31137 Hildesheim, Germany       | Phone: +49-5121-206917-0       |
Amtsgericht Hildesheim, HRA 2686| Fax:   +49-5121-206917-5555    |




  reply	other threads:[~2022-11-08  6:58 UTC|newest]

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

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=9ada8e3bb9efdd25273eeea6c381abf63385c620.camel@pengutronix.de \
    --to=j.zink@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=o.rempel@pengutronix.de \
    /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