Skip to content

Commit

Permalink
ipv6: drop ipv6_sk_mc_lock in mcast
Browse files Browse the repository at this point in the history
Similarly the code is already protected by rtnl lock.

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 83aa29e commit b535091
Showing 1 changed file with 2 additions and 16 deletions.
18 changes: 2 additions & 16 deletions net/ipv6/mcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ static void *__mld2_query_bugs[] __attribute__((__unused__)) = {

static struct in6_addr mld2_all_mcr = MLD2_ALL_MCR_INIT;

/* Big mc list lock for all the sockets */
static DEFINE_SPINLOCK(ipv6_sk_mc_lock);

static void igmp6_join_group(struct ifmcaddr6 *ma);
static void igmp6_leave_group(struct ifmcaddr6 *ma);
static void igmp6_timer_handler(unsigned long data);
Expand Down Expand Up @@ -201,10 +198,8 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
return err;
}

spin_lock(&ipv6_sk_mc_lock);
mc_lst->next = np->ipv6_mc_list;
rcu_assign_pointer(np->ipv6_mc_list, mc_lst);
spin_unlock(&ipv6_sk_mc_lock);

rcu_read_unlock();
rtnl_unlock();
Expand All @@ -226,17 +221,14 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
return -EINVAL;

rtnl_lock();
spin_lock(&ipv6_sk_mc_lock);
for (lnk = &np->ipv6_mc_list;
(mc_lst = rcu_dereference_protected(*lnk,
lockdep_is_held(&ipv6_sk_mc_lock))) != NULL;
(mc_lst = rtnl_dereference(*lnk)) != NULL;
lnk = &mc_lst->next) {
if ((ifindex == 0 || mc_lst->ifindex == ifindex) &&
ipv6_addr_equal(&mc_lst->addr, addr)) {
struct net_device *dev;

*lnk = mc_lst->next;
spin_unlock(&ipv6_sk_mc_lock);

rcu_read_lock();
dev = dev_get_by_index_rcu(net, mc_lst->ifindex);
Expand All @@ -256,7 +248,6 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
return 0;
}
}
spin_unlock(&ipv6_sk_mc_lock);
rtnl_unlock();

return -EADDRNOTAVAIL;
Expand Down Expand Up @@ -303,13 +294,10 @@ void ipv6_sock_mc_close(struct sock *sk)
return;

rtnl_lock();
spin_lock(&ipv6_sk_mc_lock);
while ((mc_lst = rcu_dereference_protected(np->ipv6_mc_list,
lockdep_is_held(&ipv6_sk_mc_lock))) != NULL) {
while ((mc_lst = rtnl_dereference(np->ipv6_mc_list)) != NULL) {
struct net_device *dev;

np->ipv6_mc_list = mc_lst->next;
spin_unlock(&ipv6_sk_mc_lock);

rcu_read_lock();
dev = dev_get_by_index_rcu(net, mc_lst->ifindex);
Expand All @@ -326,9 +314,7 @@ void ipv6_sock_mc_close(struct sock *sk)
atomic_sub(sizeof(*mc_lst), &sk->sk_omem_alloc);
kfree_rcu(mc_lst, rcu);

spin_lock(&ipv6_sk_mc_lock);
}
spin_unlock(&ipv6_sk_mc_lock);
rtnl_unlock();
}

Expand Down

0 comments on commit b535091

Please sign in to comment.