Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2923496ybl; Sun, 26 Jan 2020 14:14:27 -0800 (PST) X-Google-Smtp-Source: APXvYqyX0wzMXHprl8Zd8WmcFPv/F5zUdKcluPimzMIAbhNe3RxxHZWoRk9518utJlNQUMiRZ+e1 X-Received: by 2002:a05:6830:10a:: with SMTP id i10mr9911432otp.365.1580076867437; Sun, 26 Jan 2020 14:14:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580076867; cv=none; d=google.com; s=arc-20160816; b=jEMXhVQWk1TB9KLXsxl0Ur+l4ehJfvkIuCjFRIcG8G8II//1aKX0+kfDSD6m5RhpfI 7tzQjBzht4+8DsAvWmt8JkD5n+AwwjyzSUGuOV7NYhDAeLiOH3HA5ZSx4BSeu0JZLk2f +vH5ohv0mU3cvcyuN9FjyZ5NhudqjAY4lwSbdFUxll+azBuu+ikuDVYACv3BXaEeq5ui d+/mP2/O8uv/KBIJ6slNnSti9mt5tD35uwbSZJ9Li2B/sBXedaruulechnNFvSFKvUZG k3oNk7oIM2EBEn5uo8WJ304yNN3RbR+9s5NiA+pqr+ayB22JC7HaP68sws+6DjLljTCQ W77Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:date:cc:to:subject:from:references :in-reply-to:message-id; bh=G+CgmR1ymSUGbPZ/Q2oR+mTmKMQURDFHdhuuEm7FmeE=; b=amVXC5ChqvX6Jq7Oj53UXJj/ca5OUQ9yTcHcS0jvkzlGHonBVQqqbKlRDLl+1WICmT yeYwYMsgALjYFMHV8tP29nClB8NY45GD1l4YumNOggG7kOPXdUsTqf/MoJrI3D+P9kGN X4NYiQdhG/UbushaQugIROb4bt/3/4InheE4knipuLXZebKqY87WN0GKOJukUiHmcQM/ lSU1rU2GLo4ePNlrCm71IxZVyl8m9e/1OLi/o7wwqnY1Qf+6tAMRO6nZMzrBz6i9h/gz F4FXQdfrZ7jpaMHbvvzX7Nd7rzK0oZslTiJSBONXdAM+CgbPbiHIv9fsGxbCcMm/LReN azug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x20si2486120oix.155.2020.01.26.14.14.15; Sun, 26 Jan 2020 14:14:27 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729308AbgAZWLY (ORCPT + 99 others); Sun, 26 Jan 2020 17:11:24 -0500 Received: from mx2.suse.de ([195.135.220.15]:43770 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729159AbgAZWLW (ORCPT ); Sun, 26 Jan 2020 17:11:22 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 0415DAE2C; Sun, 26 Jan 2020 22:11:19 +0000 (UTC) Received: by unicorn.suse.cz (Postfix, from userid 1000) id A748EE06B1; Sun, 26 Jan 2020 23:11:19 +0100 (CET) Message-Id: <31ad6c1e5db5601cebf01a1f011cf39ea0ce9e4d.1580075977.git.mkubecek@suse.cz> In-Reply-To: References: From: Michal Kubecek Subject: [PATCH net-next 7/7] ethtool: add WOL_NTF notification To: David Miller , netdev@vger.kernel.org Cc: Jakub Kicinski , Jiri Pirko , Andrew Lunn , Florian Fainelli , John Linville , Johannes Berg , linux-kernel@vger.kernel.org Date: Sun, 26 Jan 2020 23:11:19 +0100 (CET) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Send ETHTOOL_MSG_WOL_NTF notification whenever wake-on-lan settings of a device are modified using ETHTOOL_MSG_WOL_SET netlink message or ETHTOOL_SWOL ioctl request. As notifications can be received by anyone, do not include SecureOn(tm) password in notification messages. Signed-off-by: Michal Kubecek --- Documentation/networking/ethtool-netlink.rst | 5 +++-- include/uapi/linux/ethtool_netlink.h | 1 + net/ethtool/ioctl.c | 1 + net/ethtool/netlink.c | 2 ++ net/ethtool/wol.c | 4 +++- 5 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/ethtool-netlink.rst b/Documentation/networking/ethtool-netlink.rst index f16f74bbb546..f1f868479ceb 100644 --- a/Documentation/networking/ethtool-netlink.rst +++ b/Documentation/networking/ethtool-netlink.rst @@ -193,7 +193,7 @@ Userspace to kernel: Kernel to userspace: - ===================================== ================================ + ===================================== ================================= ``ETHTOOL_MSG_STRSET_GET_REPLY`` string set contents ``ETHTOOL_MSG_LINKINFO_GET_REPLY`` link settings ``ETHTOOL_MSG_LINKINFO_NTF`` link settings notification @@ -203,7 +203,8 @@ Kernel to userspace: ``ETHTOOL_MSG_DEBUG_GET_REPLY`` debugging settings ``ETHTOOL_MSG_DEBUG_NTF`` debugging settings notification ``ETHTOOL_MSG_WOL_GET_REPLY`` wake-on-lan settings - ===================================== ================================ + ``ETHTOOL_MSG_WOL_NTF`` wake-on-lan settings notification + ===================================== ================================= ``GET`` requests are sent by userspace applications to retrieve device information. They usually do not contain any message specific attributes. diff --git a/include/uapi/linux/ethtool_netlink.h b/include/uapi/linux/ethtool_netlink.h index 59de35695521..7e0b460f872c 100644 --- a/include/uapi/linux/ethtool_netlink.h +++ b/include/uapi/linux/ethtool_netlink.h @@ -42,6 +42,7 @@ enum { ETHTOOL_MSG_DEBUG_GET_REPLY, ETHTOOL_MSG_DEBUG_NTF, ETHTOOL_MSG_WOL_GET_REPLY, + ETHTOOL_MSG_WOL_NTF, /* add new constants above here */ __ETHTOOL_MSG_KERNEL_CNT, diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index 46e0b31782fc..b88dd14e41c6 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -1316,6 +1316,7 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) return ret; dev->wol_enabled = !!wol.wolopts; + ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL); return 0; } diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c index 2c375f9095fe..180c194fab07 100644 --- a/net/ethtool/netlink.c +++ b/net/ethtool/netlink.c @@ -526,6 +526,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { [ETHTOOL_MSG_LINKINFO_NTF] = ðnl_linkinfo_request_ops, [ETHTOOL_MSG_LINKMODES_NTF] = ðnl_linkmodes_request_ops, [ETHTOOL_MSG_DEBUG_NTF] = ðnl_debug_request_ops, + [ETHTOOL_MSG_WOL_NTF] = ðnl_wol_request_ops, }; /* default notification handler */ @@ -610,6 +611,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { [ETHTOOL_MSG_LINKINFO_NTF] = ethnl_default_notify, [ETHTOOL_MSG_LINKMODES_NTF] = ethnl_default_notify, [ETHTOOL_MSG_DEBUG_NTF] = ethnl_default_notify, + [ETHTOOL_MSG_WOL_NTF] = ethnl_default_notify, }; void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data) diff --git a/net/ethtool/wol.c b/net/ethtool/wol.c index a2724378fac4..e1b8a65b64c4 100644 --- a/net/ethtool/wol.c +++ b/net/ethtool/wol.c @@ -41,7 +41,8 @@ static int wol_prepare_data(const struct ethnl_req_info *req_base, return ret; dev->ethtool_ops->get_wol(dev, &data->wol); ethnl_ops_complete(dev); - data->show_sopass = data->wol.supported & WAKE_MAGICSECURE; + /* do not include password in notifications */ + data->show_sopass = info && (data->wol.supported & WAKE_MAGICSECURE); return 0; } @@ -165,6 +166,7 @@ int ethnl_set_wol(struct sk_buff *skb, struct genl_info *info) if (ret) goto out_ops; dev->wol_enabled = !!wol.wolopts; + ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL); out_ops: ethnl_ops_complete(dev); -- 2.25.0