aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_trie.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r--net/ipv4/fib_trie.c51
1 files changed, 35 insertions, 16 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 214c34732e84..9be7da7c3a8f 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -50,7 +50,7 @@
50 * Patrick McHardy <kaber@trash.net> 50 * Patrick McHardy <kaber@trash.net>
51 */ 51 */
52 52
53#define VERSION "0.407" 53#define VERSION "0.408"
54 54
55#include <asm/uaccess.h> 55#include <asm/uaccess.h>
56#include <asm/system.h> 56#include <asm/system.h>
@@ -292,8 +292,8 @@ static inline void check_tnode(const struct tnode *tn)
292 292
293static int halve_threshold = 25; 293static int halve_threshold = 25;
294static int inflate_threshold = 50; 294static int inflate_threshold = 50;
295static int halve_threshold_root = 15; 295static int halve_threshold_root = 8;
296static int inflate_threshold_root = 25; 296static int inflate_threshold_root = 15;
297 297
298 298
299static void __alias_free_mem(struct rcu_head *head) 299static void __alias_free_mem(struct rcu_head *head)
@@ -350,11 +350,10 @@ static void __tnode_free_rcu(struct rcu_head *head)
350 350
351static inline void tnode_free(struct tnode *tn) 351static inline void tnode_free(struct tnode *tn)
352{ 352{
353 if(IS_LEAF(tn)) { 353 if (IS_LEAF(tn)) {
354 struct leaf *l = (struct leaf *) tn; 354 struct leaf *l = (struct leaf *) tn;
355 call_rcu_bh(&l->rcu, __leaf_free_rcu); 355 call_rcu_bh(&l->rcu, __leaf_free_rcu);
356 } 356 } else
357 else
358 call_rcu(&tn->rcu, __tnode_free_rcu); 357 call_rcu(&tn->rcu, __tnode_free_rcu);
359} 358}
360 359
@@ -459,6 +458,7 @@ static struct node *resize(struct trie *t, struct tnode *tn)
459 struct tnode *old_tn; 458 struct tnode *old_tn;
460 int inflate_threshold_use; 459 int inflate_threshold_use;
461 int halve_threshold_use; 460 int halve_threshold_use;
461 int max_resize;
462 462
463 if (!tn) 463 if (!tn)
464 return NULL; 464 return NULL;
@@ -553,13 +553,14 @@ static struct node *resize(struct trie *t, struct tnode *tn)
553 553
554 /* Keep root node larger */ 554 /* Keep root node larger */
555 555
556 if(!tn->parent) 556 if (!tn->parent)
557 inflate_threshold_use = inflate_threshold_root; 557 inflate_threshold_use = inflate_threshold_root;
558 else 558 else
559 inflate_threshold_use = inflate_threshold; 559 inflate_threshold_use = inflate_threshold;
560 560
561 err = 0; 561 err = 0;
562 while ((tn->full_children > 0 && 562 max_resize = 10;
563 while ((tn->full_children > 0 && max_resize-- &&
563 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >= 564 50 * (tn->full_children + tnode_child_length(tn) - tn->empty_children) >=
564 inflate_threshold_use * tnode_child_length(tn))) { 565 inflate_threshold_use * tnode_child_length(tn))) {
565 566
@@ -574,6 +575,15 @@ static struct node *resize(struct trie *t, struct tnode *tn)
574 } 575 }
575 } 576 }
576 577
578 if (max_resize < 0) {
579 if (!tn->parent)
580 printk(KERN_WARNING "Fix inflate_threshold_root. Now=%d size=%d bits\n",
581 inflate_threshold_root, tn->bits);
582 else
583 printk(KERN_WARNING "Fix inflate_threshold. Now=%d size=%d bits\n",
584 inflate_threshold, tn->bits);
585 }
586
577 check_tnode(tn); 587 check_tnode(tn);
578 588
579 /* 589 /*
@@ -584,13 +594,14 @@ static struct node *resize(struct trie *t, struct tnode *tn)
584 594
585 /* Keep root node larger */ 595 /* Keep root node larger */
586 596
587 if(!tn->parent) 597 if (!tn->parent)
588 halve_threshold_use = halve_threshold_root; 598 halve_threshold_use = halve_threshold_root;
589 else 599 else
590 halve_threshold_use = halve_threshold; 600 halve_threshold_use = halve_threshold;
591 601
592 err = 0; 602 err = 0;
593 while (tn->bits > 1 && 603 max_resize = 10;
604 while (tn->bits > 1 && max_resize-- &&
594 100 * (tnode_child_length(tn) - tn->empty_children) < 605 100 * (tnode_child_length(tn) - tn->empty_children) <
595 halve_threshold_use * tnode_child_length(tn)) { 606 halve_threshold_use * tnode_child_length(tn)) {
596 607
@@ -605,6 +616,14 @@ static struct node *resize(struct trie *t, struct tnode *tn)
605 } 616 }
606 } 617 }
607 618
619 if (max_resize < 0) {
620 if (!tn->parent)
621 printk(KERN_WARNING "Fix halve_threshold_root. Now=%d size=%d bits\n",
622 halve_threshold_root, tn->bits);
623 else
624 printk(KERN_WARNING "Fix halve_threshold. Now=%d size=%d bits\n",
625 halve_threshold, tn->bits);
626 }
608 627
609 /* Only one child remains */ 628 /* Only one child remains */
610 if (tn->empty_children == tnode_child_length(tn) - 1) 629 if (tn->empty_children == tnode_child_length(tn) - 1)
@@ -2039,12 +2058,12 @@ static struct node *fib_trie_get_first(struct fib_trie_iter *iter,
2039{ 2058{
2040 struct node *n ; 2059 struct node *n ;
2041 2060
2042 if(!t) 2061 if (!t)
2043 return NULL; 2062 return NULL;
2044 2063
2045 n = rcu_dereference(t->trie); 2064 n = rcu_dereference(t->trie);
2046 2065
2047 if(!iter) 2066 if (!iter)
2048 return NULL; 2067 return NULL;
2049 2068
2050 if (n) { 2069 if (n) {
@@ -2084,7 +2103,7 @@ static void trie_collect_stats(struct trie *t, struct trie_stat *s)
2084 int i; 2103 int i;
2085 2104
2086 s->tnodes++; 2105 s->tnodes++;
2087 if(tn->bits < MAX_STAT_DEPTH) 2106 if (tn->bits < MAX_STAT_DEPTH)
2088 s->nodesizes[tn->bits]++; 2107 s->nodesizes[tn->bits]++;
2089 2108
2090 for (i = 0; i < (1<<tn->bits); i++) 2109 for (i = 0; i < (1<<tn->bits); i++)
@@ -2250,7 +2269,7 @@ static inline const char *rtn_scope(enum rt_scope_t s)
2250{ 2269{
2251 static char buf[32]; 2270 static char buf[32];
2252 2271
2253 switch(s) { 2272 switch (s) {
2254 case RT_SCOPE_UNIVERSE: return "universe"; 2273 case RT_SCOPE_UNIVERSE: return "universe";
2255 case RT_SCOPE_SITE: return "site"; 2274 case RT_SCOPE_SITE: return "site";
2256 case RT_SCOPE_LINK: return "link"; 2275 case RT_SCOPE_LINK: return "link";
@@ -2340,7 +2359,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2340 return 0; 2359 return 0;
2341} 2360}
2342 2361
2343static struct seq_operations fib_trie_seq_ops = { 2362static const struct seq_operations fib_trie_seq_ops = {
2344 .start = fib_trie_seq_start, 2363 .start = fib_trie_seq_start,
2345 .next = fib_trie_seq_next, 2364 .next = fib_trie_seq_next,
2346 .stop = fib_trie_seq_stop, 2365 .stop = fib_trie_seq_stop,
@@ -2461,7 +2480,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2461 return 0; 2480 return 0;
2462} 2481}
2463 2482
2464static struct seq_operations fib_route_seq_ops = { 2483static const struct seq_operations fib_route_seq_ops = {
2465 .start = fib_trie_seq_start, 2484 .start = fib_trie_seq_start,
2466 .next = fib_trie_seq_next, 2485 .next = fib_trie_seq_next,
2467 .stop = fib_trie_seq_stop, 2486 .stop = fib_trie_seq_stop,