Subject: Re: [PATCH] include listenq max backlog in /proc/net/tcp and include in tcp_info

From: Rick Jones <[email-masked]>
Date: Tue, 11 Sep 2007 10:00:21 -0700

Eric Dumazet wrote:
> Sridhar Samudrala a écrit :
> 
>> On Mon, 2007-09-10 at 16:13 -0700, Rick Jones wrote:
>>
>>> Return some useful information such as the maximum listen backlog and
>>> the current listen backlog in the tcp_info structure and have that 
>>> match what one can see in /proc/net/tcp and /proc/net/tcp6.
>>
>>
>> If we are also exporting max listen backlog, another place to
>> consider adding this is to tcp_diag_get_info() called via INET_DIAG_INFO.
>> Current listen backlog is returned in inet_diag_msg->idiag_rqueue.
>> max listen backlog can be returned in inet_diag_msg->idiag_wqueue.
>>
> 
> I agree, /proc/net/tcp is deprecated nowadays...

What takes its place?

> Rick, could you add this part in your patch, and add my Sign-off-by ?

My pleasure.

I have a small test program for the tcp_info bit - where do I go to find 
how the inet diag stuff works?

BTW, what do people think about doing the same thing with the rxqueue 
and txqueue's of netstat output?

rick jones

> 
> Thank you
> Eric
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> diff --git a/net/ipv4/tcp_diag.c b/net/ipv4/tcp_diag.c
> index 57c5f0b..f5b6275 100644
> --- a/net/ipv4/tcp_diag.c
> +++ b/net/ipv4/tcp_diag.c
> @@ -25,11 +25,13 @@ static void tcp_diag_get_info(struct sock *sk, struct inet_diag_msg *r,
>  	const struct tcp_sock *tp = tcp_sk(sk);
>  	struct tcp_info *info = _info;
>  
> -	if (sk->sk_state == TCP_LISTEN)
> +	if (sk->sk_state == TCP_LISTEN) {
>  		r->idiag_rqueue = sk->sk_ack_backlog;
> -	else
> +		r->idiag_wqueue = sk->sk_max_ack_backlog;
> +	else {
>  		r->idiag_rqueue = tp->rcv_nxt - tp->copied_seq;
> -	r->idiag_wqueue = tp->write_seq - tp->snd_una;
> +		r->idiag_wqueue = tp->write_seq - tp->snd_una;
> +	}
>  	if (info != NULL)
>  		tcp_get_info(sk, info);
>  }