diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-04-24 04:02:16 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-04-24 04:02:16 -0400 |
commit | 5e659e4cb0eedacdc1f621a61e400a4611ddef8a (patch) | |
tree | fa3c8743010dd640c48584a6fa8a910d27350c01 /net/ipv4/fib_trie.c | |
parent | 3d36696024499aef19dbf24a781e91a24fbbe4af (diff) |
[NET]: Fix heavy stack usage in seq_file output routines.
Plan C: we can follow the Al Viro's proposal about %n like in this patch.
The same applies to udp, fib (the /proc/net/route file), rt_cache and
sctp debug. This is minus ~150-200 bytes for each.
Signed-off-by: Pavel Emelyanov <xemul@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 | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/net/ipv4/fib_trie.c b/net/ipv4/fib_trie.c index ea294fffb9ce..4b02d14e7ab9 100644 --- a/net/ipv4/fib_trie.c +++ b/net/ipv4/fib_trie.c | |||
@@ -2602,15 +2602,16 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) | |||
2602 | list_for_each_entry_rcu(fa, &li->falh, fa_list) { | 2602 | list_for_each_entry_rcu(fa, &li->falh, fa_list) { |
2603 | const struct fib_info *fi = fa->fa_info; | 2603 | const struct fib_info *fi = fa->fa_info; |
2604 | unsigned flags = fib_flag_trans(fa->fa_type, mask, fi); | 2604 | unsigned flags = fib_flag_trans(fa->fa_type, mask, fi); |
2605 | char bf[128]; | 2605 | int len; |
2606 | 2606 | ||
2607 | if (fa->fa_type == RTN_BROADCAST | 2607 | if (fa->fa_type == RTN_BROADCAST |
2608 | || fa->fa_type == RTN_MULTICAST) | 2608 | || fa->fa_type == RTN_MULTICAST) |
2609 | continue; | 2609 | continue; |
2610 | 2610 | ||
2611 | if (fi) | 2611 | if (fi) |
2612 | snprintf(bf, sizeof(bf), | 2612 | seq_printf(seq, |
2613 | "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", | 2613 | "%s\t%08X\t%08X\t%04X\t%d\t%u\t" |
2614 | "%d\t%08X\t%d\t%u\t%u%n", | ||
2614 | fi->fib_dev ? fi->fib_dev->name : "*", | 2615 | fi->fib_dev ? fi->fib_dev->name : "*", |
2615 | prefix, | 2616 | prefix, |
2616 | fi->fib_nh->nh_gw, flags, 0, 0, | 2617 | fi->fib_nh->nh_gw, flags, 0, 0, |
@@ -2619,14 +2620,15 @@ static int fib_route_seq_show(struct seq_file *seq, void *v) | |||
2619 | (fi->fib_advmss ? | 2620 | (fi->fib_advmss ? |
2620 | fi->fib_advmss + 40 : 0), | 2621 | fi->fib_advmss + 40 : 0), |
2621 | fi->fib_window, | 2622 | fi->fib_window, |
2622 | fi->fib_rtt >> 3); | 2623 | fi->fib_rtt >> 3, &len); |
2623 | else | 2624 | else |
2624 | snprintf(bf, sizeof(bf), | 2625 | seq_printf(seq, |
2625 | "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", | 2626 | "*\t%08X\t%08X\t%04X\t%d\t%u\t" |
2627 | "%d\t%08X\t%d\t%u\t%u%n", | ||
2626 | prefix, 0, flags, 0, 0, 0, | 2628 | prefix, 0, flags, 0, 0, 0, |
2627 | mask, 0, 0, 0); | 2629 | mask, 0, 0, 0, &len); |
2628 | 2630 | ||
2629 | seq_printf(seq, "%-127s\n", bf); | 2631 | seq_printf(seq, "%*s\n", 127 - len, ""); |
2630 | } | 2632 | } |
2631 | } | 2633 | } |
2632 | 2634 | ||