Commit 67bffa79 authored by Michal Kubecek's avatar Michal Kubecek Committed by David S. Miller

ethtool: add WOL_NTF notification

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: default avatarMichal Kubecek <mkubecek@suse.cz>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 8d425b19
...@@ -193,7 +193,7 @@ Userspace to kernel: ...@@ -193,7 +193,7 @@ Userspace to kernel:
Kernel to userspace: Kernel to userspace:
===================================== ================================ ===================================== =================================
``ETHTOOL_MSG_STRSET_GET_REPLY`` string set contents ``ETHTOOL_MSG_STRSET_GET_REPLY`` string set contents
``ETHTOOL_MSG_LINKINFO_GET_REPLY`` link settings ``ETHTOOL_MSG_LINKINFO_GET_REPLY`` link settings
``ETHTOOL_MSG_LINKINFO_NTF`` link settings notification ``ETHTOOL_MSG_LINKINFO_NTF`` link settings notification
...@@ -203,7 +203,8 @@ Kernel to userspace: ...@@ -203,7 +203,8 @@ Kernel to userspace:
``ETHTOOL_MSG_DEBUG_GET_REPLY`` debugging settings ``ETHTOOL_MSG_DEBUG_GET_REPLY`` debugging settings
``ETHTOOL_MSG_DEBUG_NTF`` debugging settings notification ``ETHTOOL_MSG_DEBUG_NTF`` debugging settings notification
``ETHTOOL_MSG_WOL_GET_REPLY`` wake-on-lan settings ``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 ``GET`` requests are sent by userspace applications to retrieve device
information. They usually do not contain any message specific attributes. information. They usually do not contain any message specific attributes.
......
...@@ -42,6 +42,7 @@ enum { ...@@ -42,6 +42,7 @@ enum {
ETHTOOL_MSG_DEBUG_GET_REPLY, ETHTOOL_MSG_DEBUG_GET_REPLY,
ETHTOOL_MSG_DEBUG_NTF, ETHTOOL_MSG_DEBUG_NTF,
ETHTOOL_MSG_WOL_GET_REPLY, ETHTOOL_MSG_WOL_GET_REPLY,
ETHTOOL_MSG_WOL_NTF,
/* add new constants above here */ /* add new constants above here */
__ETHTOOL_MSG_KERNEL_CNT, __ETHTOOL_MSG_KERNEL_CNT,
......
...@@ -1316,6 +1316,7 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr) ...@@ -1316,6 +1316,7 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
return ret; return ret;
dev->wol_enabled = !!wol.wolopts; dev->wol_enabled = !!wol.wolopts;
ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL);
return 0; return 0;
} }
......
...@@ -526,6 +526,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = { ...@@ -526,6 +526,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = {
[ETHTOOL_MSG_LINKINFO_NTF] = &ethnl_linkinfo_request_ops, [ETHTOOL_MSG_LINKINFO_NTF] = &ethnl_linkinfo_request_ops,
[ETHTOOL_MSG_LINKMODES_NTF] = &ethnl_linkmodes_request_ops, [ETHTOOL_MSG_LINKMODES_NTF] = &ethnl_linkmodes_request_ops,
[ETHTOOL_MSG_DEBUG_NTF] = &ethnl_debug_request_ops, [ETHTOOL_MSG_DEBUG_NTF] = &ethnl_debug_request_ops,
[ETHTOOL_MSG_WOL_NTF] = &ethnl_wol_request_ops,
}; };
/* default notification handler */ /* default notification handler */
...@@ -610,6 +611,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = { ...@@ -610,6 +611,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
[ETHTOOL_MSG_LINKINFO_NTF] = ethnl_default_notify, [ETHTOOL_MSG_LINKINFO_NTF] = ethnl_default_notify,
[ETHTOOL_MSG_LINKMODES_NTF] = ethnl_default_notify, [ETHTOOL_MSG_LINKMODES_NTF] = ethnl_default_notify,
[ETHTOOL_MSG_DEBUG_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) void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)
......
...@@ -41,7 +41,8 @@ static int wol_prepare_data(const struct ethnl_req_info *req_base, ...@@ -41,7 +41,8 @@ static int wol_prepare_data(const struct ethnl_req_info *req_base,
return ret; return ret;
dev->ethtool_ops->get_wol(dev, &data->wol); dev->ethtool_ops->get_wol(dev, &data->wol);
ethnl_ops_complete(dev); 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; return 0;
} }
...@@ -165,6 +166,7 @@ int ethnl_set_wol(struct sk_buff *skb, struct genl_info *info) ...@@ -165,6 +166,7 @@ int ethnl_set_wol(struct sk_buff *skb, struct genl_info *info)
if (ret) if (ret)
goto out_ops; goto out_ops;
dev->wol_enabled = !!wol.wolopts; dev->wol_enabled = !!wol.wolopts;
ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL);
out_ops: out_ops:
ethnl_ops_complete(dev); ethnl_ops_complete(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment