aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv6/anycast.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv6/anycast.c')
-rw-r--r--net/ipv6/anycast.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/net/ipv6/anycast.c b/net/ipv6/anycast.c
index 1ae58bec1de0..b5b07054508a 100644
--- a/net/ipv6/anycast.c
+++ b/net/ipv6/anycast.c
@@ -29,6 +29,7 @@
29#include <linux/init.h> 29#include <linux/init.h>
30#include <linux/proc_fs.h> 30#include <linux/proc_fs.h>
31#include <linux/seq_file.h> 31#include <linux/seq_file.h>
32#include <linux/slab.h>
32 33
33#include <net/net_namespace.h> 34#include <net/net_namespace.h>
34#include <net/sock.h> 35#include <net/sock.h>
@@ -404,13 +405,13 @@ int ipv6_chk_acast_addr(struct net *net, struct net_device *dev,
404 405
405 if (dev) 406 if (dev)
406 return ipv6_chk_acast_dev(dev, addr); 407 return ipv6_chk_acast_dev(dev, addr);
407 read_lock(&dev_base_lock); 408 rcu_read_lock();
408 for_each_netdev(net, dev) 409 for_each_netdev_rcu(net, dev)
409 if (ipv6_chk_acast_dev(dev, addr)) { 410 if (ipv6_chk_acast_dev(dev, addr)) {
410 found = 1; 411 found = 1;
411 break; 412 break;
412 } 413 }
413 read_unlock(&dev_base_lock); 414 rcu_read_unlock();
414 return found; 415 return found;
415} 416}
416 417
@@ -431,9 +432,9 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
431 struct net *net = seq_file_net(seq); 432 struct net *net = seq_file_net(seq);
432 433
433 state->idev = NULL; 434 state->idev = NULL;
434 for_each_netdev(net, state->dev) { 435 for_each_netdev_rcu(net, state->dev) {
435 struct inet6_dev *idev; 436 struct inet6_dev *idev;
436 idev = in6_dev_get(state->dev); 437 idev = __in6_dev_get(state->dev);
437 if (!idev) 438 if (!idev)
438 continue; 439 continue;
439 read_lock_bh(&idev->lock); 440 read_lock_bh(&idev->lock);
@@ -443,7 +444,6 @@ static inline struct ifacaddr6 *ac6_get_first(struct seq_file *seq)
443 break; 444 break;
444 } 445 }
445 read_unlock_bh(&idev->lock); 446 read_unlock_bh(&idev->lock);
446 in6_dev_put(idev);
447 } 447 }
448 return im; 448 return im;
449} 449}
@@ -454,16 +454,15 @@ static struct ifacaddr6 *ac6_get_next(struct seq_file *seq, struct ifacaddr6 *im
454 454
455 im = im->aca_next; 455 im = im->aca_next;
456 while (!im) { 456 while (!im) {
457 if (likely(state->idev != NULL)) { 457 if (likely(state->idev != NULL))
458 read_unlock_bh(&state->idev->lock); 458 read_unlock_bh(&state->idev->lock);
459 in6_dev_put(state->idev); 459
460 } 460 state->dev = next_net_device_rcu(state->dev);
461 state->dev = next_net_device(state->dev);
462 if (!state->dev) { 461 if (!state->dev) {
463 state->idev = NULL; 462 state->idev = NULL;
464 break; 463 break;
465 } 464 }
466 state->idev = in6_dev_get(state->dev); 465 state->idev = __in6_dev_get(state->dev);
467 if (!state->idev) 466 if (!state->idev)
468 continue; 467 continue;
469 read_lock_bh(&state->idev->lock); 468 read_lock_bh(&state->idev->lock);
@@ -482,29 +481,30 @@ static struct ifacaddr6 *ac6_get_idx(struct seq_file *seq, loff_t pos)
482} 481}
483 482
484static void *ac6_seq_start(struct seq_file *seq, loff_t *pos) 483static void *ac6_seq_start(struct seq_file *seq, loff_t *pos)
485 __acquires(dev_base_lock) 484 __acquires(RCU)
486{ 485{
487 read_lock(&dev_base_lock); 486 rcu_read_lock();
488 return ac6_get_idx(seq, *pos); 487 return ac6_get_idx(seq, *pos);
489} 488}
490 489
491static void *ac6_seq_next(struct seq_file *seq, void *v, loff_t *pos) 490static void *ac6_seq_next(struct seq_file *seq, void *v, loff_t *pos)
492{ 491{
493 struct ifacaddr6 *im; 492 struct ifacaddr6 *im = ac6_get_next(seq, v);
494 im = ac6_get_next(seq, v); 493
495 ++*pos; 494 ++*pos;
496 return im; 495 return im;
497} 496}
498 497
499static void ac6_seq_stop(struct seq_file *seq, void *v) 498static void ac6_seq_stop(struct seq_file *seq, void *v)
500 __releases(dev_base_lock) 499 __releases(RCU)
501{ 500{
502 struct ac6_iter_state *state = ac6_seq_private(seq); 501 struct ac6_iter_state *state = ac6_seq_private(seq);
502
503 if (likely(state->idev != NULL)) { 503 if (likely(state->idev != NULL)) {
504 read_unlock_bh(&state->idev->lock); 504 read_unlock_bh(&state->idev->lock);
505 in6_dev_put(state->idev); 505 state->idev = NULL;
506 } 506 }
507 read_unlock(&dev_base_lock); 507 rcu_read_unlock();
508} 508}
509 509
510static int ac6_seq_show(struct seq_file *seq, void *v) 510static int ac6_seq_show(struct seq_file *seq, void *v)
@@ -539,7 +539,7 @@ static const struct file_operations ac6_seq_fops = {
539 .release = seq_release_net, 539 .release = seq_release_net,
540}; 540};
541 541
542int ac6_proc_init(struct net *net) 542int __net_init ac6_proc_init(struct net *net)
543{ 543{
544 if (!proc_net_fops_create(net, "anycast6", S_IRUGO, &ac6_seq_fops)) 544 if (!proc_net_fops_create(net, "anycast6", S_IRUGO, &ac6_seq_fops))
545 return -ENOMEM; 545 return -ENOMEM;