diff options
-rw-r--r-- | net/ipv4/fib_trie.c | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 72c78c2209d5..a15cb0d2e113 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -148,10 +148,10 @@ struct trie_stat { | |||
148 | 148 | ||
149 | struct trie { | 149 | struct trie { |
150 | struct node *trie; | 150 | struct node *trie; |
151 | unsigned int size; | ||
151 | #ifdef CONFIG_IP_FIB_TRIE_STATS | 152 | #ifdef CONFIG_IP_FIB_TRIE_STATS |
152 | struct trie_use_stats stats; | 153 | struct trie_use_stats stats; |
153 | #endif | 154 | #endif |
154 | int size; | ||
155 | }; | 155 | }; |
156 | 156 | ||
157 | static void put_child(struct trie *t, struct tnode *tn, int i, struct node *n); | 157 | static void put_child(struct trie *t, struct tnode *tn, int i, struct node *n); |
@@ -1045,7 +1045,6 @@ static struct list_head *fib_insert_node(struct trie *t, u32 key, int plen) | |||
1045 | insert_leaf_info(&l->list, li); | 1045 | insert_leaf_info(&l->list, li); |
1046 | goto done; | 1046 | goto done; |
1047 | } | 1047 | } |
1048 | t->size++; | ||
1049 | l = leaf_new(); | 1048 | l = leaf_new(); |
1050 | 1049 | ||
1051 | if (!l) | 1050 | if (!l) |
@@ -1261,6 +1260,8 @@ static int fn_trie_insert(struct fib_table *tb, struct fib_config *cfg) | |||
1261 | list_add_tail_rcu(&new_fa->fa_list, | 1260 | list_add_tail_rcu(&new_fa->fa_list, |
1262 | (fa ? &fa->fa_list : fa_head)); | 1261 | (fa ? &fa->fa_list : fa_head)); |
1263 | 1262 | ||
1263 | t->size++; | ||
1264 | |||
1264 | rt_cache_flush(-1); | 1265 | rt_cache_flush(-1); |
1265 | rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id, | 1266 | rtmsg_fib(RTM_NEWROUTE, htonl(key), new_fa, plen, tb->tb_id, |
1266 | &cfg->fc_nlinfo, 0); | 1267 | &cfg->fc_nlinfo, 0); |
@@ -2131,50 +2132,34 @@ static void trie_show_usage(struct seq_file *seq, | |||
2131 | } | 2132 | } |
2132 | #endif /* CONFIG_IP_FIB_TRIE_STATS */ | 2133 | #endif /* CONFIG_IP_FIB_TRIE_STATS */ |
2133 | 2134 | ||
2135 | static void fib_trie_show(struct seq_file *seq, const char *name, struct trie *trie) | ||
2136 | { | ||
2137 | struct trie_stat stat; | ||
2138 | |||
2139 | seq_printf(seq, "%s: %d\n", name, trie->size); | ||
2140 | trie_collect_stats(trie, &stat); | ||
2141 | trie_show_stats(seq, &stat); | ||
2142 | #ifdef CONFIG_IP_FIB_TRIE_STATS | ||
2143 | trie_show_usage(seq, &trie->stats); | ||
2144 | #endif | ||
2145 | } | ||
2134 | 2146 | ||
2135 | static int fib_triestat_seq_show(struct seq_file *seq, void *v) | 2147 | static int fib_triestat_seq_show(struct seq_file *seq, void *v) |
2136 | { | 2148 | { |
2137 | struct net *net = (struct net *)seq->private; | 2149 | struct net *net = (struct net *)seq->private; |
2138 | struct trie *trie_local, *trie_main; | ||
2139 | struct trie_stat *stat; | ||
2140 | struct fib_table *tb; | 2150 | struct fib_table *tb; |
2141 | 2151 | ||
2142 | trie_local = NULL; | 2152 | seq_printf(seq, |
2153 | "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", | ||
2154 | sizeof(struct leaf), sizeof(struct tnode)); | ||
2155 | |||
2143 | tb = fib_get_table(net, RT_TABLE_LOCAL); | 2156 | tb = fib_get_table(net, RT_TABLE_LOCAL); |
2144 | if (tb) | 2157 | if (tb) |
2145 | trie_local = (struct trie *) tb->tb_data; | 2158 | fib_trie_show(seq, "Local", (struct trie *) tb->tb_data); |
2146 | 2159 | ||
2147 | trie_main = NULL; | ||
2148 | tb = fib_get_table(net, RT_TABLE_MAIN); | 2160 | tb = fib_get_table(net, RT_TABLE_MAIN); |
2149 | if (tb) | 2161 | if (tb) |
2150 | trie_main = (struct trie *) tb->tb_data; | 2162 | fib_trie_show(seq, "Main", (struct trie *) tb->tb_data); |
2151 | |||
2152 | |||
2153 | stat = kmalloc(sizeof(*stat), GFP_KERNEL); | ||
2154 | if (!stat) | ||
2155 | return -ENOMEM; | ||
2156 | |||
2157 | seq_printf(seq, "Basic info: size of leaf: %Zd bytes, size of tnode: %Zd bytes.\n", | ||
2158 | sizeof(struct leaf), sizeof(struct tnode)); | ||
2159 | |||
2160 | if (trie_local) { | ||
2161 | seq_printf(seq, "Local:\n"); | ||
2162 | trie_collect_stats(trie_local, stat); | ||
2163 | trie_show_stats(seq, stat); | ||
2164 | #ifdef CONFIG_IP_FIB_TRIE_STATS | ||
2165 | trie_show_usage(seq, &trie_local->stats); | ||
2166 | #endif | ||
2167 | } | ||
2168 | |||
2169 | if (trie_main) { | ||
2170 | seq_printf(seq, "Main:\n"); | ||
2171 | trie_collect_stats(trie_main, stat); | ||
2172 | trie_show_stats(seq, stat); | ||
2173 | #ifdef CONFIG_IP_FIB_TRIE_STATS | ||
2174 | trie_show_usage(seq, &trie_main->stats); | ||
2175 | #endif | ||
2176 | } | ||
2177 | kfree(stat); | ||
2178 | 2163 | ||
2179 | return 0; | 2164 | return 0; |
2180 | } | 2165 | } |