提交 3710becf 编写于 作者: E Eric Dumazet 提交者: David S. Miller

net: RCU locking for simple ioctl()

All ioctls() implemented by dev_ifsioc_locked() :
SIOCGIFFLAGS, SIOCGIFMETRIC, SIOCGIFMTU, SIOCGIFHWADDR,
SIOCGIFSLAVE, SIOCGIFMAP, SIOCGIFINDEX & SIOCGIFTXQLEN
can use RCU lock instead of dev_base_lock rwlock
Signed-off-by: NEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 685c7944
...@@ -4315,12 +4315,12 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa) ...@@ -4315,12 +4315,12 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
EXPORT_SYMBOL(dev_set_mac_address); EXPORT_SYMBOL(dev_set_mac_address);
/* /*
* Perform the SIOCxIFxxx calls, inside read_lock(dev_base_lock) * Perform the SIOCxIFxxx calls, inside rcu_read_lock()
*/ */
static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cmd) static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cmd)
{ {
int err; int err;
struct net_device *dev = __dev_get_by_name(net, ifr->ifr_name); struct net_device *dev = dev_get_by_name_rcu(net, ifr->ifr_name);
if (!dev) if (!dev)
return -ENODEV; return -ENODEV;
...@@ -4552,9 +4552,9 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg) ...@@ -4552,9 +4552,9 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
case SIOCGIFINDEX: case SIOCGIFINDEX:
case SIOCGIFTXQLEN: case SIOCGIFTXQLEN:
dev_load(net, ifr.ifr_name); dev_load(net, ifr.ifr_name);
read_lock(&dev_base_lock); rcu_read_lock();
ret = dev_ifsioc_locked(net, &ifr, cmd); ret = dev_ifsioc_locked(net, &ifr, cmd);
read_unlock(&dev_base_lock); rcu_read_unlock();
if (!ret) { if (!ret) {
if (colon) if (colon)
*colon = ':'; *colon = ':';
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册