Skip to content

Commit

Permalink
net: RCU locking for simple ioctl()
Browse files Browse the repository at this point in the history
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: Eric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Eric Dumazet authored and David S. Miller committed Nov 2, 2009
1 parent 685c794 commit 3710bec
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions net/core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -4315,12 +4315,12 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa)
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)
{
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)
return -ENODEV;
Expand Down Expand Up @@ -4552,9 +4552,9 @@ int dev_ioctl(struct net *net, unsigned int cmd, void __user *arg)
case SIOCGIFINDEX:
case SIOCGIFTXQLEN:
dev_load(net, ifr.ifr_name);
read_lock(&dev_base_lock);
rcu_read_lock();
ret = dev_ifsioc_locked(net, &ifr, cmd);
read_unlock(&dev_base_lock);
rcu_read_unlock();
if (!ret) {
if (colon)
*colon = ':';
Expand Down

0 comments on commit 3710bec

Please sign in to comment.