aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--net/ipv4/fib_trie.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 899210b3c6b7..1a9231fcebbf 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -143,12 +143,12 @@ struct trie_stat {
143 unsigned int tnodes; 143 unsigned int tnodes;
144 unsigned int leaves; 144 unsigned int leaves;
145 unsigned int nullpointers; 145 unsigned int nullpointers;
146 unsigned int prefixes;
146 unsigned int nodesizes[MAX_STAT_DEPTH]; 147 unsigned int nodesizes[MAX_STAT_DEPTH];
147}; 148};
148 149
149struct trie { 150struct trie {
150 struct node *trie; 151 struct node *trie;
151 unsigned int size;
152#ifdef CONFIG_IP_FIB_TRIE_STATS 152#ifdef CONFIG_IP_FIB_TRIE_STATS
153 struct trie_use_stats stats; 153 struct trie_use_stats stats;
154#endif 154#endif
@@ -1292,8 +1292,6 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg)
1292 list_add_tail_rcu(&new_fa->fa_list, 1292 list_add_tail_rcu(&new_fa->fa_list,
1293 (fa ? &fa->fa_list : fa_head)); 1293 (fa ? &fa->fa_list : fa_head));
1294 1294
1295 t->size++;
1296
1297 rt_cache_flush(-1); 1295 rt_cache_flush(-1);
1298 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id, 1296 rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id,
1299 &cfg->fc_nlinfo, 0); 1297 &cfg->fc_nlinfo, 0);
@@ -1579,9 +1577,6 @@ static int trie_leaf_remove(struct trie *t, t_key key)
1579 * Key found. 1577 * Key found.
1580 * Remove the leaf and rebalance the tree 1578 * Remove the leaf and rebalance the tree
1581 */ 1579 */
1582
1583 t->size--;
1584
1585 tp = node_parent(n); 1580 tp = node_parent(n);
1586 tnode_free((struct tnode *) n); 1581 tnode_free((struct tnode *) n);
1587 1582
@@ -2114,10 +2109,17 @@ static void trie_collect_stats(struct trie *t, struct trie_stat *s)
2114 for (n = fib_trie_get_first(&iter, t); n; 2109 for (n = fib_trie_get_first(&iter, t); n;
2115 n = fib_trie_get_next(&iter)) { 2110 n = fib_trie_get_next(&iter)) {
2116 if (IS_LEAF(n)) { 2111 if (IS_LEAF(n)) {
2112 struct leaf *l = (struct leaf *)n;
2113 struct leaf_info *li;
2114 struct hlist_node *tmp;
2115
2117 s->leaves++; 2116 s->leaves++;
2118 s->totdepth += iter.depth; 2117 s->totdepth += iter.depth;
2119 if (iter.depth > s->maxdepth) 2118 if (iter.depth > s->maxdepth)
2120 s->maxdepth = iter.depth; 2119 s->maxdepth = iter.depth;
2120
2121 hlist_for_each_entry_rcu(li, tmp, &l->list, hlist)
2122 ++s->prefixes;
2121 } else { 2123 } else {
2122 const struct tnode *tn = (const struct tnode *) n; 2124 const struct tnode *tn = (const struct tnode *) n;
2123 int i; 2125 int i;
@@ -2151,8 +2153,11 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat)
2151 seq_printf(seq, "\tMax depth: %u\n", stat->maxdepth); 2153 seq_printf(seq, "\tMax depth: %u\n", stat->maxdepth);
2152 2154
2153 seq_printf(seq, "\tLeaves: %u\n", stat->leaves); 2155 seq_printf(seq, "\tLeaves: %u\n", stat->leaves);
2154
2155 bytes = sizeof(struct leaf) * stat->leaves; 2156 bytes = sizeof(struct leaf) * stat->leaves;
2157
2158 seq_printf(seq, "\tPrefixes: %u\n", stat->prefixes);
2159 bytes += sizeof(struct leaf_info) * stat->prefixes;
2160
2156 seq_printf(seq, "\tInternal nodes: %u\n\t", stat->tnodes); 2161 seq_printf(seq, "\tInternal nodes: %u\n\t", stat->tnodes);
2157 bytes += sizeof(struct tnode) * stat->tnodes; 2162 bytes += sizeof(struct tnode) * stat->tnodes;
2158 2163
@@ -2196,8 +2201,8 @@ static void fib_trie_show(struct seq_file *seq, const char *name,
2196{ 2201{
2197 struct trie_stat stat; 2202 struct trie_stat stat;
2198 2203
2199 seq_printf(seq, "%s: %d\n", name, trie->size);
2200 trie_collect_stats(trie, &stat); 2204 trie_collect_stats(trie, &stat);
2205 seq_printf(seq, "%s:\n", name);
2201 trie_show_stats(seq, &stat); 2206 trie_show_stats(seq, &stat);
2202#ifdef CONFIG_IP_FIB_TRIE_STATS 2207#ifdef CONFIG_IP_FIB_TRIE_STATS
2203 trie_show_usage(seq, &trie->stats); 2208 trie_show_usage(seq, &trie->stats);