* [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* Re: [PATCH] Export accept queue len of a TCP listening socket via /proc/net/tcp{6}
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
0 siblings, 1 reply; 6+ messages in thread
From: Herbert Xu @ 2006-06-22 0:21 UTC (permalink / raw)
To: Sridhar Samudrala; +Cc: davem, netdev
Sridhar Samudrala <sri@us.ibm.com> wrote:
>
> 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?
What about using the same fields (rqueue/wqueue) as you did for /proc?
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Export accept queue len of a TCP listening socket via /proc/net/tcp{6}
2006-06-22 0:21 ` Herbert Xu
@ 2006-06-22 0:35 ` Sridhar Samudrala
2006-06-22 0:50 ` Herbert Xu
0 siblings, 1 reply; 6+ messages in thread
From: Sridhar Samudrala @ 2006-06-22 0:35 UTC (permalink / raw)
To: Herbert Xu; +Cc: davem, netdev
On Thu, 2006-06-22 at 10:21 +1000, Herbert Xu wrote:
> Sridhar Samudrala <sri@us.ibm.com> wrote:
> >
> > 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?
>
> What about using the same fields (rqueue/wqueue) as you did for /proc?
I meant extending tcp_info structure to add new fields. I think the user
space also uses this structure.
Thanks
Sridhar
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Export accept queue len of a TCP listening socket via /proc/net/tcp{6}
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
0 siblings, 1 reply; 6+ messages in thread
From: Herbert Xu @ 2006-06-22 0:50 UTC (permalink / raw)
To: Sridhar Samudrala; +Cc: herbert, davem, netdev
Sridhar Samudrala <sri@us.ibm.com> wrote:
>>
>> What about using the same fields (rqueue/wqueue) as you did for /proc?
>
> I meant extending tcp_info structure to add new fields. I think the user
> space also uses this structure.
What about putting it into inet_idiag_msg.idiag_[rw]queue instead?
Cheers,
--
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] Export accept queue len of a TCP listening socket via rx_queue
2006-06-22 0:50 ` Herbert Xu
@ 2006-06-22 17:38 ` Sridhar Samudrala
2006-06-27 20:29 ` David Miller
0 siblings, 1 reply; 6+ messages in thread
From: Sridhar Samudrala @ 2006-06-22 17:38 UTC (permalink / raw)
To: Herbert Xu; +Cc: davem, netdev
On Thu, 2006-06-22 at 10:50 +1000, Herbert Xu wrote:
> Sridhar Samudrala <sri@us.ibm.com> wrote:
> >>
> >> What about using the same fields (rqueue/wqueue) as you did for /proc?
> >
> > I meant extending tcp_info structure to add new fields. I think the user
> > space also uses this structure.
>
> What about putting it into inet_idiag_msg.idiag_[rw]queue instead?
OK. I was under the mistaken assumption that [rw]queue fields are exported
via tcp_info. This makes it pretty simple to support netlink users also.
Here is the updated patch.
Thanks
Sridhar
While debugging a TCP server hang issue, we noticed that currently there is
no way for a user to get 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. These
fields do not mean much for listening sockets. This patch uses one of these
unused fields(rx_queue) to export the accept queue len for listening sockets.
Signed-off-by: Sridhar Samudrala <sri@us.ibm.com>
diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
index c148c10..b56399c 100644
--- a/net/ipv4/tcp_diag.c
+++ b/net/ipv4/tcp_diag.c
@@ -26,7 +26,10 @@ static void tcp_diag_get_info(struct soc
const struct tcp_sock *tp = tcp_sk(sk);
struct tcp_info *info = _info;
- r->idiag_rqueue = tp->rcv_nxt - tp->copied_seq;
+ if (sk->sk_state == TCP_LISTEN)
+ r->idiag_rqueue = sk->sk_ack_backlog;
+ else
+ r->idiag_rqueue = tp->rcv_nxt - tp->copied_seq;
r->idiag_wqueue = tp->write_seq - tp->snd_una;
if (info != NULL)
tcp_get_info(sk, info);
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
* Re: [PATCH] Export accept queue len of a TCP listening socket via rx_queue
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
0 siblings, 0 replies; 6+ messages in thread
From: David Miller @ 2006-06-27 20:29 UTC (permalink / raw)
To: sri; +Cc: herbert, netdev
From: Sridhar Samudrala <sri@us.ibm.com>
Date: Thu, 22 Jun 2006 10:38:17 -0700
> On Thu, 2006-06-22 at 10:50 +1000, Herbert Xu wrote:
> > Sridhar Samudrala <sri@us.ibm.com> wrote:
> > >>
> > >> What about using the same fields (rqueue/wqueue) as you did for /proc?
> > >
> > > I meant extending tcp_info structure to add new fields. I think the user
> > > space also uses this structure.
> >
> > What about putting it into inet_idiag_msg.idiag_[rw]queue instead?
>
> OK. I was under the mistaken assumption that [rw]queue fields are exported
> via tcp_info. This makes it pretty simple to support netlink users also.
> Here is the updated patch.
This looks fine. Applied, thanks a lot Sridhar.
^ permalink raw reply [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