aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Hemminger <stephen.hemminger@vyatta.com>2008-01-23 00:54:37 -0500
committerDavid S. Miller <davem@davemloft.net>2008-01-28 18:10:58 -0500
commit1328042e268c936189f15eba5bd9a5a4605a8581 (patch)
tree203acec5a6aa5a06c4d2f7d4431b1650102bb4df
parent936722922f6d2366378de606a40c14f96915474d (diff)
[IPV4] fib_trie: use hash list
The code to dump can use the existing hash chain rather than doing repeated lookup. Signed-off-by: Stephen Hemminger <stephen.hemminger@vyatta.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--net/ipv4/fib_trie.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c
index 1a9231fcebbf..c19d68551eb1 100644
--- a/net/ipv4/fib_trie.c
+++ b/net/ipv4/fib_trie.c
@@ -2399,31 +2399,30 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
2399 2399
2400 } else { 2400 } else {
2401 struct leaf *l = (struct leaf *) n; 2401 struct leaf *l = (struct leaf *) n;
2402 int i; 2402 struct leaf_info *li;
2403 struct hlist_node *node;
2404
2403 __be32 val = htonl(l->key); 2405 __be32 val = htonl(l->key);
2404 2406
2405 seq_indent(seq, iter->depth); 2407 seq_indent(seq, iter->depth);
2406 seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val)); 2408 seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val));
2407 for (i = 32; i >= 0; i--) { 2409
2408 struct leaf_info *li = find_leaf_info(l, i); 2410 hlist_for_each_entry_rcu(li, node, &l->list, hlist) {
2409 2411 struct fib_alias *fa;
2410 if (li) { 2412
2411 struct fib_alias *fa; 2413 list_for_each_entry_rcu(fa, &li->falh, fa_list) {
2412 2414 char buf1[32], buf2[32];
2413 list_for_each_entry_rcu(fa, &li->falh, fa_list) { 2415
2414 char buf1[32], buf2[32]; 2416 seq_indent(seq, iter->depth+1);
2415 2417 seq_printf(seq, " /%d %s %s", li->plen,
2416 seq_indent(seq, iter->depth+1); 2418 rtn_scope(buf1, sizeof(buf1),
2417 seq_printf(seq, " /%d %s %s", i, 2419 fa->fa_scope),
2418 rtn_scope(buf1, sizeof(buf1), 2420 rtn_type(buf2, sizeof(buf2),
2419 fa->fa_scope), 2421 fa->fa_type));
2420 rtn_type(buf2, sizeof(buf2), 2422 if (fa->fa_tos)
2421 fa->fa_type)); 2423 seq_printf(seq, "tos =%d\n",
2422 if (fa->fa_tos) 2424 fa->fa_tos);
2423 seq_printf(seq, "tos =%d\n", 2425 seq_putc(seq, '\n');
2424 fa->fa_tos);
2425 seq_putc(seq, '\n');
2426 }
2427 } 2426 }
2428 } 2427 }
2429 } 2428 }
@@ -2477,8 +2476,8 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2477{ 2476{
2478 const struct fib_trie_iter *iter = seq->private; 2477 const struct fib_trie_iter *iter = seq->private;
2479 struct leaf *l = v; 2478 struct leaf *l = v;
2480 int i; 2479 struct leaf_info *li;
2481 char bf[128]; 2480 struct hlist_node *node;
2482 2481
2483 if (v == SEQ_START_TOKEN) { 2482 if (v == SEQ_START_TOKEN) {
2484 seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway " 2483 seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway "
@@ -2493,8 +2492,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2493 if (IS_TNODE(l)) 2492 if (IS_TNODE(l))
2494 return 0; 2493 return 0;
2495 2494
2496 for (i = 32; i >= 0; i--) { 2495 hlist_for_each_entry_rcu(li, node, &l->list, hlist) {
2497 struct leaf_info *li = find_leaf_info(l, i);
2498 struct fib_alias *fa; 2496 struct fib_alias *fa;
2499 __be32 mask, prefix; 2497 __be32 mask, prefix;
2500 2498
@@ -2507,6 +2505,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
2507 list_for_each_entry_rcu(fa, &li->falh, fa_list) { 2505 list_for_each_entry_rcu(fa, &li->falh, fa_list) {
2508 const struct fib_info *fi = fa->fa_info; 2506 const struct fib_info *fi = fa->fa_info;
2509 unsigned flags = fib_flag_trans(fa->fa_type, mask, fi); 2507 unsigned flags = fib_flag_trans(fa->fa_type, mask, fi);
2508 char bf[128];
2510 2509
2511 if (fa->fa_type == RTN_BROADCAST 2510 if (fa->fa_type == RTN_BROADCAST
2512 || fa->fa_type == RTN_MULTICAST) 2511 || fa->fa_type == RTN_MULTICAST)