Skip to content

Commit 67bffa7

Browse files
mkubecekdavem330
authored andcommitted
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: Michal Kubecek <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8d425b1 commit 67bffa7

File tree

5 files changed

+10
-3
lines changed

5 files changed

+10
-3
lines changed

Documentation/networking/ethtool-netlink.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ Userspace to kernel:
193193

194194
Kernel to userspace:
195195

196-
===================================== ================================
196+
===================================== =================================
197197
``ETHTOOL_MSG_STRSET_GET_REPLY`` string set contents
198198
``ETHTOOL_MSG_LINKINFO_GET_REPLY`` link settings
199199
``ETHTOOL_MSG_LINKINFO_NTF`` link settings notification
@@ -203,7 +203,8 @@ Kernel to userspace:
203203
``ETHTOOL_MSG_DEBUG_GET_REPLY`` debugging settings
204204
``ETHTOOL_MSG_DEBUG_NTF`` debugging settings notification
205205
``ETHTOOL_MSG_WOL_GET_REPLY`` wake-on-lan settings
206-
===================================== ================================
206+
``ETHTOOL_MSG_WOL_NTF`` wake-on-lan settings notification
207+
===================================== =================================
207208

208209
``GET`` requests are sent by userspace applications to retrieve device
209210
information. They usually do not contain any message specific attributes.

include/uapi/linux/ethtool_netlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ enum {
4242
ETHTOOL_MSG_DEBUG_GET_REPLY,
4343
ETHTOOL_MSG_DEBUG_NTF,
4444
ETHTOOL_MSG_WOL_GET_REPLY,
45+
ETHTOOL_MSG_WOL_NTF,
4546

4647
/* add new constants above here */
4748
__ETHTOOL_MSG_KERNEL_CNT,

net/ethtool/ioctl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1316,6 +1316,7 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
13161316
return ret;
13171317

13181318
dev->wol_enabled = !!wol.wolopts;
1319+
ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL);
13191320

13201321
return 0;
13211322
}

net/ethtool/netlink.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = {
526526
[ETHTOOL_MSG_LINKINFO_NTF] = &ethnl_linkinfo_request_ops,
527527
[ETHTOOL_MSG_LINKMODES_NTF] = &ethnl_linkmodes_request_ops,
528528
[ETHTOOL_MSG_DEBUG_NTF] = &ethnl_debug_request_ops,
529+
[ETHTOOL_MSG_WOL_NTF] = &ethnl_wol_request_ops,
529530
};
530531

531532
/* default notification handler */
@@ -610,6 +611,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
610611
[ETHTOOL_MSG_LINKINFO_NTF] = ethnl_default_notify,
611612
[ETHTOOL_MSG_LINKMODES_NTF] = ethnl_default_notify,
612613
[ETHTOOL_MSG_DEBUG_NTF] = ethnl_default_notify,
614+
[ETHTOOL_MSG_WOL_NTF] = ethnl_default_notify,
613615
};
614616

615617
void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)

net/ethtool/wol.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ static int wol_prepare_data(const struct ethnl_req_info *req_base,
4141
return ret;
4242
dev->ethtool_ops->get_wol(dev, &data->wol);
4343
ethnl_ops_complete(dev);
44-
data->show_sopass = data->wol.supported & WAKE_MAGICSECURE;
44+
/* do not include password in notifications */
45+
data->show_sopass = info && (data->wol.supported & WAKE_MAGICSECURE);
4546

4647
return 0;
4748
}
@@ -165,6 +166,7 @@ int ethnl_set_wol(struct sk_buff *skb, struct genl_info *info)
165166
if (ret)
166167
goto out_ops;
167168
dev->wol_enabled = !!wol.wolopts;
169+
ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL);
168170

169171
out_ops:
170172
ethnl_ops_complete(dev);

0 commit comments

Comments
 (0)