Netdev List
 help / color / mirror / Atom feed
* [PATCH net v1 1/1] ethtool: fix clearing of WoL flags
@ 2023-10-19  7:09 Oleksij Rempel
  2023-10-19  9:05 ` Michal Kubecek
  0 siblings, 1 reply; 11+ messages in thread
From: Oleksij Rempel @ 2023-10-19  7:09 UTC (permalink / raw)
  To: David S. Miller, Andrew Lunn, Eric Dumazet, Florian Fainelli,
	Jakub Kicinski, Paolo Abeni, Vladimir Oltean
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev, Michal Kubecek

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


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-10-19 17:34 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox