Skip to content

Commit 111dcba

Browse files
mkubecekdavem330
authored andcommitted
ethtool: add PRIVFLAGS_NTF notification
Send ETHTOOL_MSG_PRIVFLAGS_NTF notification whenever private flags of a network device are modified using ETHTOOL_MSG_PRIVFLAGS_SET netlink message or ETHTOOL_SPFLAGS ioctl request. Signed-off-by: Michal Kubecek <mkubecek@suse.cz> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f265d79 commit 111dcba

4 files changed

Lines changed: 8 additions & 0 deletions

File tree

‎include/uapi/linux/ethtool_netlink.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ enum {
5151
ETHTOOL_MSG_FEATURES_SET_REPLY,
5252
ETHTOOL_MSG_FEATURES_NTF,
5353
ETHTOOL_MSG_PRIVFLAGS_GET_REPLY,
54+
ETHTOOL_MSG_PRIVFLAGS_NTF,
5455

5556
/* add new constants above here */
5657
__ETHTOOL_MSG_KERNEL_CNT,

‎net/ethtool/ioctl.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2716,6 +2716,8 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
27162716
case ETHTOOL_GPFLAGS:
27172717
rc = ethtool_get_value(dev, useraddr, ethcmd,
27182718
dev->ethtool_ops->get_priv_flags);
2719+
if (!rc)
2720+
ethtool_notify(dev, ETHTOOL_MSG_PRIVFLAGS_NTF, NULL);
27192721
break;
27202722
case ETHTOOL_SPFLAGS:
27212723
rc = ethtool_set_value(dev, useraddr,

‎net/ethtool/netlink.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,7 @@ ethnl_default_notify_ops[ETHTOOL_MSG_KERNEL_MAX + 1] = {
530530
[ETHTOOL_MSG_DEBUG_NTF] = &ethnl_debug_request_ops,
531531
[ETHTOOL_MSG_WOL_NTF] = &ethnl_wol_request_ops,
532532
[ETHTOOL_MSG_FEATURES_NTF] = &ethnl_features_request_ops,
533+
[ETHTOOL_MSG_PRIVFLAGS_NTF] = &ethnl_privflags_request_ops,
533534
};
534535

535536
/* default notification handler */
@@ -616,6 +617,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
616617
[ETHTOOL_MSG_DEBUG_NTF] = ethnl_default_notify,
617618
[ETHTOOL_MSG_WOL_NTF] = ethnl_default_notify,
618619
[ETHTOOL_MSG_FEATURES_NTF] = ethnl_default_notify,
620+
[ETHTOOL_MSG_PRIVFLAGS_NTF] = ethnl_default_notify,
619621
};
620622

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

‎net/ethtool/privflags.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ int ethnl_set_privflags(struct sk_buff *skb, struct genl_info *info)
194194
if (ret < 0 || !mod)
195195
goto out_free;
196196
ret = ops->set_priv_flags(dev, flags);
197+
if (ret < 0)
198+
goto out_free;
199+
ethtool_notify(dev, ETHTOOL_MSG_PRIVFLAGS_NTF, NULL);
197200

198201
out_free:
199202
kfree(names);

0 commit comments

Comments
 (0)