2006-01-16 20:05:53

by Andy Gospodarek

[permalink] [raw]
Subject: [patch] networking ipv4: remove total socket usage count from /proc/net/sockstat

Printing the total number of sockets used in /proc/net/sockstat is out
of place in a file that is supposed to contain information related to
ipv4 sockets. Removed output for total socket usage.

Signed-off-by: Andy Gospodarek <[email protected]>
---

proc.c | 1 -
1 files changed, 1 deletion(-)


diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -60,7 +60,6 @@ static int fold_prot_inuse(struct proto
*/
static int sockstat_seq_show(struct seq_file *seq, void *v)
{
- socket_seq_show(seq);
seq_printf(seq, "TCP: inuse %d orphan %d tw %d alloc %d mem %d\n",
fold_prot_inuse(&tcp_prot), atomic_read(&tcp_orphan_count),
tcp_death_row.tw_count, atomic_read(&tcp_sockets_allocated),


2006-01-16 20:14:11

by Lee Revell

[permalink] [raw]
Subject: Re: [patch] networking ipv4: remove total socket usage count from /proc/net/sockstat

On Mon, 2006-01-16 at 15:04 -0500, Andy Gospodarek wrote:
> Printing the total number of sockets used in /proc/net/sockstat is out
> of place in a file that is supposed to contain information related to
> ipv4 sockets. Removed output for total socket usage.
>

Um, you can't do that, it will break userspace.

Lee

2006-01-16 20:25:32

by Andy Gospodarek

[permalink] [raw]
Subject: Re: [patch] networking ipv4: remove total socket usage count from /proc/net/sockstat

What userspace app will break because of this?

On 1/16/06, Lee Revell <[email protected]> wrote:
> On Mon, 2006-01-16 at 15:04 -0500, Andy Gospodarek wrote:
> > Printing the total number of sockets used in /proc/net/sockstat is out
> > of place in a file that is supposed to contain information related to
> > ipv4 sockets. Removed output for total socket usage.
> >
>
> Um, you can't do that, it will break userspace.
>
> Lee
>
>

2006-01-16 20:35:32

by Jesper Juhl

[permalink] [raw]
Subject: Re: [patch] networking ipv4: remove total socket usage count from /proc/net/sockstat

On 1/16/06, Andy Gospodarek <[email protected]> wrote:
> What userspace app will break because of this?
>
> On 1/16/06, Lee Revell <[email protected]> wrote:
> > On Mon, 2006-01-16 at 15:04 -0500, Andy Gospodarek wrote:
> > > Printing the total number of sockets used in /proc/net/sockstat is out
> > > of place in a file that is supposed to contain information related to
> > > ipv4 sockets. Removed output for total socket usage.
> > >
> >
> > Um, you can't do that, it will break userspace.
> >

That's not the point. The point is you can't go around changing things
exported to usersace - that has the potential to break apps. Even if
no app is known to the people on this list there may still be apps out
there depending on it - and we don't break userspace without *very*
good reasons, and even then it's announced for several months (years
sometimes) in Documentation/feature-removal.txt and elsewhere.

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

2006-01-16 20:55:27

by Andy Gospodarek

[permalink] [raw]
Subject: Re: [patch] networking ipv4: remove total socket usage count from /proc/net/sockstat

Jesper,

Thanks for the explanation. Your reasoning makes sense. I will
consider other ways to solve my current problem and post a patch that
doesn't "break userspace" if necessary.

-andy



On 1/16/06, Jesper Juhl <[email protected]> wrote:
> On 1/16/06, Andy Gospodarek <[email protected]> wrote:
> > What userspace app will break because of this?
> >
> > On 1/16/06, Lee Revell <[email protected]> wrote:
> > > On Mon, 2006-01-16 at 15:04 -0500, Andy Gospodarek wrote:
> > > > Printing the total number of sockets used in /proc/net/sockstat is out
> > > > of place in a file that is supposed to contain information related to
> > > > ipv4 sockets. Removed output for total socket usage.
> > > >
> > >
> > > Um, you can't do that, it will break userspace.
> > >
>
> That's not the point. The point is you can't go around changing things
> exported to usersace - that has the potential to break apps. Even if
> no app is known to the people on this list there may still be apps out
> there depending on it - and we don't break userspace without *very*
> good reasons, and even then it's announced for several months (years
> sometimes) in Documentation/feature-removal.txt and elsewhere.
>
> --
> Jesper Juhl <[email protected]>
> Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
> Plain text mails only, please http://www.expita.com/nomime.html
>

2006-01-16 21:08:34

by Jesper Juhl

[permalink] [raw]
Subject: Re: [patch] networking ipv4: remove total socket usage count from /proc/net/sockstat

On 1/16/06, Andy Gospodarek <[email protected]> wrote:

[could you *please* not top post? It's pretty annoying]

> Jesper,
>
> Thanks for the explanation. Your reasoning makes sense. I will

I'm glad you found it useful.

> consider other ways to solve my current problem and post a patch that
> doesn't "break userspace" if necessary.
>
Maybe if you described "your current problem" someone could suggest a
solution...

--
Jesper Juhl <[email protected]>
Don't top-post http://www.catb.org/~esr/jargon/html/T/top-post.html
Plain text mails only, please http://www.expita.com/nomime.html

2006-01-16 22:34:03

by Andy Gospodarek

[permalink] [raw]
Subject: Re: [patch] networking ipv4: remove total socket usage count from /proc/net/sockstat

On 1/16/06, Jesper Juhl <[email protected]> wrote:
> >
> Maybe if you described "your current problem" someone could suggest a
> solution...
>

Sure, I'd be glad to. If I add up all the entries from the procfiles
(in /proc/net) on my system

packet = 1
netlink = 6
raw = 0
raw6 = 0
tcp = 5
tcp6 = 3
udp = 9
udp6 = 1
unix = 29

I find there are a total of 54 sockets open on my system.

Now this seems to differ from the value in /proc/net/sockstat:
# cat sockstat
sockets: used 59
TCP: inuse 5 orphan 0 tw 0 alloc 8 mem 1
UDP: inuse 9
RAW: inuse 0
FRAG: inuse 0 memory 0

So we are off by 5. I added some code around the stat collection used
in sockstat to get more detailed info about those sockets and the
output is here. The values are family[protocol family][socket
family].

family[1][1] = 17 (UNIX/LOCAL,STREAM)
family[1][2] = 12 (UNIX/LOCAL,DGRAM)
family[2][1] = 5 (INET,STREAM)
family[2][2] = 9 (INET,DGRAM)
family[2][3] = 2 (INET,RAW)
family[10][1] = 3 (INET6,STREAM)
family[10][2] = 1 (INET6,DGRAM)
family[10][3] = 3 (INET6,RAW)
family[16][2] = 6 (NETLINK/ROUTE,DGRAM)
family[17][10] = 1 (PACKET,PACKET)
Total = 59

All of these numbers match up with what we saw above, except the
INET/RAW and INET6/RAW sockets. It seems they aren't being counted
correctly -- which accounts for the 5 missing sockets. The
decrementing of these values is in sock_release() and seems to get
done correctly other times RAW sockets are created, but not for the 5
sockets in question.

Since the total socket usage seems out of place in that file -- and
quite possibly wrong, it seemed like a nice idea to get rid of it
(prior to understanding the reasoning behind keeping it). Now it
seems the goal will be to fix the discrepancy between these files.

-andy

2006-01-17 01:18:09

by YOSHIFUJI Hideaki

[permalink] [raw]
Subject: Re: [patch] networking ipv4: remove total socket usage count from /proc/net/sockstat

In article <[email protected]> (at Mon, 16 Jan 2006 17:33:59 -0500), Andy Gospodarek <[email protected]> says:

> On 1/16/06, Jesper Juhl <[email protected]> wrote:
> > >
> > Maybe if you described "your current problem" someone could suggest a
> > solution...
> >
>
> Sure, I'd be glad to. If I add up all the entries from the procfiles
> (in /proc/net) on my system
:
> I find there are a total of 54 sockets open on my system.
>
> Now this seems to differ from the value in /proc/net/sockstat:
> # cat sockstat
> sockets: used 59
:
> So we are off by 5. I added some code around the stat collection used
> in sockstat to get more detailed info about those sockets and the
> output is here. The values are family[protocol family][socket
> family].
:
> Total = 59
>
> All of these numbers match up with what we saw above, except the
> INET/RAW and INET6/RAW sockets. It seems they aren't being counted
> correctly -- which accounts for the 5 missing sockets. The
> decrementing of these values is in sock_release() and seems to get
> done correctly other times RAW sockets are created, but not for the 5
> sockets in question.

This is because we have several internal unhashed raw sockets in
kernel, which are not counted in the "raw" entry, but in "sockets."

--yoshfuji