diff options
Diffstat (limited to 'net/ipv6/ip6_fib.c')
-rw-r--r-- | net/ipv6/ip6_fib.c | 60 |
1 files changed, 22 insertions, 38 deletions
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 4de2b9efcacb..08ea2de28d63 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -661,17 +661,17 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, | |||
661 | 661 | ||
662 | static __inline__ void fib6_start_gc(struct net *net, struct rt6_info *rt) | 662 | static __inline__ void fib6_start_gc(struct net *net, struct rt6_info *rt) |
663 | { | 663 | { |
664 | if (net->ipv6.ip6_fib_timer->expires == 0 && | 664 | if (!timer_pending(&net->ipv6.ip6_fib_timer) && |
665 | (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE))) | 665 | (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE))) |
666 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + | 666 | mod_timer(&net->ipv6.ip6_fib_timer, |
667 | net->ipv6.sysctl.ip6_rt_gc_interval); | 667 | jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); |
668 | } | 668 | } |
669 | 669 | ||
670 | void fib6_force_start_gc(struct net *net) | 670 | void fib6_force_start_gc(struct net *net) |
671 | { | 671 | { |
672 | if (net->ipv6.ip6_fib_timer->expires == 0) | 672 | if (!timer_pending(&net->ipv6.ip6_fib_timer)) |
673 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + | 673 | mod_timer(&net->ipv6.ip6_fib_timer, |
674 | net->ipv6.sysctl.ip6_rt_gc_interval); | 674 | jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); |
675 | } | 675 | } |
676 | 676 | ||
677 | /* | 677 | /* |
@@ -1447,27 +1447,23 @@ void fib6_run_gc(unsigned long expires, struct net *net) | |||
1447 | gc_args.timeout = expires ? (int)expires : | 1447 | gc_args.timeout = expires ? (int)expires : |
1448 | net->ipv6.sysctl.ip6_rt_gc_interval; | 1448 | net->ipv6.sysctl.ip6_rt_gc_interval; |
1449 | } else { | 1449 | } else { |
1450 | local_bh_disable(); | 1450 | if (!spin_trylock_bh(&fib6_gc_lock)) { |
1451 | if (!spin_trylock(&fib6_gc_lock)) { | 1451 | mod_timer(&net->ipv6.ip6_fib_timer, jiffies + HZ); |
1452 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + HZ); | ||
1453 | local_bh_enable(); | ||
1454 | return; | 1452 | return; |
1455 | } | 1453 | } |
1456 | gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval; | 1454 | gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval; |
1457 | } | 1455 | } |
1458 | gc_args.more = 0; | ||
1459 | 1456 | ||
1460 | icmp6_dst_gc(&gc_args.more); | 1457 | gc_args.more = icmp6_dst_gc(); |
1461 | 1458 | ||
1462 | fib6_clean_all(net, fib6_age, 0, NULL); | 1459 | fib6_clean_all(net, fib6_age, 0, NULL); |
1463 | 1460 | ||
1464 | if (gc_args.more) | 1461 | if (gc_args.more) |
1465 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + | 1462 | mod_timer(&net->ipv6.ip6_fib_timer, |
1466 | net->ipv6.sysctl.ip6_rt_gc_interval); | 1463 | round_jiffies(jiffies |
1467 | else { | 1464 | + net->ipv6.sysctl.ip6_rt_gc_interval)); |
1468 | del_timer(net->ipv6.ip6_fib_timer); | 1465 | else |
1469 | net->ipv6.ip6_fib_timer->expires = 0; | 1466 | del_timer(&net->ipv6.ip6_fib_timer); |
1470 | } | ||
1471 | spin_unlock_bh(&fib6_gc_lock); | 1467 | spin_unlock_bh(&fib6_gc_lock); |
1472 | } | 1468 | } |
1473 | 1469 | ||
@@ -1478,24 +1474,15 @@ static void fib6_gc_timer_cb(unsigned long arg) | |||
1478 | 1474 | ||
1479 | static int fib6_net_init(struct net *net) | 1475 | static int fib6_net_init(struct net *net) |
1480 | { | 1476 | { |
1481 | int ret; | 1477 | setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net); |
1482 | struct timer_list *timer; | ||
1483 | |||
1484 | ret = -ENOMEM; | ||
1485 | timer = kzalloc(sizeof(*timer), GFP_KERNEL); | ||
1486 | if (!timer) | ||
1487 | goto out; | ||
1488 | |||
1489 | setup_timer(timer, fib6_gc_timer_cb, (unsigned long)net); | ||
1490 | net->ipv6.ip6_fib_timer = timer; | ||
1491 | 1478 | ||
1492 | net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL); | 1479 | net->ipv6.rt6_stats = kzalloc(sizeof(*net->ipv6.rt6_stats), GFP_KERNEL); |
1493 | if (!net->ipv6.rt6_stats) | 1480 | if (!net->ipv6.rt6_stats) |
1494 | goto out_timer; | 1481 | goto out_timer; |
1495 | 1482 | ||
1496 | net->ipv6.fib_table_hash = | 1483 | net->ipv6.fib_table_hash = kcalloc(FIB_TABLE_HASHSZ, |
1497 | kzalloc(sizeof(*net->ipv6.fib_table_hash)*FIB_TABLE_HASHSZ, | 1484 | sizeof(*net->ipv6.fib_table_hash), |
1498 | GFP_KERNEL); | 1485 | GFP_KERNEL); |
1499 | if (!net->ipv6.fib_table_hash) | 1486 | if (!net->ipv6.fib_table_hash) |
1500 | goto out_rt6_stats; | 1487 | goto out_rt6_stats; |
1501 | 1488 | ||
@@ -1521,9 +1508,7 @@ static int fib6_net_init(struct net *net) | |||
1521 | #endif | 1508 | #endif |
1522 | fib6_tables_init(net); | 1509 | fib6_tables_init(net); |
1523 | 1510 | ||
1524 | ret = 0; | 1511 | return 0; |
1525 | out: | ||
1526 | return ret; | ||
1527 | 1512 | ||
1528 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 1513 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
1529 | out_fib6_main_tbl: | 1514 | out_fib6_main_tbl: |
@@ -1534,15 +1519,14 @@ out_fib_table_hash: | |||
1534 | out_rt6_stats: | 1519 | out_rt6_stats: |
1535 | kfree(net->ipv6.rt6_stats); | 1520 | kfree(net->ipv6.rt6_stats); |
1536 | out_timer: | 1521 | out_timer: |
1537 | kfree(timer); | 1522 | return -ENOMEM; |
1538 | goto out; | ||
1539 | } | 1523 | } |
1540 | 1524 | ||
1541 | static void fib6_net_exit(struct net *net) | 1525 | static void fib6_net_exit(struct net *net) |
1542 | { | 1526 | { |
1543 | rt6_ifdown(net, NULL); | 1527 | rt6_ifdown(net, NULL); |
1544 | del_timer_sync(net->ipv6.ip6_fib_timer); | 1528 | del_timer_sync(&net->ipv6.ip6_fib_timer); |
1545 | kfree(net->ipv6.ip6_fib_timer); | 1529 | |
1546 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 1530 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
1547 | kfree(net->ipv6.fib6_local_tbl); | 1531 | kfree(net->ipv6.fib6_local_tbl); |
1548 | #endif | 1532 | #endif |