From 81785925d3e2e29b439027050379fa4959500d48 Mon Sep 17 00:00:00 2001 From: Raju Lakkaraju Date: Mon, 4 Mar 2024 16:37:01 +0530 Subject: [PATCH] ethtool: netlink: adding options is incremental d clears everything. All other things enable one option Signed-off-by: Raju Lakkaraju --- net/ethtool/wol.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/net/ethtool/wol.c b/net/ethtool/wol.c index 0ed56c9ac1bc..b5f12f75611b 100644 --- a/net/ethtool/wol.c +++ b/net/ethtool/wol.c @@ -107,16 +107,26 @@ ethnl_set_wol(struct ethnl_req_info *req_info, struct genl_info *info) struct ethtool_wolinfo wol = { .cmd = ETHTOOL_GWOL }; struct net_device *dev = req_info->dev; struct nlattr **tb = info->attrs; + __u32 wolopts = 0; bool mod = false; 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.wolopts |= wolopts; + } else { + wol.wolopts = 0; + memset(&wol.sopass, 0, sizeof(wol.sopass)); + mod = true; + } + + if (wolopts & ~wol.supported) { NL_SET_ERR_MSG_ATTR(info->extack, tb[ETHTOOL_A_WOL_MODES], "cannot enable unsupported WoL mode"); return -EINVAL; -- 2.34.1