netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michal Kubecek <mkubecek@suse.cz>
To: netdev@vger.kernel.org
Cc: David Miller <davem@davemloft.net>, Andrew Lunn <andrew@lunn.ch>,
	Jakub Kicinski <jakub.kicinski@netronome.com>,
	Jiri Pirko <jiri@resnulli.us>,
	linux-kernel@vger.kernel.org
Subject: [RFC PATCH net-next v3 21/21] ethtool: send netlink notifications about setting changes
Date: Mon, 18 Feb 2019 19:23:10 +0100 (CET)	[thread overview]
Message-ID: <73fef81aa207a254ff6a24a60a1910b3c0682af3.1550513384.git.mkubecek@suse.cz> (raw)
In-Reply-To: <cover.1550513384.git.mkubecek@suse.cz>

SET_SETTINGS notification message has the same format as response to
GET_SETTINGS request and is broadcasted on change of relevant fields. Info
mask can be used to limit the information passed to userspace.

Send the notification on changes performed via the legacy ioctl interface;
feature notifications are also sent whenever netdev_update_features() or
netdev_change_features() is called, even if the change was not performed
using the ethtool interface.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 net/ethtool/ioctl.c   | 24 ++++++++++++++++++++++--
 net/ethtool/netlink.c | 12 ++++++++++++
 2 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c
index 6c3b492a88fe..17ccca14f5c3 100644
--- a/net/ethtool/ioctl.c
+++ b/net/ethtool/ioctl.c
@@ -30,6 +30,7 @@
 #include <net/devlink.h>
 #include <net/xdp_sock.h>
 #include <net/flow_offload.h>
+#include <linux/ethtool_netlink.h>
 
 #include "common.h"
 
@@ -567,7 +568,12 @@ static int ethtool_set_link_ksettings(struct net_device *dev,
 	    != link_ksettings.base.link_mode_masks_nwords)
 		return -EINVAL;
 
-	return dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);
+	err = dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);
+	if (err >= 0)
+		ethtool_notify(dev, NULL, ETHNL_CMD_SET_SETTINGS,
+			       ETH_SETTINGS_IM_LINKINFO |
+			       ETH_SETTINGS_IM_LINKMODES, NULL);
+	return err;
 }
 
 /* Query device for its ethtool_cmd settings.
@@ -616,6 +622,7 @@ static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
 {
 	struct ethtool_link_ksettings link_ksettings;
 	struct ethtool_cmd cmd;
+	int ret;
 
 	ASSERT_RTNL();
 
@@ -628,7 +635,12 @@ static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
 		return -EINVAL;
 	link_ksettings.base.link_mode_masks_nwords =
 		__ETHTOOL_LINK_MODE_MASK_NU32;
-	return dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);
+	ret = dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);
+	if (ret >= 0)
+		ethtool_notify(dev, NULL, ETHNL_CMD_SET_SETTINGS,
+			       ETH_SETTINGS_IM_LINKINFO |
+			       ETH_SETTINGS_IM_LINKMODES, NULL);
+	return ret;
 }
 
 static noinline_for_stack int ethtool_get_drvinfo(struct net_device *dev,
@@ -1255,6 +1267,8 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
 		return ret;
 
 	dev->wol_enabled = !!wol.wolopts;
+	ethtool_notify(dev, NULL, ETHNL_CMD_SET_SETTINGS,
+		       ETH_SETTINGS_IM_WOLINFO, NULL);
 
 	return 0;
 }
@@ -2453,6 +2467,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
 	case ETHTOOL_SMSGLVL:
 		rc = ethtool_set_value_void(dev, useraddr,
 				       dev->ethtool_ops->set_msglevel);
+		if (rc >= 0)
+			ethtool_notify(dev, NULL, ETHNL_CMD_SET_SETTINGS,
+				       ETH_SETTINGS_IM_MSGLEVEL, NULL);
 		break;
 	case ETHTOOL_GEEE:
 		rc = ethtool_get_eee(dev, useraddr);
@@ -2519,6 +2536,9 @@ int dev_ethtool(struct net *net, struct ifreq *ifr)
 	case ETHTOOL_SPFLAGS:
 		rc = ethtool_set_value(dev, useraddr,
 				       dev->ethtool_ops->set_priv_flags);
+		if (rc == 0)
+			ethtool_notify(dev, NULL, ETHNL_CMD_SET_SETTINGS,
+				       ETH_SETTINGS_IM_PRIVFLAGS, NULL);
 		break;
 	case ETHTOOL_GRXFH:
 	case ETHTOOL_GRXRINGS:
diff --git a/net/ethtool/netlink.c b/net/ethtool/netlink.c
index 5166b0c28288..6f94aec6fa69 100644
--- a/net/ethtool/netlink.c
+++ b/net/ethtool/netlink.c
@@ -480,6 +480,7 @@ typedef void (*ethnl_notify_handler_t)(struct net_device *dev,
 				       const void *data);
 
 ethnl_notify_handler_t ethnl_notify_handlers[] = {
+	[ETHNL_CMD_SET_SETTINGS]	= ethnl_std_notify,
 };
 
 void ethtool_notify(struct net_device *dev, struct netlink_ext_ack *extack,
@@ -534,6 +535,14 @@ static void ethnl_notify_devlist(struct netdev_notifier_info *info,
 	nlmsg_free(skb);
 }
 
+static void ethnl_notify_features(struct netdev_notifier_info *info)
+{
+	struct net_device *dev = netdev_notifier_info_to_dev(info);
+
+	ethtool_notify(dev, NULL, ETHNL_CMD_SET_SETTINGS,
+		       ETH_SETTINGS_IM_FEATURES, NULL);
+}
+
 static int ethnl_netdev_event(struct notifier_block *this, unsigned long event,
 			      void *ptr)
 {
@@ -548,6 +557,9 @@ static int ethnl_netdev_event(struct notifier_block *this, unsigned long event,
 		ethnl_notify_devlist(ptr, ETHA_EVENT_RENAMEDEV,
 				     ETHA_RENAMEDEV_DEV);
 		break;
+	case NETDEV_FEAT_CHANGE:
+		ethnl_notify_features(ptr);
+		break;
 	}
 
 	return NOTIFY_DONE;
-- 
2.20.1


  parent reply	other threads:[~2019-02-18 18:23 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-18 18:21 [RFC PATCH net-next v3 00/21] ethtool netlink interface, part 1 Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 01/21] netlink: introduce nla_put_bitfield32() Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 02/21] ethtool: move to its own directory Michal Kubecek
2019-02-18 20:01   ` Jakub Kicinski
2019-02-18 18:21 ` [RFC PATCH net-next v3 03/21] ethtool: introduce ethtool netlink interface Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 04/21] ethtool: helper functions for " Michal Kubecek
2019-02-18 20:15   ` Jakub Kicinski
2019-02-19 13:07     ` Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 05/21] ethtool: netlink bitset handling Michal Kubecek
2019-02-20  2:27   ` Jakub Kicinski
2019-02-20  8:16     ` Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 06/21] ethtool: support for netlink notifications Michal Kubecek
2019-02-18 18:21 ` [RFC PATCH net-next v3 07/21] ethtool: implement EVENT notifications Michal Kubecek
2019-02-18 23:46   ` Andrew Lunn
2019-02-19  7:02     ` Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 08/21] ethtool: generic handlers for GET requests Michal Kubecek
2019-02-20  2:42   ` Jakub Kicinski
2019-02-18 18:22 ` [RFC PATCH net-next v3 09/21] ethtool: move string arrays into common file Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 10/21] ethtool: provide string sets with GET_STRSET request Michal Kubecek
2019-02-20  2:56   ` Jakub Kicinski
2019-02-20 12:34     ` Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 11/21] ethtool: provide driver/device information in GET_INFO request Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 12/21] ethtool: provide permanent hardware address " Michal Kubecek
2019-02-19 10:24   ` Jiri Pirko
2019-02-19 11:36     ` Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 13/21] ethtool: provide timestamping information " Michal Kubecek
2019-02-20  3:00   ` Jakub Kicinski
2019-02-20 13:00     ` Michal Kubecek
2019-02-20 18:37       ` Jakub Kicinski
2019-02-18 18:22 ` [RFC PATCH net-next v3 14/21] ethtool: provide link mode names as a string set Michal Kubecek
2019-02-21  3:21   ` Florian Fainelli
2019-02-21  9:57     ` Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 15/21] ethtool: provide link settings and link modes in GET_SETTINGS request Michal Kubecek
2019-02-21  3:14   ` Florian Fainelli
2019-02-21 10:14     ` Michal Kubecek
2019-02-21 17:40       ` Florian Fainelli
2019-02-18 18:22 ` [RFC PATCH net-next v3 16/21] ethtool: provide WoL information " Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 17/21] ethtool: provide message level " Michal Kubecek
2019-02-18 18:22 ` [RFC PATCH net-next v3 18/21] ethtool: provide link state " Michal Kubecek
2019-02-18 18:23 ` [RFC PATCH net-next v3 19/21] ethtool: provide device features " Michal Kubecek
2019-02-18 18:23 ` [RFC PATCH net-next v3 20/21] ethtool: provide private flags " Michal Kubecek
2019-02-18 18:23 ` Michal Kubecek [this message]
2019-02-19 10:35 ` [RFC PATCH net-next v3 00/21] ethtool netlink interface, part 1 Jiri Pirko
2019-02-19 11:57   ` Michal Kubecek
2019-02-19 12:27     ` Jiri Pirko
2019-02-21  3:21 ` Florian Fainelli
2019-02-21  9:54   ` Michal Kubecek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=73fef81aa207a254ff6a24a60a1910b3c0682af3.1550513384.git.mkubecek@suse.cz \
    --to=mkubecek@suse.cz \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=jakub.kicinski@netronome.com \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).