aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6
diff options
context:
space:
mode:
authorEric Dumazet <eric.dumazet@gmail.com>2009-11-02 06:10:39 -0500
committerDavid S. Miller <davem@davemloft.net>2009-11-02 06:42:41 -0500
commit16ba5e8e7c01d2da87ff1d17e83545f164665b5c (patch)
tree0e51da332c65d719ca1b855022027aa9423e7acf /net/ipv6
parentf1a28eab20076542322fcab3efa016834bd732f2 (diff)
ipv6: no more dev_put() in inet6_bind()
Avoids touching device refcount in inet6_bind(), thanks to RCU Signed-off-by: Eric Dumazet <eric.dumazet@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6')
-rw-r--r--net/ipv6/af_inet6.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
index b6d058818673..9105b25defe5 100644
--- a/net/ipv6/af_inet6.c
+++ b/net/ipv6/af_inet6.c
@@ -314,6 +314,7 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
314 if (addr_type != IPV6_ADDR_ANY) { 314 if (addr_type != IPV6_ADDR_ANY) {
315 struct net_device *dev = NULL; 315 struct net_device *dev = NULL;
316 316
317 rcu_read_lock();
317 if (addr_type & IPV6_ADDR_LINKLOCAL) { 318 if (addr_type & IPV6_ADDR_LINKLOCAL) {
318 if (addr_len >= sizeof(struct sockaddr_in6) && 319 if (addr_len >= sizeof(struct sockaddr_in6) &&
319 addr->sin6_scope_id) { 320 addr->sin6_scope_id) {
@@ -326,12 +327,12 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
326 /* Binding to link-local address requires an interface */ 327 /* Binding to link-local address requires an interface */
327 if (!sk->sk_bound_dev_if) { 328 if (!sk->sk_bound_dev_if) {
328 err = -EINVAL; 329 err = -EINVAL;
329 goto out; 330 goto out_unlock;
330 } 331 }
331 dev = dev_get_by_index(net, sk->sk_bound_dev_if); 332 dev = dev_get_by_index_rcu(net, sk->sk_bound_dev_if);
332 if (!dev) { 333 if (!dev) {
333 err = -ENODEV; 334 err = -ENODEV;
334 goto out; 335 goto out_unlock;
335 } 336 }
336 } 337 }
337 338
@@ -342,14 +343,11 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
342 if (!(addr_type & IPV6_ADDR_MULTICAST)) { 343 if (!(addr_type & IPV6_ADDR_MULTICAST)) {
343 if (!ipv6_chk_addr(net, &addr->sin6_addr, 344 if (!ipv6_chk_addr(net, &addr->sin6_addr,
344 dev, 0)) { 345 dev, 0)) {
345 if (dev)
346 dev_put(dev);
347 err = -EADDRNOTAVAIL; 346 err = -EADDRNOTAVAIL;
348 goto out; 347 goto out_unlock;
349 } 348 }
350 } 349 }
351 if (dev) 350 rcu_read_unlock();
352 dev_put(dev);
353 } 351 }
354 } 352 }
355 353
@@ -381,6 +379,9 @@ int inet6_bind(struct socket *sock, struct sockaddr *uaddr, int addr_len)
381out: 379out:
382 release_sock(sk); 380 release_sock(sk);
383 return err; 381 return err;
382out_unlock:
383 rcu_read_unlock();
384 goto out;
384} 385}
385 386
386EXPORT_SYMBOL(inet6_bind); 387EXPORT_SYMBOL(inet6_bind);