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/udp.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/udp.c')
-rw-r--r-- | net/ipv4/udp.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c index b053ac79527..1f535e31518 100644 --- a/net/ipv4/udp.c +++ b/net/ipv4/udp.c | |||
@@ -1619,7 +1619,8 @@ void udp_proc_unregister(struct net *net, struct udp_seq_afinfo *afinfo) | |||
1619 | } | 1619 | } |
1620 | 1620 | ||
1621 | /* ------------------------------------------------------------------------ */ | 1621 | /* ------------------------------------------------------------------------ */ |
1622 | static void udp4_format_sock(struct sock *sp, char *tmpbuf, int bucket) | 1622 | static void udp4_format_sock(struct sock *sp, struct seq_file *f, |
1623 | int bucket, int *len) | ||
1623 | { | 1624 | { |
1624 | struct inet_sock *inet = inet_sk(sp); | 1625 | struct inet_sock *inet = inet_sk(sp); |
1625 | __be32 dest = inet->daddr; | 1626 | __be32 dest = inet->daddr; |
@@ -1627,13 +1628,13 @@ static void udp4_format_sock(struct sock *sp, char *tmpbuf, int bucket) | |||
1627 | __u16 destp = ntohs(inet->dport); | 1628 | __u16 destp = ntohs(inet->dport); |
1628 | __u16 srcp = ntohs(inet->sport); | 1629 | __u16 srcp = ntohs(inet->sport); |
1629 | 1630 | ||
1630 | sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X" | 1631 | seq_printf(f, "%4d: %08X:%04X %08X:%04X" |
1631 | " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p", | 1632 | " %02X %08X:%08X %02X:%08lX %08X %5d %8d %lu %d %p%n", |
1632 | bucket, src, srcp, dest, destp, sp->sk_state, | 1633 | bucket, src, srcp, dest, destp, sp->sk_state, |
1633 | atomic_read(&sp->sk_wmem_alloc), | 1634 | atomic_read(&sp->sk_wmem_alloc), |
1634 | atomic_read(&sp->sk_rmem_alloc), | 1635 | atomic_read(&sp->sk_rmem_alloc), |
1635 | 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp), | 1636 | 0, 0L, 0, sock_i_uid(sp), 0, sock_i_ino(sp), |
1636 | atomic_read(&sp->sk_refcnt), sp); | 1637 | atomic_read(&sp->sk_refcnt), sp, len); |
1637 | } | 1638 | } |
1638 | 1639 | ||
1639 | int udp4_seq_show(struct seq_file *seq, void *v) | 1640 | int udp4_seq_show(struct seq_file *seq, void *v) |
@@ -1644,11 +1645,11 @@ int udp4_seq_show(struct seq_file *seq, void *v) | |||
1644 | "rx_queue tr tm->when retrnsmt uid timeout " | 1645 | "rx_queue tr tm->when retrnsmt uid timeout " |
1645 | "inode"); | 1646 | "inode"); |
1646 | else { | 1647 | else { |
1647 | char tmpbuf[129]; | ||
1648 | struct udp_iter_state *state = seq->private; | 1648 | struct udp_iter_state *state = seq->private; |
1649 | int len; | ||
1649 | 1650 | ||
1650 | udp4_format_sock(v, tmpbuf, state->bucket); | 1651 | udp4_format_sock(v, seq, state->bucket, &len); |
1651 | seq_printf(seq, "%-127s\n", tmpbuf); | 1652 | seq_printf(seq, "%*s\n", 127 - len ,""); |
1652 | } | 1653 | } |
1653 | return 0; | 1654 | return 0; |
1654 | } | 1655 | } |