aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/fib_hash.c
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-04-24 04:02:16 -0400
committerDavid S. Miller <davem@davemloft.net>2008-04-24 04:02:16 -0400
commit5e659e4cb0eedacdc1f621a61e400a4611ddef8a (patch)
treefa3c8743010dd640c48584a6fa8a910d27350c01 /net/ipv4/fib_hash.c
parent3d36696024499aef19dbf24a781e91a24fbbe4af (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_hash.c')
-rw-r--r--net/ipv4/fib_hash.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/net/ipv4/fib_hash.c b/net/ipv4/fib_hash.c
index 02088deb0461..2e2fc3376ac9 100644
--- a/net/ipv4/fib_hash.c
+++ b/net/ipv4/fib_hash.c
@@ -1003,7 +1003,7 @@ static unsigned fib_flag_trans(int type, __be32 mask, struct fib_info *fi)
1003static int fib_seq_show(struct seq_file *seq, void *v) 1003static int fib_seq_show(struct seq_file *seq, void *v)
1004{ 1004{
1005 struct fib_iter_state *iter; 1005 struct fib_iter_state *iter;
1006 char bf[128]; 1006 int len;
1007 __be32 prefix, mask; 1007 __be32 prefix, mask;
1008 unsigned flags; 1008 unsigned flags;
1009 struct fib_node *f; 1009 struct fib_node *f;
@@ -1025,18 +1025,19 @@ static int fib_seq_show(struct seq_file *seq, void *v)
1025 mask = FZ_MASK(iter->zone); 1025 mask = FZ_MASK(iter->zone);
1026 flags = fib_flag_trans(fa->fa_type, mask, fi); 1026 flags = fib_flag_trans(fa->fa_type, mask, fi);
1027 if (fi) 1027 if (fi)
1028 snprintf(bf, sizeof(bf), 1028 seq_printf(seq,
1029 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", 1029 "%s\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
1030 fi->fib_dev ? fi->fib_dev->name : "*", prefix, 1030 fi->fib_dev ? fi->fib_dev->name : "*", prefix,
1031 fi->fib_nh->nh_gw, flags, 0, 0, fi->fib_priority, 1031 fi->fib_nh->nh_gw, flags, 0, 0, fi->fib_priority,
1032 mask, (fi->fib_advmss ? fi->fib_advmss + 40 : 0), 1032 mask, (fi->fib_advmss ? fi->fib_advmss + 40 : 0),
1033 fi->fib_window, 1033 fi->fib_window,
1034 fi->fib_rtt >> 3); 1034 fi->fib_rtt >> 3, &len);
1035 else 1035 else
1036 snprintf(bf, sizeof(bf), 1036 seq_printf(seq,
1037 "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u", 1037 "*\t%08X\t%08X\t%04X\t%d\t%u\t%d\t%08X\t%d\t%u\t%u%n",
1038 prefix, 0, flags, 0, 0, 0, mask, 0, 0, 0); 1038 prefix, 0, flags, 0, 0, 0, mask, 0, 0, 0, &len);
1039 seq_printf(seq, "%-127s\n", bf); 1039
1040 seq_printf(seq, "%*s\n", 127 - len, "");
1040out: 1041out:
1041 return 0; 1042 return 0;
1042} 1043}