Skip to content

Commit cb00d3e

Browse files
kuba-mooNipaLocal
authored andcommitted
net: ethtool: remove the data argument from ethtool_notify()
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. Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent ea82849 commit cb00d3e

File tree

4 files changed

+23
-18
lines changed

4 files changed

+23
-18
lines changed

include/linux/netdevice.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5138,10 +5138,9 @@ void netdev_bonding_info_change(struct net_device *dev,
51385138
struct netdev_bonding_info *bonding_info);
51395139

51405140
#if IS_ENABLED(CONFIG_ETHTOOL_NETLINK)
5141-
void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data);
5141+
void ethtool_notify(struct net_device *dev, unsigned int cmd);
51425142
#else
5143-
static inline void ethtool_notify(struct net_device *dev, unsigned int cmd,
5144-
const void *data)
5143+
static inline void ethtool_notify(struct net_device *dev, unsigned int cmd)
51455144
{
51465145
}
51475146
#endif

net/ethtool/ioctl.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ static int ethtool_set_link_ksettings(struct net_device *dev,
617617

618618
err = dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);
619619
if (err >= 0) {
620-
ethtool_notify(dev, ETHTOOL_MSG_LINKINFO_NTF, NULL);
621-
ethtool_notify(dev, ETHTOOL_MSG_LINKMODES_NTF, NULL);
620+
ethtool_notify(dev, ETHTOOL_MSG_LINKINFO_NTF);
621+
ethtool_notify(dev, ETHTOOL_MSG_LINKMODES_NTF);
622622
}
623623
return err;
624624
}
@@ -708,8 +708,8 @@ static int ethtool_set_settings(struct net_device *dev, void __user *useraddr)
708708
__ETHTOOL_LINK_MODE_MASK_NU32;
709709
ret = dev->ethtool_ops->set_link_ksettings(dev, &link_ksettings);
710710
if (ret >= 0) {
711-
ethtool_notify(dev, ETHTOOL_MSG_LINKINFO_NTF, NULL);
712-
ethtool_notify(dev, ETHTOOL_MSG_LINKMODES_NTF, NULL);
711+
ethtool_notify(dev, ETHTOOL_MSG_LINKINFO_NTF);
712+
ethtool_notify(dev, ETHTOOL_MSG_LINKMODES_NTF);
713713
}
714714
return ret;
715715
}
@@ -1868,7 +1868,7 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
18681868
return ret;
18691869

18701870
dev->ethtool->wol_enabled = !!wol.wolopts;
1871-
ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF, NULL);
1871+
ethtool_notify(dev, ETHTOOL_MSG_WOL_NTF);
18721872

18731873
return 0;
18741874
}
@@ -1944,7 +1944,7 @@ static int ethtool_set_eee(struct net_device *dev, char __user *useraddr)
19441944
eee_to_keee(&keee, &eee);
19451945
ret = dev->ethtool_ops->set_eee(dev, &keee);
19461946
if (!ret)
1947-
ethtool_notify(dev, ETHTOOL_MSG_EEE_NTF, NULL);
1947+
ethtool_notify(dev, ETHTOOL_MSG_EEE_NTF);
19481948
return ret;
19491949
}
19501950

@@ -2184,7 +2184,7 @@ static noinline_for_stack int ethtool_set_coalesce(struct net_device *dev,
21842184
ret = dev->ethtool_ops->set_coalesce(dev, &coalesce, &kernel_coalesce,
21852185
NULL);
21862186
if (!ret)
2187-
ethtool_notify(dev, ETHTOOL_MSG_COALESCE_NTF, NULL);
2187+
ethtool_notify(dev, ETHTOOL_MSG_COALESCE_NTF);
21882188
return ret;
21892189
}
21902190

@@ -2228,7 +2228,7 @@ static int ethtool_set_ringparam(struct net_device *dev, void __user *useraddr)
22282228
ret = dev->ethtool_ops->set_ringparam(dev, &ringparam,
22292229
&kernel_ringparam, NULL);
22302230
if (!ret)
2231-
ethtool_notify(dev, ETHTOOL_MSG_RINGS_NTF, NULL);
2231+
ethtool_notify(dev, ETHTOOL_MSG_RINGS_NTF);
22322232
return ret;
22332233
}
22342234

@@ -2295,7 +2295,7 @@ static noinline_for_stack int ethtool_set_channels(struct net_device *dev,
22952295

22962296
ret = dev->ethtool_ops->set_channels(dev, &channels);
22972297
if (!ret)
2298-
ethtool_notify(dev, ETHTOOL_MSG_CHANNELS_NTF, NULL);
2298+
ethtool_notify(dev, ETHTOOL_MSG_CHANNELS_NTF);
22992299
return ret;
23002300
}
23012301

@@ -2326,7 +2326,7 @@ static int ethtool_set_pauseparam(struct net_device *dev, void __user *useraddr)
23262326

23272327
ret = dev->ethtool_ops->set_pauseparam(dev, &pauseparam);
23282328
if (!ret)
2329-
ethtool_notify(dev, ETHTOOL_MSG_PAUSE_NTF, NULL);
2329+
ethtool_notify(dev, ETHTOOL_MSG_PAUSE_NTF);
23302330
return ret;
23312331
}
23322332

@@ -3328,7 +3328,7 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
33283328
rc = ethtool_set_value_void(dev, useraddr,
33293329
dev->ethtool_ops->set_msglevel);
33303330
if (!rc)
3331-
ethtool_notify(dev, ETHTOOL_MSG_DEBUG_NTF, NULL);
3331+
ethtool_notify(dev, ETHTOOL_MSG_DEBUG_NTF);
33323332
break;
33333333
case ETHTOOL_GEEE:
33343334
rc = ethtool_get_eee(dev, useraddr);
@@ -3392,7 +3392,7 @@ __dev_ethtool(struct net *net, struct ifreq *ifr, void __user *useraddr,
33923392
rc = ethtool_get_value(dev, useraddr, ethcmd,
33933393
dev->ethtool_ops->get_priv_flags);
33943394
if (!rc)
3395-
ethtool_notify(dev, ETHTOOL_MSG_PRIVFLAGS_NTF, NULL);
3395+
ethtool_notify(dev, ETHTOOL_MSG_PRIVFLAGS_NTF);
33963396
break;
33973397
case ETHTOOL_SPFLAGS:
33983398
rc = ethtool_set_value(dev, useraddr,

net/ethtool/netlink.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,7 @@ static int ethnl_default_set_doit(struct sk_buff *skb, struct genl_info *info)
911911
swap(dev->cfg, dev->cfg_pending);
912912
if (!ret)
913913
goto out_ops;
914-
ethtool_notify(dev, ops->set_ntf_cmd, NULL);
914+
ethtool_notify(dev, ops->set_ntf_cmd);
915915

916916
ret = 0;
917917
out_ops:
@@ -1049,7 +1049,7 @@ static const ethnl_notify_handler_t ethnl_notify_handlers[] = {
10491049
[ETHTOOL_MSG_MM_NTF] = ethnl_default_notify,
10501050
};
10511051

1052-
void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)
1052+
void ethnl_notify(struct net_device *dev, unsigned int cmd, const void *data)
10531053
{
10541054
if (unlikely(!ethnl_ok))
10551055
return;
@@ -1062,13 +1062,18 @@ void ethtool_notify(struct net_device *dev, unsigned int cmd, const void *data)
10621062
WARN_ONCE(1, "notification %u not implemented (dev=%s)\n",
10631063
cmd, netdev_name(dev));
10641064
}
1065+
1066+
void ethtool_notify(struct net_device *dev, unsigned int cmd)
1067+
{
1068+
ethnl_notify(dev, cmd, NULL);
1069+
}
10651070
EXPORT_SYMBOL(ethtool_notify);
10661071

10671072
static void ethnl_notify_features(struct netdev_notifier_info *info)
10681073
{
10691074
struct net_device *dev = netdev_notifier_info_to_dev(info);
10701075

1071-
ethtool_notify(dev, ETHTOOL_MSG_FEATURES_NTF, NULL);
1076+
ethtool_notify(dev, ETHTOOL_MSG_FEATURES_NTF);
10721077
}
10731078

10741079
static int ethnl_netdev_event(struct notifier_block *this, unsigned long event,

net/ethtool/netlink.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ void *ethnl_dump_put(struct sk_buff *skb, struct netlink_callback *cb, u8 cmd);
2323
void *ethnl_bcastmsg_put(struct sk_buff *skb, u8 cmd);
2424
void *ethnl_unicast_put(struct sk_buff *skb, u32 portid, u32 seq, u8 cmd);
2525
int ethnl_multicast(struct sk_buff *skb, struct net_device *dev);
26+
void ethnl_notify(struct net_device *dev, unsigned int cmd, const void *data);
2627

2728
/**
2829
* ethnl_strz_size() - calculate attribute length for fixed size string

0 commit comments

Comments
 (0)