Commit b5350916 authored by WANG Cong's avatar WANG Cong Committed by David S. Miller

ipv6: drop ipv6_sk_mc_lock in mcast

Similarly the code is already protected by rtnl lock.
Signed-off-by: default avatarCong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 83aa29ee
...@@ -73,9 +73,6 @@ static void *__mld2_query_bugs[] __attribute__((__unused__)) = { ...@@ -73,9 +73,6 @@ static void *__mld2_query_bugs[] __attribute__((__unused__)) = {
static struct in6_addr mld2_all_mcr = MLD2_ALL_MCR_INIT; 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_join_group(struct ifmcaddr6 *ma);
static void igmp6_leave_group(struct ifmcaddr6 *ma); static void igmp6_leave_group(struct ifmcaddr6 *ma);
static void igmp6_timer_handler(unsigned long data); static void igmp6_timer_handler(unsigned long data);
...@@ -201,10 +198,8 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr) ...@@ -201,10 +198,8 @@ int ipv6_sock_mc_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
return err; return err;
} }
spin_lock(&ipv6_sk_mc_lock);
mc_lst->next = np->ipv6_mc_list; mc_lst->next = np->ipv6_mc_list;
rcu_assign_pointer(np->ipv6_mc_list, mc_lst); rcu_assign_pointer(np->ipv6_mc_list, mc_lst);
spin_unlock(&ipv6_sk_mc_lock);
rcu_read_unlock(); rcu_read_unlock();
rtnl_unlock(); rtnl_unlock();
...@@ -226,17 +221,14 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr) ...@@ -226,17 +221,14 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
return -EINVAL; return -EINVAL;
rtnl_lock(); rtnl_lock();
spin_lock(&ipv6_sk_mc_lock);
for (lnk = &np->ipv6_mc_list; for (lnk = &np->ipv6_mc_list;
(mc_lst = rcu_dereference_protected(*lnk, (mc_lst = rtnl_dereference(*lnk)) != NULL;
lockdep_is_held(&ipv6_sk_mc_lock))) != NULL;
lnk = &mc_lst->next) { lnk = &mc_lst->next) {
if ((ifindex == 0 || mc_lst->ifindex == ifindex) && if ((ifindex == 0 || mc_lst->ifindex == ifindex) &&
ipv6_addr_equal(&mc_lst->addr, addr)) { ipv6_addr_equal(&mc_lst->addr, addr)) {
struct net_device *dev; struct net_device *dev;
*lnk = mc_lst->next; *lnk = mc_lst->next;
spin_unlock(&ipv6_sk_mc_lock);
rcu_read_lock(); rcu_read_lock();
dev = dev_get_by_index_rcu(net, mc_lst->ifindex); dev = dev_get_by_index_rcu(net, mc_lst->ifindex);
...@@ -256,7 +248,6 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr) ...@@ -256,7 +248,6 @@ int ipv6_sock_mc_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
return 0; return 0;
} }
} }
spin_unlock(&ipv6_sk_mc_lock);
rtnl_unlock(); rtnl_unlock();
return -EADDRNOTAVAIL; return -EADDRNOTAVAIL;
...@@ -303,13 +294,10 @@ void ipv6_sock_mc_close(struct sock *sk) ...@@ -303,13 +294,10 @@ void ipv6_sock_mc_close(struct sock *sk)
return; return;
rtnl_lock(); rtnl_lock();
spin_lock(&ipv6_sk_mc_lock); while ((mc_lst = rtnl_dereference(np->ipv6_mc_list)) != NULL) {
while ((mc_lst = rcu_dereference_protected(np->ipv6_mc_list,
lockdep_is_held(&ipv6_sk_mc_lock))) != NULL) {
struct net_device *dev; struct net_device *dev;
np->ipv6_mc_list = mc_lst->next; np->ipv6_mc_list = mc_lst->next;
spin_unlock(&ipv6_sk_mc_lock);
rcu_read_lock(); rcu_read_lock();
dev = dev_get_by_index_rcu(net, mc_lst->ifindex); dev = dev_get_by_index_rcu(net, mc_lst->ifindex);
...@@ -326,9 +314,7 @@ void ipv6_sock_mc_close(struct sock *sk) ...@@ -326,9 +314,7 @@ void ipv6_sock_mc_close(struct sock *sk)
atomic_sub(sizeof(*mc_lst), &sk->sk_omem_alloc); atomic_sub(sizeof(*mc_lst), &sk->sk_omem_alloc);
kfree_rcu(mc_lst, rcu); kfree_rcu(mc_lst, rcu);
spin_lock(&ipv6_sk_mc_lock);
} }
spin_unlock(&ipv6_sk_mc_lock);
rtnl_unlock(); rtnl_unlock();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment