netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [TCP] Show all SYN_RECV sockets in /proc/net/tcp
@ 2004-10-06  2:06 Herbert Xu
  2004-10-06  2:17 ` Arnaldo Carvalho de Melo
  2004-10-06  5:18 ` David S. Miller
  0 siblings, 2 replies; 7+ messages in thread
From: Herbert Xu @ 2004-10-06  2:06 UTC (permalink / raw)
  To: David S. Miller, netdev

[-- Attachment #1: Type: text/plain, Size: 526 bytes --]

Hi Dave:

I was fixing the tcp_diag so that it shows SYN_RECV sockets properly.
I found that /proc/net/tcp didn't do it correctly either.  So here is
a small patch to fix /proc/net/tcp.

The logic in there stinks though so I'd love to see a rewrite.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

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

[-- Attachment #2: p --]
[-- Type: text/plain, Size: 835 bytes --]

===== net/ipv4/tcp_ipv4.c 1.99 vs edited =====
--- 1.99/net/ipv4/tcp_ipv4.c	2004-09-15 06:57:07 +10:00
+++ edited/net/ipv4/tcp_ipv4.c	2004-10-06 11:25:04 +10:00
@@ -2175,8 +2175,14 @@
 		sk	  = sk_next(st->syn_wait_sk);
 		st->state = TCP_SEQ_STATE_LISTENING;
 		read_unlock_bh(&tp->syn_wait_lock);
-	} else
+	} else {
+	       	tp = tcp_sk(sk);
+		read_lock_bh(&tp->syn_wait_lock);
+		if (tp->listen_opt && tp->listen_opt->qlen)
+			goto start_req;
+		read_unlock_bh(&tp->syn_wait_lock);
 		sk = sk_next(sk);
+	}
 get_sk:
 	sk_for_each_from(sk, node) {
 		if (sk->sk_family == st->family) {
@@ -2186,6 +2192,7 @@
 	       	tp = tcp_sk(sk);
 		read_lock_bh(&tp->syn_wait_lock);
 		if (tp->listen_opt && tp->listen_opt->qlen) {
+start_req:
 			st->uid		= sock_i_uid(sk);
 			st->syn_wait_sk = sk;
 			st->state	= TCP_SEQ_STATE_OPENREQ;

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

* Re: [TCP] Show all SYN_RECV sockets in /proc/net/tcp
  2004-10-06  2:06 [TCP] Show all SYN_RECV sockets in /proc/net/tcp Herbert Xu
@ 2004-10-06  2:17 ` Arnaldo Carvalho de Melo
  2004-10-06  2:35   ` Herbert Xu
  2004-10-06  2:55   ` YOSHIFUJI Hideaki / 吉藤英明
  2004-10-06  5:18 ` David S. Miller
  1 sibling, 2 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2004-10-06  2:17 UTC (permalink / raw)
  To: Herbert Xu; +Cc: David S. Miller, netdev



Herbert Xu wrote:
> Hi Dave:
> 
> I was fixing the tcp_diag so that it shows SYN_RECV sockets properly.
> I found that /proc/net/tcp didn't do it correctly either.  So here is
> a small patch to fix /proc/net/tcp.
> 
> The logic in there stinks though so I'd love to see a rewrite.

Go ahead and do it with the current seq_file infrastructure 8) Standard
answer for these cases is remove /proc/net/tcp altogether and convert
the userland tools to use netlink instead.

- Arnaldo

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

* Re: [TCP] Show all SYN_RECV sockets in /proc/net/tcp
  2004-10-06  2:17 ` Arnaldo Carvalho de Melo
@ 2004-10-06  2:35   ` Herbert Xu
  2004-10-06  2:43     ` Arnaldo Carvalho de Melo
  2004-10-06  3:58     ` Randy.Dunlap
  2004-10-06  2:55   ` YOSHIFUJI Hideaki / 吉藤英明
  1 sibling, 2 replies; 7+ messages in thread
From: Herbert Xu @ 2004-10-06  2:35 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo; +Cc: herbert, davem, netdev

Arnaldo Carvalho de Melo <acme@conectiva.com.br> wrote:
> 
> Go ahead and do it with the current seq_file infrastructure 8) Standard

Does the current seq_file infrastructure offer anything new compared
to what's in the existing /proc/net/tcp code?

> answer for these cases is remove /proc/net/tcp altogether and convert
> the userland tools to use netlink instead.

Completely agreed.  As I said I only started looking at this because
I was trying to fix tcp_diag.

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] 7+ messages in thread

* Re: [TCP] Show all SYN_RECV sockets in /proc/net/tcp
  2004-10-06  2:35   ` Herbert Xu
@ 2004-10-06  2:43     ` Arnaldo Carvalho de Melo
  2004-10-06  3:58     ` Randy.Dunlap
  1 sibling, 0 replies; 7+ messages in thread
From: Arnaldo Carvalho de Melo @ 2004-10-06  2:43 UTC (permalink / raw)
  To: Herbert Xu; +Cc: davem, netdev



Herbert Xu wrote:
> Arnaldo Carvalho de Melo <acme@conectiva.com.br> wrote:
> 
>>Go ahead and do it with the current seq_file infrastructure 8) Standard
> 
> 
> Does the current seq_file infrastructure offer anything new compared
> to what's in the existing /proc/net/tcp code?

Haven't checked, it has been a long time already since I wrote that
spaguetti code to fit the seq_file infrastructure :)

>>answer for these cases is remove /proc/net/tcp altogether and convert
>>the userland tools to use netlink instead. 
> 
> Completely agreed.  As I said I only started looking at this because
> I was trying to fix tcp_diag.

I see, and thank you for getting so involved in linux networking
development, you're doing a wonderful work :-)

- Arnaldo

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

* Re: [TCP] Show all SYN_RECV sockets in /proc/net/tcp
  2004-10-06  2:17 ` Arnaldo Carvalho de Melo
  2004-10-06  2:35   ` Herbert Xu
@ 2004-10-06  2:55   ` YOSHIFUJI Hideaki / 吉藤英明
  1 sibling, 0 replies; 7+ messages in thread
From: YOSHIFUJI Hideaki / 吉藤英明 @ 2004-10-06  2:55 UTC (permalink / raw)
  To: acme; +Cc: herbert, davem, netdev, yoshfuji

In article <416355BD.50402@conectiva.com.br> (at Tue, 05 Oct 2004 23:17:33 -0300), Arnaldo Carvalho de Melo <acme@conectiva.com.br> says:

> > I found that /proc/net/tcp didn't do it correctly either.  So here is
> > a small patch to fix /proc/net/tcp.
> > 
> > The logic in there stinks though so I'd love to see a rewrite.
> 
> Go ahead and do it with the current seq_file infrastructure 8) Standard
> answer for these cases is remove /proc/net/tcp altogether and convert
> the userland tools to use netlink instead.

It is okay to have dual interface (procfs and netlink), but
please, please do not remove /proc/net/tcp (during 2.6.x at least).
And, yes, if you want to add something, it should be done in netlink.

Thanks.

--yoshfuji

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

* Re: [TCP] Show all SYN_RECV sockets in /proc/net/tcp
  2004-10-06  2:35   ` Herbert Xu
  2004-10-06  2:43     ` Arnaldo Carvalho de Melo
@ 2004-10-06  3:58     ` Randy.Dunlap
  1 sibling, 0 replies; 7+ messages in thread
From: Randy.Dunlap @ 2004-10-06  3:58 UTC (permalink / raw)
  To: Herbert Xu; +Cc: acme, herbert, davem, netdev

On Wed, 06 Oct 2004 12:35:58 +1000 Herbert Xu wrote:

| Arnaldo Carvalho de Melo <acme@conectiva.com.br> wrote:
| > 
| > Go ahead and do it with the current seq_file infrastructure 8) Standard
| 
| Does the current seq_file infrastructure offer anything new compared
| to what's in the existing /proc/net/tcp code?
| 
| > answer for these cases is remove /proc/net/tcp altogether and convert
| > the userland tools to use netlink instead.
| 
| Completely agreed.  As I said I only started looking at this because
| I was trying to fix tcp_diag.

Dave's other standard answer is "don't mess up the userland API",
including /proc interfaces.  (not to put words into Dave's mouth)

--
~Randy

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

* Re: [TCP] Show all SYN_RECV sockets in /proc/net/tcp
  2004-10-06  2:06 [TCP] Show all SYN_RECV sockets in /proc/net/tcp Herbert Xu
  2004-10-06  2:17 ` Arnaldo Carvalho de Melo
@ 2004-10-06  5:18 ` David S. Miller
  1 sibling, 0 replies; 7+ messages in thread
From: David S. Miller @ 2004-10-06  5:18 UTC (permalink / raw)
  To: Herbert Xu; +Cc: netdev

On Wed, 6 Oct 2004 12:06:50 +1000
Herbert Xu <herbert@gondor.apana.org.au> wrote:

> I was fixing the tcp_diag so that it shows SYN_RECV sockets properly.
> I found that /proc/net/tcp didn't do it correctly either.  So here is
> a small patch to fix /proc/net/tcp.
> 
> The logic in there stinks though so I'd love to see a rewrite.
> 
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Patch applied, thanks.  And yes I agree this stuff could
be improved dramatically.

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

end of thread, other threads:[~2004-10-06  5:18 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-06  2:06 [TCP] Show all SYN_RECV sockets in /proc/net/tcp Herbert Xu
2004-10-06  2:17 ` Arnaldo Carvalho de Melo
2004-10-06  2:35   ` Herbert Xu
2004-10-06  2:43     ` Arnaldo Carvalho de Melo
2004-10-06  3:58     ` Randy.Dunlap
2004-10-06  2:55   ` YOSHIFUJI Hideaki / 吉藤英明
2004-10-06  5:18 ` David S. Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).