ipv6: drop useless rcu_read_lock() in anycast

These code is now protected by rtnl lock, rcu read lock
is useless now.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
WANG Cong 2014-09-11 15:35:09 -07:00 committed by David S. Miller
parent 8801d48cbd
commit 6c555490e0
3 changed files with 16 additions and 20 deletions

View File

@ -2083,8 +2083,8 @@ void __dev_remove_pack(struct packet_type *pt);
void dev_add_offload(struct packet_offload *po); void dev_add_offload(struct packet_offload *po);
void dev_remove_offload(struct packet_offload *po); void dev_remove_offload(struct packet_offload *po);
struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short flags, struct net_device *__dev_get_by_flags(struct net *net, unsigned short flags,
unsigned short mask); unsigned short mask);
struct net_device *dev_get_by_name(struct net *net, const char *name); struct net_device *dev_get_by_name(struct net *net, const char *name);
struct net_device *dev_get_by_name_rcu(struct net *net, const char *name); struct net_device *dev_get_by_name_rcu(struct net *net, const char *name);
struct net_device *__dev_get_by_name(struct net *net, const char *name); struct net_device *__dev_get_by_name(struct net *net, const char *name);

View File

@ -897,23 +897,25 @@ struct net_device *dev_getfirstbyhwtype(struct net *net, unsigned short type)
EXPORT_SYMBOL(dev_getfirstbyhwtype); EXPORT_SYMBOL(dev_getfirstbyhwtype);
/** /**
* dev_get_by_flags_rcu - find any device with given flags * __dev_get_by_flags - find any device with given flags
* @net: the applicable net namespace * @net: the applicable net namespace
* @if_flags: IFF_* values * @if_flags: IFF_* values
* @mask: bitmask of bits in if_flags to check * @mask: bitmask of bits in if_flags to check
* *
* Search for any interface with the given flags. Returns NULL if a device * Search for any interface with the given flags. Returns NULL if a device
* is not found or a pointer to the device. Must be called inside * is not found or a pointer to the device. Must be called inside
* rcu_read_lock(), and result refcount is unchanged. * rtnl_lock(), and result refcount is unchanged.
*/ */
struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short if_flags, struct net_device *__dev_get_by_flags(struct net *net, unsigned short if_flags,
unsigned short mask) unsigned short mask)
{ {
struct net_device *dev, *ret; struct net_device *dev, *ret;
ASSERT_RTNL();
ret = NULL; ret = NULL;
for_each_netdev_rcu(net, dev) { for_each_netdev(net, dev) {
if (((dev->flags ^ if_flags) & mask) == 0) { if (((dev->flags ^ if_flags) & mask) == 0) {
ret = dev; ret = dev;
break; break;
@ -921,7 +923,7 @@ struct net_device *dev_get_by_flags_rcu(struct net *net, unsigned short if_flags
} }
return ret; return ret;
} }
EXPORT_SYMBOL(dev_get_by_flags_rcu); EXPORT_SYMBOL(__dev_get_by_flags);
/** /**
* dev_valid_name - check if name is okay for network device * dev_valid_name - check if name is okay for network device

View File

@ -78,7 +78,6 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
pac->acl_addr = *addr; pac->acl_addr = *addr;
rtnl_lock(); rtnl_lock();
rcu_read_lock();
if (ifindex == 0) { if (ifindex == 0) {
struct rt6_info *rt; struct rt6_info *rt;
@ -91,11 +90,11 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
goto error; goto error;
} else { } else {
/* router, no matching interface: just pick one */ /* router, no matching interface: just pick one */
dev = dev_get_by_flags_rcu(net, IFF_UP, dev = __dev_get_by_flags(net, IFF_UP,
IFF_UP | IFF_LOOPBACK); IFF_UP | IFF_LOOPBACK);
} }
} else } else
dev = dev_get_by_index_rcu(net, ifindex); dev = __dev_get_by_index(net, ifindex);
if (dev == NULL) { if (dev == NULL) {
err = -ENODEV; err = -ENODEV;
@ -137,7 +136,6 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
} }
error: error:
rcu_read_unlock();
rtnl_unlock(); rtnl_unlock();
if (pac) if (pac)
sock_kfree_s(sk, pac, sizeof(*pac)); sock_kfree_s(sk, pac, sizeof(*pac));
@ -174,11 +172,9 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
spin_unlock_bh(&ipv6_sk_ac_lock); spin_unlock_bh(&ipv6_sk_ac_lock);
rtnl_lock(); rtnl_lock();
rcu_read_lock(); dev = __dev_get_by_index(net, pac->acl_ifindex);
dev = dev_get_by_index_rcu(net, pac->acl_ifindex);
if (dev) if (dev)
ipv6_dev_ac_dec(dev, &pac->acl_addr); ipv6_dev_ac_dec(dev, &pac->acl_addr);
rcu_read_unlock();
rtnl_unlock(); rtnl_unlock();
sock_kfree_s(sk, pac, sizeof(*pac)); sock_kfree_s(sk, pac, sizeof(*pac));
@ -203,12 +199,11 @@ void ipv6_sock_ac_close(struct sock *sk)
prev_index = 0; prev_index = 0;
rtnl_lock(); rtnl_lock();
rcu_read_lock();
while (pac) { while (pac) {
struct ipv6_ac_socklist *next = pac->acl_next; struct ipv6_ac_socklist *next = pac->acl_next;
if (pac->acl_ifindex != prev_index) { if (pac->acl_ifindex != prev_index) {
dev = dev_get_by_index_rcu(net, pac->acl_ifindex); dev = __dev_get_by_index(net, pac->acl_ifindex);
prev_index = pac->acl_ifindex; prev_index = pac->acl_ifindex;
} }
if (dev) if (dev)
@ -216,7 +211,6 @@ void ipv6_sock_ac_close(struct sock *sk)
sock_kfree_s(sk, pac, sizeof(*pac)); sock_kfree_s(sk, pac, sizeof(*pac));
pac = next; pac = next;
} }
rcu_read_unlock();
rtnl_unlock(); rtnl_unlock();
} }
@ -341,7 +335,7 @@ int __ipv6_dev_ac_dec(struct inet6_dev *idev, const struct in6_addr *addr)
return 0; return 0;
} }
/* called with rcu_read_lock() */ /* called with rtnl_lock() */
static int ipv6_dev_ac_dec(struct net_device *dev, const struct in6_addr *addr) static int ipv6_dev_ac_dec(struct net_device *dev, const struct in6_addr *addr)
{ {
struct inet6_dev *idev = __in6_dev_get(dev); struct inet6_dev *idev = __in6_dev_get(dev);