diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2007-12-07 03:47:47 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:56:49 -0500 |
commit | 877a9bff3889512d7326d6bf0ba6ed3ddda6d772 (patch) | |
tree | 87193403343881696a7ea9ea5919644cb51dc8ea /net/ipv4/fib_trie.c | |
parent | bb803175865dd030420eebbc87298414c7725019 (diff) |
[IPV4]: Move trie_local and trie_main into the proc iterator.
We only use these variables when displaying the trie in proc so
place them into the iterator to make this explicit. We should
probably do something smarter to handle the CONFIG_IP_MULTIPLE_TABLES
case but at least this makes it clear that the silliness is limited
to the display in /proc.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv4/fib_trie.c')
-rw-r--r-- | net/ipv4/fib_trie.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index 1010b469d7d3..13a80aa911d8 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -164,7 +164,6 @@ static struct tnode *halve(struct trie *t, struct tnode *tn); | |||
164 | static void tnode_free(struct tnode *tn); | 164 | static void tnode_free(struct tnode *tn); |
165 | 165 | ||
166 | static struct kmem_cache *fn_alias_kmem __read_mostly; | 166 | static struct kmem_cache *fn_alias_kmem __read_mostly; |
167 | static struct trie *trie_local = NULL, *trie_main = NULL; | ||
168 | 167 | ||
169 | static inline struct tnode *node_parent(struct node *node) | 168 | static inline struct tnode *node_parent(struct node *node) |
170 | { | 169 | { |
@@ -2003,11 +2002,6 @@ struct fib_table * __init fib_hash_init(u32 id) | |||
2003 | trie_init(t); | 2002 | trie_init(t); |
2004 | 2003 | ||
2005 | if (id == RT_TABLE_LOCAL) | 2004 | if (id == RT_TABLE_LOCAL) |
2006 | trie_local = t; | ||
2007 | else if (id == RT_TABLE_MAIN) | ||
2008 | trie_main = t; | ||
2009 | |||
2010 | if (id == RT_TABLE_LOCAL) | ||
2011 | printk(KERN_INFO "IPv4 FIB: Using LC-trie version %s\n", VERSION); | 2005 | printk(KERN_INFO "IPv4 FIB: Using LC-trie version %s\n", VERSION); |
2012 | 2006 | ||
2013 | return tb; | 2007 | return tb; |
@@ -2016,6 +2010,7 @@ struct fib_table * __init fib_hash_init(u32 id) | |||
2016 | #ifdef CONFIG_PROC_FS | 2010 | #ifdef CONFIG_PROC_FS |
2017 | /* Depth first Trie walk iterator */ | 2011 | /* Depth first Trie walk iterator */ |
2018 | struct fib_trie_iter { | 2012 | struct fib_trie_iter { |
2013 | struct trie *trie_local, *trie_main; | ||
2019 | struct tnode *tnode; | 2014 | struct tnode *tnode; |
2020 | struct trie *trie; | 2015 | struct trie *trie; |
2021 | unsigned index; | 2016 | unsigned index; |
@@ -2182,7 +2177,20 @@ static void trie_show_stats(struct seq_file *seq, struct trie_stat *stat) | |||
2182 | 2177 | ||
2183 | static int fib_triestat_seq_show(struct seq_file *seq, void *v) | 2178 | static int fib_triestat_seq_show(struct seq_file *seq, void *v) |
2184 | { | 2179 | { |
2180 | struct trie *trie_local, *trie_main; | ||
2185 | struct trie_stat *stat; | 2181 | struct trie_stat *stat; |
2182 | struct fib_table *tb; | ||
2183 | |||
2184 | trie_local = NULL; | ||
2185 | tb = fib_get_table(RT_TABLE_LOCAL); | ||
2186 | if (tb) | ||
2187 | trie_local = (struct trie *) tb->tb_data; | ||
2188 | |||
2189 | trie_main = NULL; | ||
2190 | tb = fib_get_table(RT_TABLE_MAIN); | ||
2191 | if (tb) | ||
2192 | trie_main = (struct trie *) tb->tb_data; | ||
2193 | |||
2186 | 2194 | ||
2187 | stat = kmalloc(sizeof(*stat), GFP_KERNEL); | 2195 | stat = kmalloc(sizeof(*stat), GFP_KERNEL); |
2188 | if (!stat) | 2196 | if (!stat) |
@@ -2226,13 +2234,13 @@ static struct node *fib_trie_get_idx(struct fib_trie_iter *iter, | |||
2226 | loff_t idx = 0; | 2234 | loff_t idx = 0; |
2227 | struct node *n; | 2235 | struct node *n; |
2228 | 2236 | ||
2229 | for (n = fib_trie_get_first(iter, trie_local); | 2237 | for (n = fib_trie_get_first(iter, iter->trie_local); |
2230 | n; ++idx, n = fib_trie_get_next(iter)) { | 2238 | n; ++idx, n = fib_trie_get_next(iter)) { |
2231 | if (pos == idx) | 2239 | if (pos == idx) |
2232 | return n; | 2240 | return n; |
2233 | } | 2241 | } |
2234 | 2242 | ||
2235 | for (n = fib_trie_get_first(iter, trie_main); | 2243 | for (n = fib_trie_get_first(iter, iter->trie_main); |
2236 | n; ++idx, n = fib_trie_get_next(iter)) { | 2244 | n; ++idx, n = fib_trie_get_next(iter)) { |
2237 | if (pos == idx) | 2245 | if (pos == idx) |
2238 | return n; | 2246 | return n; |
@@ -2242,10 +2250,23 @@ static struct node *fib_trie_get_idx(struct fib_trie_iter *iter, | |||
2242 | 2250 | ||
2243 | static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) | 2251 | static void *fib_trie_seq_start(struct seq_file *seq, loff_t *pos) |
2244 | { | 2252 | { |
2253 | struct fib_trie_iter *iter = seq->private; | ||
2254 | struct fib_table *tb; | ||
2255 | |||
2256 | if (!iter->trie_local) { | ||
2257 | tb = fib_get_table(RT_TABLE_LOCAL); | ||
2258 | if (tb) | ||
2259 | iter->trie_local = (struct trie *) tb->tb_data; | ||
2260 | } | ||
2261 | if (!iter->trie_main) { | ||
2262 | tb = fib_get_table(RT_TABLE_MAIN); | ||
2263 | if (tb) | ||
2264 | iter->trie_main = (struct trie *) tb->tb_data; | ||
2265 | } | ||
2245 | rcu_read_lock(); | 2266 | rcu_read_lock(); |
2246 | if (*pos == 0) | 2267 | if (*pos == 0) |
2247 | return SEQ_START_TOKEN; | 2268 | return SEQ_START_TOKEN; |
2248 | return fib_trie_get_idx(seq->private, *pos - 1); | 2269 | return fib_trie_get_idx(iter, *pos - 1); |
2249 | } | 2270 | } |
2250 | 2271 | ||
2251 | static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) | 2272 | static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) |
@@ -2263,8 +2284,8 @@ static void *fib_trie_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |||
2263 | return v; | 2284 | return v; |
2264 | 2285 | ||
2265 | /* continue scan in next trie */ | 2286 | /* continue scan in next trie */ |
2266 | if (iter->trie == trie_local) | 2287 | if (iter->trie == iter->trie_local) |
2267 | return fib_trie_get_first(iter, trie_main); | 2288 | return fib_trie_get_first(iter, iter->trie_main); |
2268 | 2289 | ||
2269 | return NULL; | 2290 | return NULL; |
2270 | } | 2291 | } |
@@ -2330,7 +2351,7 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v) | |||
2330 | return 0; | 2351 | return 0; |
2331 | 2352 | ||
2332 | if (!node_parent(n)) { | 2353 | if (!node_parent(n)) { |
2333 | if (iter->trie == trie_local) | 2354 | if (iter->trie == iter->trie_local) |
2334 | seq_puts(seq, "<local>:\n"); | 2355 | seq_puts(seq, "<local>:\n"); |
2335 | else | 2356 | else |
2336 | seq_puts(seq, "<main>:\n"); | 2357 | seq_puts(seq, "<main>:\n"); |
@@ -2429,7 +2450,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) | |||
2429 | return 0; | 2450 | return 0; |
2430 | } | 2451 | } |
2431 | 2452 | ||
2432 | if (iter->trie == trie_local) | 2453 | if (iter->trie == iter->trie_local) |
2433 | return 0; | 2454 | return 0; |
2434 | if (IS_TNODE(l)) | 2455 | if (IS_TNODE(l)) |
2435 | return 0; | 2456 | return 0; |