aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv4/fib_trie.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 8aa31fe514ee..ccd3efc6a173 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.405" 53#define VERSION "0.406"
54 54
55#include <linux/config.h> 55#include <linux/config.h>
56#include <asm/uaccess.h> 56#include <asm/uaccess.h>
@@ -84,7 +84,7 @@
84#include "fib_lookup.h" 84#include "fib_lookup.h"
85 85
86#undef CONFIG_IP_FIB_TRIE_STATS 86#undef CONFIG_IP_FIB_TRIE_STATS
87#define MAX_CHILDS 16384 87#define MAX_STAT_DEPTH 32
88 88
89#define KEYLENGTH (8*sizeof(t_key)) 89#define KEYLENGTH (8*sizeof(t_key))
90#define MASK_PFX(k, l) (((l)==0)?0:(k >> (KEYLENGTH-l)) << (KEYLENGTH-l)) 90#define MASK_PFX(k, l) (((l)==0)?0:(k >> (KEYLENGTH-l)) << (KEYLENGTH-l))
@@ -154,7 +154,7 @@ struct trie_stat {
154 unsigned int tnodes; 154 unsigned int tnodes;
155 unsigned int leaves; 155 unsigned int leaves;
156 unsigned int nullpointers; 156 unsigned int nullpointers;
157 unsigned int nodesizes[MAX_CHILDS]; 157 unsigned int nodesizes[MAX_STAT_DEPTH];
158}; 158};
159 159
160struct trie { 160struct trie {
@@ -2080,7 +2080,9 @@ static void trie_collect_stats(struct trie *t, struct trie_stat *s)
2080 int i; 2080 int i;
2081 2081
2082 s->tnodes++; 2082 s->tnodes++;
2083 s->nodesizes[tn->bits]++; 2083 if(tn->bits < MAX_STAT_DEPTH)
2084 s->nodesizes[tn->bits]++;
2085
2084 for (i = 0; i < (1<<tn->bits); i++) 2086 for (i = 0; i < (1<<tn->bits); i++)
2085 if (!tn->child[i]) 2087 if (!tn->child[i])
2086 s->nullpointers++; 2088 s->nullpointers++;
@@ -2110,8 +2112,8 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat)
2110 seq_printf(seq, "\tInternal nodes: %d\n\t", stat->tnodes); 2112 seq_printf(seq, "\tInternal nodes: %d\n\t", stat->tnodes);
2111 bytes += sizeof(struct tnode) * stat->tnodes; 2113 bytes += sizeof(struct tnode) * stat->tnodes;
2112 2114
2113 max = MAX_CHILDS-1; 2115 max = MAX_STAT_DEPTH;
2114 while (max >= 0 && stat->nodesizes[max] == 0) 2116 while (max > 0 && stat->nodesizes[max-1] == 0)
2115 max--; 2117 max--;
2116 2118
2117 pointers = 0; 2119 pointers = 0;