]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: ethtool: remove the data argument from ethtool_notify()
authorJakub Kicinski <kuba@kernel.org>
Mon, 23 Jun 2025 23:17:16 +0000 (16:17 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 25 Jun 2025 22:24:14 +0000 (15:24 -0700)
ethtool_notify() takes a const void *data argument, which presumably
was intended to pass information from the call site to the subcommand
handler. This argument currently has no users.

Expecting the data to be subcommand-specific has two complications.

Complication #1 is that its not plumbed thru any of the standardized
callbacks. It gets propagated to ethnl_default_notify() where it
remains unused. Coming from the ethnl_default_set_doit() side we pass
in NULL, because how could we have a command specific attribute in
a generic handler.

Complication #2 is that we expect the ethtool_notify() callers to
know what attribute type to pass in. Again, the data pointer is
untyped.

RSS will need to pass the context ID to the notifications.
I think it's a better design if the "subcommand" exports its own
typed interface and constructs the appropriate argument struct
(which will be req_info). Remove the unused data argument from
ethtool_notify() but retain it in a new internal helper which
subcommands can use to build a typed interface.

Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Tested-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20250623231720.3124717-5-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netdevice.h
net/ethtool/ioctl.c
net/ethtool/netlink.c
net/ethtool/netlink.h

index 03c26bb0fbbef925fd022b3c8d7b6b30e85c4667..db5bfd4e7ec8d981af7352076e6f5d4b7e580796 100644 (file)
@@ -5138,10 +5138,9 @@ void netdev_bonding_info_change(struct net_device *dev,
                                struct netdev_bonding_info *bonding_info);
 
 #if IS_ENABLED(CONFIG_ETHTOOL_NETLINK)
-void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data);
+void ethtool_notify(struct net_device *dev, unsigned int cmd);
 #else
-static inline void ethtool_notify(struct net_device *dev, unsigned int cmd,
-                                 const void *data)
+static inline void ethtool_notify(struct net_device *dev, unsigned int cmd)
 {
 }
 #endif
index 82cde640aa87b1d9e95bc3114f8558a1bcf22a40..96da9d18789ba97b53862ac2ee258854766f9250 100644 (file)
@@ -617,8 +617,8 @@ static int ethtool_set_link_ksettings(struct net_device *dev,
 
        err = dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);
        if (err >= 0) {
-               ethtool_notify(dev, ETHTOOL_MSG_LINKINFO_NTF, NULL);
-               ethtool_notify(dev, ETHTOOL_MSG_LINKMODES_NTF, NULL);
+               ethtool_notify(dev, ETHTOOL_MSG_LINKINFO_NTF);
+               ethtool_notify(dev, ETHTOOL_MSG_LINKMODES_NTF);
        }
        return err;
 }
@@ -708,8 +708,8 @@ static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
                __ETHTOOL_LINK_MODE_MASK_NU32;
        ret = dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);
        if (ret >= 0) {
-               ethtool_notify(dev, ETHTOOL_MSG_LINKINFO_NTF, NULL);
-               ethtool_notify(dev, ETHTOOL_MSG_LINKMODES_NTF, NULL);
+               ethtool_notify(dev, ETHTOOL_MSG_LINKINFO_NTF);
+               ethtool_notify(dev, ETHTOOL_MSG_LINKMODES_NTF);
        }
        return ret;
 }
@@ -1868,7 +1868,7 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
                return ret;
 
        dev->ethtool->wol_enabled = !!wol.wolopts;
-       ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL);
+       ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF);
 
        return 0;
 }
@@ -1944,7 +1944,7 @@ static int ethtool_set_eee(struct net_device *dev, char __user *useraddr)
        eee_to_keee(&keee, &eee);
        ret = dev->ethtool_ops->set_eee(dev, &keee);
        if (!ret)
-               ethtool_notify(dev, ETHTOOL_MSG_EEE_NTF, NULL);
+               ethtool_notify(dev, ETHTOOL_MSG_EEE_NTF);
        return ret;
 }
 
@@ -2184,7 +2184,7 @@ static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev,
        ret = dev->ethtool_ops->set_coalesce(dev, &coalesce, &kernel_coalesce,
                                             NULL);
        if (!ret)
-               ethtool_notify(dev, ETHTOOL_MSG_COALESCE_NTF, NULL);
+               ethtool_notify(dev, ETHTOOL_MSG_COALESCE_NTF);
        return ret;
 }
 
@@ -2228,7 +2228,7 @@ static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
        ret = dev->ethtool_ops->set_ringparam(dev, &ringparam,
                                              &kernel_ringparam, NULL);
        if (!ret)
-               ethtool_notify(dev, ETHTOOL_MSG_RINGS_NTF, NULL);
+               ethtool_notify(dev, ETHTOOL_MSG_RINGS_NTF);
        return ret;
 }
 
@@ -2295,7 +2295,7 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
 
        ret = dev->ethtool_ops->set_channels(dev, &channels);
        if (!ret)
-               ethtool_notify(dev, ETHTOOL_MSG_CHANNELS_NTF, NULL);
+               ethtool_notify(dev, ETHTOOL_MSG_CHANNELS_NTF);
        return ret;
 }
 
@@ -2326,7 +2326,7 @@ static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
 
        ret = dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
        if (!ret)
-               ethtool_notify(dev, ETHTOOL_MSG_PAUSE_NTF, NULL);
+               ethtool_notify(dev, ETHTOOL_MSG_PAUSE_NTF);
        return ret;
 }
 
@@ -3328,7 +3328,7 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
                rc = ethtool_set_value_void(dev, useraddr,
                                       dev->ethtool_ops->set_msglevel);
                if (!rc)
-                       ethtool_notify(dev, ETHTOOL_MSG_DEBUG_NTF, NULL);
+                       ethtool_notify(dev, ETHTOOL_MSG_DEBUG_NTF);
                break;
        case ETHTOOL_GEEE:
                rc = ethtool_get_eee(dev, useraddr);
@@ -3392,7 +3392,7 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
                rc = ethtool_get_value(dev, useraddr, ethcmd,
                                       dev->ethtool_ops->get_priv_flags);
                if (!rc)
-                       ethtool_notify(dev, ETHTOOL_MSG_PRIVFLAGS_NTF, NULL);
+                       ethtool_notify(dev, ETHTOOL_MSG_PRIVFLAGS_NTF);
                break;
        case ETHTOOL_SPFLAGS:
                rc = ethtool_set_value(dev, useraddr,
index c5ec3c82ab2eec32bd897bbcc299c72e37829885..129f9d56ac652728a03a882f3fe631c5a17f0fb5 100644 (file)
@@ -911,7 +911,7 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info)
        swap(dev->cfg, dev->cfg_pending);
        if (!ret)
                goto out_ops;
-       ethtool_notify(dev, ops->set_ntf_cmd, NULL);
+       ethtool_notify(dev, ops->set_ntf_cmd);
 
        ret = 0;
 out_ops:
@@ -1049,7 +1049,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
        [ETHTOOL_MSG_MM_NTF]            = ethnl_default_notify,
 };
 
-void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)
+void ethnl_notify(struct net_device *dev, unsigned int cmd, const void *data)
 {
        if (unlikely(!ethnl_ok))
                return;
@@ -1062,13 +1062,18 @@ void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)
                WARN_ONCE(1, "notification %u not implemented (dev=%s)\n",
                          cmd, netdev_name(dev));
 }
+
+void ethtool_notify(struct net_device *dev, unsigned int cmd)
+{
+       ethnl_notify(dev, cmd, NULL);
+}
 EXPORT_SYMBOL(ethtool_notify);
 
 static void ethnl_notify_features(struct netdev_notifier_info *info)
 {
        struct net_device *dev = netdev_notifier_info_to_dev(info);
 
-       ethtool_notify(dev, ETHTOOL_MSG_FEATURES_NTF, NULL);
+       ethtool_notify(dev, ETHTOOL_MSG_FEATURES_NTF);
 }
 
 static int ethnl_netdev_event(struct notifier_block *this, unsigned long event,
index 91b953924af38640652ab0ba336f6d24f42fa5eb..4a061944a3aa9f8e4c9e99ed6e38417b132d9110 100644 (file)
@@ -23,6 +23,7 @@ void *ethnl_dump_put(struct sk_buff *skb, struct netlink_callback *cb, u8 cmd);
 void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd);
 void *ethnl_unicast_put(struct sk_buff *skb, u32 portid, u32 seq, u8 cmd);
 int ethnl_multicast(struct sk_buff *skb, struct net_device *dev);
+void ethnl_notify(struct net_device *dev, unsigned int cmd, const void *data);
 
 /**
  * ethnl_strz_size() - calculate attribute length for fixed size string