Skip to content

Commit

Permalink
ipv6 anycast: Convert ipv6_sk_ac_lock to spinlock.
Browse files Browse the repository at this point in the history
Since all users are write-lock, it does not make sense to use
rwlock here.  Use simple spinlock.

Signed-off-by: YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
YOSHIFUJI Hideaki / 吉藤英明 authored and David S. Miller committed Jan 31, 2013
1 parent 1836768 commit c33e7b0
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions net/ipv6/anycast.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
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_RWLOCK(ipv6_sk_ac_lock);
static DEFINE_SPINLOCK(ipv6_sk_ac_lock);


/*
Expand Down Expand Up @@ -128,10 +128,10 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)

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

Expand All @@ -152,7 +152,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);

write_lock_bh(&ipv6_sk_ac_lock);
spin_lock_bh(&ipv6_sk_ac_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,15 +161,15 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
prev_pac = pac;
}
if (!pac) {
write_unlock_bh(&ipv6_sk_ac_lock);
spin_unlock_bh(&ipv6_sk_ac_lock);
return -ENOENT;
}
if (prev_pac)
prev_pac->acl_next = pac->acl_next;
else
np->ipv6_ac_list = pac->acl_next;

write_unlock_bh(&ipv6_sk_ac_lock);
spin_unlock_bh(&ipv6_sk_ac_lock);

rcu_read_lock();
dev = dev_get_by_index_rcu(net, pac->acl_ifindex);
Expand All @@ -192,10 +192,10 @@ void ipv6_sock_ac_close(struct sock *sk)
if (!np->ipv6_ac_list)
return;

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

prev_index = 0;
rcu_read_lock();
Expand Down

0 comments on commit c33e7b0

Please sign in to comment.