You need to sign in or sign up before continuing.
提交 1328042e 编写于 作者: S Stephen Hemminger 提交者: David S. Miller

[IPV4] fib_trie: use hash list

The code to dump can use the existing hash chain rather than doing
repeated lookup.
Signed-off-by: NStephen Hemminger <stephen.hemminger@vyatta.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 93672292
...@@ -2399,22 +2399,22 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v) ...@@ -2399,22 +2399,22 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
} else { } else {
struct leaf *l = (struct leaf *) n; struct leaf *l = (struct leaf *) n;
int i; struct leaf_info *li;
struct hlist_node *node;
__be32 val = htonl(l->key); __be32 val = htonl(l->key);
seq_indent(seq, iter->depth); seq_indent(seq, iter->depth);
seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val)); seq_printf(seq, " |-- %d.%d.%d.%d\n", NIPQUAD(val));
for (i = 32; i >= 0; i--) {
struct leaf_info *li = find_leaf_info(l, i);
if (li) { hlist_for_each_entry_rcu(li, node, &l->list, hlist) {
struct fib_alias *fa; struct fib_alias *fa;
list_for_each_entry_rcu(fa, &li->falh, fa_list) { list_for_each_entry_rcu(fa, &li->falh, fa_list) {
char buf1[32], buf2[32]; char buf1[32], buf2[32];
seq_indent(seq, iter->depth+1); seq_indent(seq, iter->depth+1);
seq_printf(seq, " /%d %s %s", i, seq_printf(seq, " /%d %s %s", li->plen,
rtn_scope(buf1, sizeof(buf1), rtn_scope(buf1, sizeof(buf1),
fa->fa_scope), fa->fa_scope),
rtn_type(buf2, sizeof(buf2), rtn_type(buf2, sizeof(buf2),
...@@ -2426,7 +2426,6 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v) ...@@ -2426,7 +2426,6 @@ static int fib_trie_seq_show(struct seq_file *seq, void *v)
} }
} }
} }
}
return 0; return 0;
} }
...@@ -2477,8 +2476,8 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) ...@@ -2477,8 +2476,8 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
{ {
const struct fib_trie_iter *iter = seq->private; const struct fib_trie_iter *iter = seq->private;
struct leaf *l = v; struct leaf *l = v;
int i; struct leaf_info *li;
char bf[128]; struct hlist_node *node;
if (v == SEQ_START_TOKEN) { if (v == SEQ_START_TOKEN) {
seq_printf(seq, "%-127s\n", "Iface\tDestination\tGateway " 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,8 +2492,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
if (IS_TNODE(l)) if (IS_TNODE(l))
return 0; return 0;
for (i = 32; i >= 0; i--) { hlist_for_each_entry_rcu(li, node, &l->list, hlist) {
struct leaf_info *li = find_leaf_info(l, i);
struct fib_alias *fa; struct fib_alias *fa;
__be32 mask, prefix; __be32 mask, prefix;
...@@ -2507,6 +2505,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) ...@@ -2507,6 +2505,7 @@ static int fib_route_seq_show(struct seq_file *seq, void *v)
list_for_each_entry_rcu(fa, &li->falh, fa_list) { list_for_each_entry_rcu(fa, &li->falh, fa_list) {
const struct fib_info *fi = fa->fa_info; const struct fib_info *fi = fa->fa_info;
unsigned flags = fib_flag_trans(fa->fa_type, mask, fi); unsigned flags = fib_flag_trans(fa->fa_type, mask, fi);
char bf[128];
if (fa->fa_type == RTN_BROADCAST if (fa->fa_type == RTN_BROADCAST
|| fa->fa_type == RTN_MULTICAST) || fa->fa_type == RTN_MULTICAST)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册