Received: by 2002:a05:7412:f690:b0:e2:908c:2ebd with SMTP id ej16csp169138rdb; Thu, 19 Oct 2023 00:09:33 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuWKsCvDAmMJJjlkmmBq2yJHUGP7Ajo8g3vXtOrOAYEZejjR2lQ8qrwtiVhQw1tDYmScMw X-Received: by 2002:a05:6359:660a:b0:168:9d60:e6b4 with SMTP id sm10-20020a056359660a00b001689d60e6b4mr1128886rwb.16.1697699373236; Thu, 19 Oct 2023 00:09:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699373; cv=none; d=google.com; s=arc-20160816; b=f2Nv6DN981UmKBWlgjlYG91NlowrvF+WzQpsV7vyR0qlNuZKTliIO/04fB0JyHXHjk p+Tf5vaHWby1mXakEeiUR9Ay8MTwXQIM6rUbhFkQNMWiIMVCPti9vSbOudWt/bBJThpz 1Ir7v4gyVkaSncTNaqo/Nt0jP+JrWO9EfXSZOddCLgymk25dim3GS4sAi6VTeJ7qiOL5 eKgft/qDgRzoeeYUW3Un1r/Nz9ux8xTdYpatKDSsPu4OSdriKOPWlJGauzXVa9oZXYbC FICnp0QtAEQPsakkV5mkgORtEp5Ue852/KBj88gptTfr3tLl7BOqqVxGy9RlmZhvOewN pyHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=AyaguX9Tpy5Bc1NFKO9stnqZuhyYRzNz1jx6zc0YRVk=; fh=zGUwd9DyZCpxGeUVRDt+VUsI1fxalPlncSMLzdB+iW4=; b=IdNKhHTb8KPE+Vd8vH/EO07DefpP6aOuuZaNm02bYkfiXCQmrL6M2nab1wnqkbaUwL lZ7NnP+tTcTHKhv8HXn8EoMKff6mEwgOHK94irb7hl0Dqj2THH4UOgqw/+3wpAIDBgqp 3Qy/AuIsU1BW11w3Z45ZYYhHb3fOBHs6BBW0VT88ZqU4H++aEJyLktpr1wB9C4r9muJ2 i3L6KuDEWGT+0vYL6J9BW0zS6Zs2J7C7meOHDG3dFrrO9gZVCyTnr+p6hG91AGpohgIO V84V8xhpZJUdf6g721TGqOaC0OHqyXryRLaa5tFvJ8Mu9ow6RpmnQCjo7NqFhQQcBKTb 7gPQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id i29-20020a056a00005d00b006ba8478b96fsi5378932pfk.30.2023.10.19.00.09.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 00:09:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 13988826E699; Thu, 19 Oct 2023 00:09:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344808AbjJSHJU (ORCPT + 99 others); Thu, 19 Oct 2023 03:09:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344804AbjJSHJQ (ORCPT ); Thu, 19 Oct 2023 03:09:16 -0400 Received: from metis.whiteo.stw.pengutronix.de (metis.whiteo.stw.pengutronix.de [IPv6:2a0a:edc0:2:b01:1d::104]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 824AF11B for ; Thu, 19 Oct 2023 00:09:14 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qtN9X-0002RO-TQ; Thu, 19 Oct 2023 09:09:07 +0200 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qtN9W-002jpd-Oi; Thu, 19 Oct 2023 09:09:06 +0200 Received: from ore by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qtN9W-002Bj7-2H; Thu, 19 Oct 2023 09:09:06 +0200 From: Oleksij Rempel To: "David S. Miller" , Andrew Lunn , Eric Dumazet , Florian Fainelli , Jakub Kicinski , Paolo Abeni , Vladimir Oltean Cc: Oleksij Rempel , kernel@pengutronix.de, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, Michal Kubecek Subject: [PATCH net v1 1/1] ethtool: fix clearing of WoL flags Date: Thu, 19 Oct 2023 09:09:04 +0200 Message-Id: <20231019070904.521718-1-o.rempel@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (morse.vger.email [0.0.0.0]); Thu, 19 Oct 2023 00:09:31 -0700 (PDT) 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 --- 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