diff options
Diffstat (limited to 'net/ipv6/ip6_fib.c')
-rw-r--r-- | net/ipv6/ip6_fib.c | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c index 1ee4fa17c129..08ea2de28d63 100644 --- a/net/ipv6/ip6_fib.c +++ b/net/ipv6/ip6_fib.c | |||
@@ -5,8 +5,6 @@ | |||
5 | * Authors: | 5 | * Authors: |
6 | * Pedro Roque <roque@di.fc.ul.pt> | 6 | * Pedro Roque <roque@di.fc.ul.pt> |
7 | * | 7 | * |
8 | * $Id: ip6_fib.c,v 1.25 2001/10/31 21:55:55 davem Exp $ | ||
9 | * | ||
10 | * This program is free software; you can redistribute it and/or | 8 | * This program is free software; you can redistribute it and/or |
11 | * modify it under the terms of the GNU General Public License | 9 | * modify it under the terms of the GNU General Public License |
12 | * as published by the Free Software Foundation; either version | 10 | * as published by the Free Software Foundation; either version |
@@ -663,17 +661,17 @@ static int fib6_add_rt2node(struct fib6_node *fn, struct rt6_info *rt, | |||
663 | 661 | ||
664 | 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) |
665 | { | 663 | { |
666 | if (net->ipv6.ip6_fib_timer->expires == 0 && | 664 | if (!timer_pending(&net->ipv6.ip6_fib_timer) && |
667 | (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE))) | 665 | (rt->rt6i_flags & (RTF_EXPIRES|RTF_CACHE))) |
668 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + | 666 | mod_timer(&net->ipv6.ip6_fib_timer, |
669 | net->ipv6.sysctl.ip6_rt_gc_interval); | 667 | jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); |
670 | } | 668 | } |
671 | 669 | ||
672 | void fib6_force_start_gc(struct net *net) | 670 | void fib6_force_start_gc(struct net *net) |
673 | { | 671 | { |
674 | if (net->ipv6.ip6_fib_timer->expires == 0) | 672 | if (!timer_pending(&net->ipv6.ip6_fib_timer)) |
675 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + | 673 | mod_timer(&net->ipv6.ip6_fib_timer, |
676 | net->ipv6.sysctl.ip6_rt_gc_interval); | 674 | jiffies + net->ipv6.sysctl.ip6_rt_gc_interval); |
677 | } | 675 | } |
678 | 676 | ||
679 | /* | 677 | /* |
@@ -1449,27 +1447,23 @@ void fib6_run_gc(unsigned long expires, struct net *net) | |||
1449 | gc_args.timeout = expires ? (int)expires : | 1447 | gc_args.timeout = expires ? (int)expires : |
1450 | net->ipv6.sysctl.ip6_rt_gc_interval; | 1448 | net->ipv6.sysctl.ip6_rt_gc_interval; |
1451 | } else { | 1449 | } else { |
1452 | local_bh_disable(); | 1450 | if (!spin_trylock_bh(&fib6_gc_lock)) { |
1453 | if (!spin_trylock(&fib6_gc_lock)) { | 1451 | mod_timer(&net->ipv6.ip6_fib_timer, jiffies + HZ); |
1454 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + HZ); | ||
1455 | local_bh_enable(); | ||
1456 | return; | 1452 | return; |
1457 | } | 1453 | } |
1458 | gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval; | 1454 | gc_args.timeout = net->ipv6.sysctl.ip6_rt_gc_interval; |
1459 | } | 1455 | } |
1460 | gc_args.more = 0; | ||
1461 | 1456 | ||
1462 | icmp6_dst_gc(&gc_args.more); | 1457 | gc_args.more = icmp6_dst_gc(); |
1463 | 1458 | ||
1464 | fib6_clean_all(net, fib6_age, 0, NULL); | 1459 | fib6_clean_all(net, fib6_age, 0, NULL); |
1465 | 1460 | ||
1466 | if (gc_args.more) | 1461 | if (gc_args.more) |
1467 | mod_timer(net->ipv6.ip6_fib_timer, jiffies + | 1462 | mod_timer(&net->ipv6.ip6_fib_timer, |
1468 | net->ipv6.sysctl.ip6_rt_gc_interval); | 1463 | round_jiffies(jiffies |
1469 | else { | 1464 | + net->ipv6.sysctl.ip6_rt_gc_interval)); |
1470 | del_timer(net->ipv6.ip6_fib_timer); | 1465 | else |
1471 | net->ipv6.ip6_fib_timer->expires = 0; | 1466 | del_timer(&net->ipv6.ip6_fib_timer); |
1472 | } | ||
1473 | spin_unlock_bh(&fib6_gc_lock); | 1467 | spin_unlock_bh(&fib6_gc_lock); |
1474 | } | 1468 | } |
1475 | 1469 | ||
@@ -1480,24 +1474,15 @@ static void fib6_gc_timer_cb(unsigned long arg) | |||
1480 | 1474 | ||
1481 | static int fib6_net_init(struct net *net) | 1475 | static int fib6_net_init(struct net *net) |
1482 | { | 1476 | { |
1483 | int ret; | 1477 | setup_timer(&net->ipv6.ip6_fib_timer, fib6_gc_timer_cb, (unsigned long)net); |
1484 | struct timer_list *timer; | ||
1485 | |||
1486 | ret = -ENOMEM; | ||
1487 | timer = kzalloc(sizeof(*timer), GFP_KERNEL); | ||
1488 | if (!timer) | ||
1489 | goto out; | ||
1490 | |||
1491 | setup_timer(timer, fib6_gc_timer_cb, (unsigned long)net); | ||
1492 | net->ipv6.ip6_fib_timer = timer; | ||
1493 | 1478 | ||
1494 | 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); |
1495 | if (!net->ipv6.rt6_stats) | 1480 | if (!net->ipv6.rt6_stats) |
1496 | goto out_timer; | 1481 | goto out_timer; |
1497 | 1482 | ||
1498 | net->ipv6.fib_table_hash = | 1483 | net->ipv6.fib_table_hash = kcalloc(FIB_TABLE_HASHSZ, |
1499 | kzalloc(sizeof(*net->ipv6.fib_table_hash)*FIB_TABLE_HASHSZ, | 1484 | sizeof(*net->ipv6.fib_table_hash), |
1500 | GFP_KERNEL); | 1485 | GFP_KERNEL); |
1501 | if (!net->ipv6.fib_table_hash) | 1486 | if (!net->ipv6.fib_table_hash) |
1502 | goto out_rt6_stats; | 1487 | goto out_rt6_stats; |
1503 | 1488 | ||
@@ -1523,9 +1508,7 @@ static int fib6_net_init(struct net *net) | |||
1523 | #endif | 1508 | #endif |
1524 | fib6_tables_init(net); | 1509 | fib6_tables_init(net); |
1525 | 1510 | ||
1526 | ret = 0; | 1511 | return 0; |
1527 | out: | ||
1528 | return ret; | ||
1529 | 1512 | ||
1530 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 1513 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
1531 | out_fib6_main_tbl: | 1514 | out_fib6_main_tbl: |
@@ -1536,15 +1519,14 @@ out_fib_table_hash: | |||
1536 | out_rt6_stats: | 1519 | out_rt6_stats: |
1537 | kfree(net->ipv6.rt6_stats); | 1520 | kfree(net->ipv6.rt6_stats); |
1538 | out_timer: | 1521 | out_timer: |
1539 | kfree(timer); | 1522 | return -ENOMEM; |
1540 | goto out; | ||
1541 | } | 1523 | } |
1542 | 1524 | ||
1543 | static void fib6_net_exit(struct net *net) | 1525 | static void fib6_net_exit(struct net *net) |
1544 | { | 1526 | { |
1545 | rt6_ifdown(net, NULL); | 1527 | rt6_ifdown(net, NULL); |
1546 | del_timer_sync(net->ipv6.ip6_fib_timer); | 1528 | del_timer_sync(&net->ipv6.ip6_fib_timer); |
1547 | kfree(net->ipv6.ip6_fib_timer); | 1529 | |
1548 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES | 1530 | #ifdef CONFIG_IPV6_MULTIPLE_TABLES |
1549 | kfree(net->ipv6.fib6_local_tbl); | 1531 | kfree(net->ipv6.fib6_local_tbl); |
1550 | #endif | 1532 | #endif |