Skip to content

Commit

Permalink
ipv6: remove ipv6_sk_ac_lock
Browse files Browse the repository at this point in the history
Just move rtnl lock up, so that the anycast list can be protected
by rtnl lock now.

Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
WANG Cong authored and David S. Miller committed Sep 13, 2014
1 parent 6c55549 commit b03a9c0
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions net/ipv6/anycast.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,6 @@

static int ipv6_dev_ac_dec(struct net_device *dev, const struct in6_addr *addr);

/* Big ac list lock for all the sockets */
static DEFINE_SPINLOCK(ipv6_sk_ac_lock);


/*
* socket join an anycast group
*/
Expand Down Expand Up @@ -128,10 +124,8 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)

err = ipv6_dev_ac_inc(dev, addr);
if (!err) {
spin_lock_bh(&ipv6_sk_ac_lock);
pac->acl_next = np->ipv6_ac_list;
np->ipv6_ac_list = pac;
spin_unlock_bh(&ipv6_sk_ac_lock);
pac = NULL;
}

Expand All @@ -152,7 +146,7 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
struct ipv6_ac_socklist *pac, *prev_pac;
struct net *net = sock_net(sk);

spin_lock_bh(&ipv6_sk_ac_lock);
rtnl_lock();
prev_pac = NULL;
for (pac = np->ipv6_ac_list; pac; pac = pac->acl_next) {
if ((ifindex == 0 || pac->acl_ifindex == ifindex) &&
Expand All @@ -161,17 +155,14 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
prev_pac = pac;
}
if (!pac) {
spin_unlock_bh(&ipv6_sk_ac_lock);
rtnl_unlock();
return -ENOENT;
}
if (prev_pac)
prev_pac->acl_next = pac->acl_next;
else
np->ipv6_ac_list = pac->acl_next;

spin_unlock_bh(&ipv6_sk_ac_lock);

rtnl_lock();
dev = __dev_get_by_index(net, pac->acl_ifindex);
if (dev)
ipv6_dev_ac_dec(dev, &pac->acl_addr);
Expand All @@ -192,13 +183,11 @@ void ipv6_sock_ac_close(struct sock *sk)
if (!np->ipv6_ac_list)
return;

spin_lock_bh(&ipv6_sk_ac_lock);
rtnl_lock();
pac = np->ipv6_ac_list;
np->ipv6_ac_list = NULL;
spin_unlock_bh(&ipv6_sk_ac_lock);

prev_index = 0;
rtnl_lock();
while (pac) {
struct ipv6_ac_socklist *next = pac->acl_next;

Expand Down

0 comments on commit b03a9c0

Please sign in to comment.