Netdev List
 help / color / mirror / Atom feed
* [PATCH] Export accept queue len of a TCP listening socket via /proc/net/tcp{6}
@ 2006-06-21 23:56 Sridhar Samudrala
  2006-06-22  0:21 ` Herbert Xu
  0 siblings, 1 reply; 6+ messages in thread
From: Sridhar Samudrala @ 2006-06-21 23:56 UTC (permalink / raw)
  To: davem; +Cc: netdev

While debugging a TCP server hang issue, we noticed that currently there is 
no way for a user to find the acceptq backlog value for a TCP listen socket.

All the standard networking utilities that display socket info like netstat,
ss and /proc/net/tcp have 2 fields called rx_queue and tx_queue. I think these
fields do not mean much for listening sockets and they are always zero. So why
not use one of these fields(rx_queue) to export the accept queue len for listening
sockets?
The attached patch implements this, but it only works with /proc/net/tcp and
/proc/net/tcp6.

In order to support this with netstat/ss that use netlink mechanism to
get the socket info, i think we need to extend tcp_info to add this field.
Can this be done in a backward compatible way?

Anyway, i think it is useful to have this value exported via /proc.

Thanks
Sridhar


Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>

diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 25ecc6e..4c6ef47 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1726,7 +1726,8 @@ static void get_tcp4_sock(struct sock *s
 	sprintf(tmpbuf, "%4d: %08X:%04X %08X:%04X %02X %08X:%08X %02X:%08lX "
 			"%08X %5d %8d %lu %d %p %u %u %u %u %d",
 		i, src, srcp, dest, destp, sp->sk_state,
-		tp->write_seq - tp->snd_una, tp->rcv_nxt - tp->copied_seq,
+		tp->write_seq - tp->snd_una,
+		(sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq),
 		timer_active,
 		jiffies_to_clock_t(timer_expires - jiffies),
 		icsk->icsk_retransmits,
diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
index a50eb30..b36d5b2 100644
--- a/net/ipv6/tcp_ipv6.c
+++ b/net/ipv6/tcp_ipv6.c
@@ -1469,7 +1469,8 @@ static void get_tcp6_sock(struct seq_fil
 		   dest->s6_addr32[0], dest->s6_addr32[1],
 		   dest->s6_addr32[2], dest->s6_addr32[3], destp,
 		   sp->sk_state, 
-		   tp->write_seq-tp->snd_una, tp->rcv_nxt-tp->copied_seq,
+		   tp->write_seq-tp->snd_una,
+		   (sp->sk_state == TCP_LISTEN) ? sp->sk_ack_backlog : (tp->rcv_nxt - tp->copied_seq),
 		   timer_active,
 		   jiffies_to_clock_t(timer_expires - jiffies),
 		   icsk->icsk_retransmits,



^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-06-27 20:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-06-21 23:56 [PATCH] Export accept queue len of a TCP listening socket via /proc/net/tcp{6} Sridhar Samudrala
2006-06-22  0:21 ` Herbert Xu
2006-06-22  0:35   ` Sridhar Samudrala
2006-06-22  0:50     ` Herbert Xu
2006-06-22 17:38       ` [PATCH] Export accept queue len of a TCP listening socket via rx_queue Sridhar Samudrala
2006-06-27 20:29         ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox