mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
net: hold netdev instance lock during ioctl operations
Convert all ndo_eth_ioctl invocations to dev_eth_ioctl which does the locking. Reflow some of the dev_siocxxx to drop else clause. Cc: Saeed Mahameed <saeed@kernel.org> Signed-off-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250305163732.2766420-8-sdf@fomichev.me Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
7e4d784f58
commit
ffb7ed19ac
@@ -222,3 +222,33 @@ void dev_close(struct net_device *dev)
|
||||
netdev_unlock_ops(dev);
|
||||
}
|
||||
EXPORT_SYMBOL(dev_close);
|
||||
|
||||
int dev_eth_ioctl(struct net_device *dev,
|
||||
struct ifreq *ifr, unsigned int cmd)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
int ret = -ENODEV;
|
||||
|
||||
if (!ops->ndo_eth_ioctl)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
netdev_lock_ops(dev);
|
||||
if (netif_device_present(dev))
|
||||
ret = ops->ndo_eth_ioctl(dev, ifr, cmd);
|
||||
netdev_unlock_ops(dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(dev_eth_ioctl);
|
||||
|
||||
int dev_set_mtu(struct net_device *dev, int new_mtu)
|
||||
{
|
||||
int ret;
|
||||
|
||||
netdev_lock_ops(dev);
|
||||
ret = netif_set_mtu(dev, new_mtu);
|
||||
netdev_unlock_ops(dev);
|
||||
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(dev_set_mtu);
|
||||
|
||||
Reference in New Issue
Block a user