aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2014-09-11 18:35:10 -0400
committerDavid S. Miller <davem@davemloft.net>2014-09-13 16:38:42 -0400
commitb03a9c04a3a605815c232506e1d76281afe0946f (patch)
tree30a1f41269b63692668648a49306f855a975ba21
parent6c555490e0ce885a9caf0a045db69382a3ccbc9c (diff)
ipv6: remove ipv6_sk_ac_lock
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>
-rw-r--r--net/ipv6/anycast.c17
1 files changed, 3 insertions, 14 deletions
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index 3b0429bc6b5a..d10f2e2b49c6 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -46,10 +46,6 @@
46 46
47static int ipv6_dev_ac_dec(struct net_device *dev, const struct in6_addr *addr); 47static int ipv6_dev_ac_dec(struct net_device *dev, const struct in6_addr *addr);
48 48
49/* Big ac list lock for all the sockets */
50static DEFINE_SPINLOCK(ipv6_sk_ac_lock);
51
52
53/* 49/*
54 * socket join an anycast group 50 * socket join an anycast group
55 */ 51 */
@@ -128,10 +124,8 @@ int ipv6_sock_ac_join(struct sock *sk, int ifindex, const struct in6_addr *addr)
128 124
129 err = ipv6_dev_ac_inc(dev, addr); 125 err = ipv6_dev_ac_inc(dev, addr);
130 if (!err) { 126 if (!err) {
131 spin_lock_bh(&ipv6_sk_ac_lock);
132 pac->acl_next = np->ipv6_ac_list; 127 pac->acl_next = np->ipv6_ac_list;
133 np->ipv6_ac_list = pac; 128 np->ipv6_ac_list = pac;
134 spin_unlock_bh(&ipv6_sk_ac_lock);
135 pac = NULL; 129 pac = NULL;
136 } 130 }
137 131
@@ -152,7 +146,7 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
152 struct ipv6_ac_socklist *pac, *prev_pac; 146 struct ipv6_ac_socklist *pac, *prev_pac;
153 struct net *net = sock_net(sk); 147 struct net *net = sock_net(sk);
154 148
155 spin_lock_bh(&ipv6_sk_ac_lock); 149 rtnl_lock();
156 prev_pac = NULL; 150 prev_pac = NULL;
157 for (pac = np->ipv6_ac_list; pac; pac = pac->acl_next) { 151 for (pac = np->ipv6_ac_list; pac; pac = pac->acl_next) {
158 if ((ifindex == 0 || pac->acl_ifindex == ifindex) && 152 if ((ifindex == 0 || pac->acl_ifindex == ifindex) &&
@@ -161,7 +155,7 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
161 prev_pac = pac; 155 prev_pac = pac;
162 } 156 }
163 if (!pac) { 157 if (!pac) {
164 spin_unlock_bh(&ipv6_sk_ac_lock); 158 rtnl_unlock();
165 return -ENOENT; 159 return -ENOENT;
166 } 160 }
167 if (prev_pac) 161 if (prev_pac)
@@ -169,9 +163,6 @@ int ipv6_sock_ac_drop(struct sock *sk, int ifindex, const struct in6_addr *addr)
169 else 163 else
170 np->ipv6_ac_list = pac->acl_next; 164 np->ipv6_ac_list = pac->acl_next;
171 165
172 spin_unlock_bh(&ipv6_sk_ac_lock);
173
174 rtnl_lock();
175 dev = __dev_get_by_index(net, pac->acl_ifindex); 166 dev = __dev_get_by_index(net, pac->acl_ifindex);
176 if (dev) 167 if (dev)
177 ipv6_dev_ac_dec(dev, &pac->acl_addr); 168 ipv6_dev_ac_dec(dev, &pac->acl_addr);
@@ -192,13 +183,11 @@ void ipv6_sock_ac_close(struct sock *sk)
192 if (!np->ipv6_ac_list) 183 if (!np->ipv6_ac_list)
193 return; 184 return;
194 185
195 spin_lock_bh(&ipv6_sk_ac_lock); 186 rtnl_lock();
196 pac = np->ipv6_ac_list; 187 pac = np->ipv6_ac_list;
197 np->ipv6_ac_list = NULL; 188 np->ipv6_ac_list = NULL;
198 spin_unlock_bh(&ipv6_sk_ac_lock);
199 189
200 prev_index = 0; 190 prev_index = 0;
201 rtnl_lock();
202 while (pac) { 191 while (pac) {
203 struct ipv6_ac_socklist *next = pac->acl_next; 192 struct ipv6_ac_socklist *next = pac->acl_next;
204 193