Netdev List
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: Oleksij Rempel <o.rempel@pengutronix.de>
Cc: Kory Maincent <kory.maincent@bootlin.com>,
	"David S. Miller" <davem@davemloft.net>,
	Andrew Lunn <andrew@lunn.ch>, Eric Dumazet <edumazet@google.com>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Vladimir Oltean <olteanv@gmail.com>,
	kernel@pengutronix.de, linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org
Subject: Re: [PATCH net v1 1/1] ethtool: fix clearing of WoL flags
Date: Thu, 19 Oct 2023 11:05:10 +0200	[thread overview]
Message-ID: <20231019090510.bbcmh7stzqqgchdd@lion.mk-sys.cz> (raw)
In-Reply-To: <20231019070904.521718-1-o.rempel@pengutronix.de>

[-- Attachment #1: Type: text/plain, Size: 2365 bytes --]

On Thu, Oct 19, 2023 at 09:09:04AM +0200, Oleksij Rempel wrote:
> With current kernel it is possible to set flags, but not possible to remove
> existing WoL flags. For example:
> ~$ ethtool lan2
> ...
>         Supports Wake-on: pg
>         Wake-on: d
> ...
> ~$ ethtool -s lan2 wol gp
> ~$ ethtool lan2
> ...
>         Wake-on: pg
> ...
> ~$ ethtool -s lan2 wol d
> ~$ ethtool lan2
> ...
>         Wake-on: pg
> ...
> 
> This patch makes it work as expected
> 
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  net/ethtool/wol.c | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/net/ethtool/wol.c b/net/ethtool/wol.c
> index 0ed56c9ac1bc..fcefc1bbfa2e 100644
> --- a/net/ethtool/wol.c
> +++ b/net/ethtool/wol.c
> @@ -108,15 +108,16 @@ ethnl_set_wol(struct ethnl_req_info *req_info, struct genl_info *info)
>  	struct net_device *dev = req_info->dev;
>  	struct nlattr **tb = info->attrs;
>  	bool mod = false;
> +	u32 wolopts = 0;
>  	int ret;
>  
>  	dev->ethtool_ops->get_wol(dev, &wol);
> -	ret = ethnl_update_bitset32(&wol.wolopts, WOL_MODE_COUNT,
> +	ret = ethnl_update_bitset32(&wolopts, WOL_MODE_COUNT,
>  				    tb[ETHTOOL_A_WOL_MODES], wol_mode_names,
>  				    info->extack, &mod);
>  	if (ret < 0)
>  		return ret;
> -	if (wol.wolopts & ~wol.supported) {
> +	if (wolopts & ~wol.supported) {
>  		NL_SET_ERR_MSG_ATTR(info->extack, tb[ETHTOOL_A_WOL_MODES],
>  				    "cannot enable unsupported WoL mode");
>  		return -EINVAL;
> @@ -132,8 +133,9 @@ ethnl_set_wol(struct ethnl_req_info *req_info, struct genl_info *info)
>  				    tb[ETHTOOL_A_WOL_SOPASS], &mod);
>  	}
>  
> -	if (!mod)
> +	if (!mod && wolopts == wol.wolopts)
>  		return 0;
> +	wol.wolopts = wolopts;
>  	ret = dev->ethtool_ops->set_wol(dev, &wol);
>  	if (ret)
>  		return ret;
> -- 
> 2.39.2

This doesn't look right, AFAICS with this patch, the resulting WoL flags
would not depend on current values at all, i.e. it would certainly break
non-absolute commands like

  ethtool -s eth0 wol +g
  ethtool -s eth0 wol -u+g
  ethtool -s etho wol 32/34

How recent was the kernel where you encountered the issue? I suspect the
issue might be related to recent 108a36d07c01 ("ethtool: Fix mod state
of verbose no_mask bitset"), I'll look into it closer.

Michal

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

  reply	other threads:[~2023-10-19  9:05 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-19  7:09 [PATCH net v1 1/1] ethtool: fix clearing of WoL flags Oleksij Rempel
2023-10-19  9:05 ` Michal Kubecek [this message]
2023-10-19  9:12   ` Oleksij Rempel
2023-10-19  9:51   ` Michal Kubecek
2023-10-19 10:21     ` Köry Maincent
2023-10-19 10:50       ` Michal Kubecek
2023-10-19 10:54         ` Michal Kubecek
2023-10-19 13:27         ` Köry Maincent
2023-10-19 16:20           ` Florian Fainelli
2023-10-19 16:45             ` Michal Kubecek
2023-10-19 17:34               ` Florian Fainelli

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=20231019090510.bbcmh7stzqqgchdd@lion.mk-sys.cz \
    --to=mkubecek@suse.cz \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=f.fainelli@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=kory.maincent@bootlin.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.com \
    /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