From: Pavel Emelyanov <hidden> Date: 2012-10-25 13:16:34
In the net-next sits a patch which extends the sock-diag subsys to
show the sockets' shutdown state. I propose to teach the ss tool to
print this info when requested with -e|--extended key.
The output will look like arrows at the end of each line, like this:
ESTAB 0 0 127.0.0.1:41705 127.0.0.1:12345 ino:143321 sk:ffff88003a8cea00 -->
ESTAB 0 0 127.0.0.1:46925 127.0.0.1:12346 ino:143322 sk:ffff88003a8ce4c0 <--
ESTAB 0 0 127.0.0.1:51678 127.0.0.1:12347 ino:143323 sk:ffff88003a8cdf80 ---
ESTAB 0 0 127.0.0.1:46911 127.0.0.1:12348 ino:143324 sk:ffff88003b7f05c0 <->
for SHUT_RD, SHUT_WR, SHUT_RDWR and non-shutdown sockets respectively.
In order to do so, it's also required to implement support for the
newer sock-diag in tcp and udp netlink code. I did it before, but
broke compatibility with older kernels (those without sock-diag).
Now this is fixed (checked on 2.6.40 kernel).
Signed-off-by: Pavel Emelyanov <redacted>
From: Pavel Emelyanov <hidden> Date: 2012-10-25 13:18:33
The sock-diag is capable to diag udp sockets as well. Prepare the
ss code for this by first renaming soon-to-be-generic tcp-s names
into inet-s.
Signed-off-by: Pavel Emelyanov <redacted>
---
misc/ss.c | 21 ++++++++++++---------
1 files changed, 12 insertions(+), 9 deletions(-)
@@ -1517,7 +1517,10 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)nladdr.nl_family=AF_NETLINK;req.nlh.nlmsg_len=sizeof(req);-req.nlh.nlmsg_type=socktype;+if(protocol==IPPROTO_TCP)+req.nlh.nlmsg_type=TCPDIAG_GETSOCK;+else+req.nlh.nlmsg_type=DCCPDIAG_GETSOCK;req.nlh.nlmsg_flags=NLM_F_ROOT|NLM_F_MATCH|NLM_F_REQUEST;req.nlh.nlmsg_pid=0;req.nlh.nlmsg_seq=123456;
@@ -1626,7 +1629,7 @@ static int tcp_show_netlink(struct filter *f, FILE *dump_fp, int socktype)h=NLMSG_NEXT(h,status);continue;}-err=tcp_show_sock(h,NULL);+err=inet_show_sock(h,NULL);if(err<0){close(fd);returnerr;
@@ -1699,7 +1702,7 @@ static int tcp_show_netlink_file(struct filter *f)return-1;}-err=tcp_show_sock(h,f);+err=inet_show_sock(h,f);if(err<0)returnerr;}
@@ -1717,7 +1720,7 @@ static int tcp_show(struct filter *f, int socktype)returntcp_show_netlink_file(f);if(!getenv("PROC_NET_TCP")&&!getenv("PROC_ROOT")-&&tcp_show_netlink(f,NULL,socktype)==0)+&&inet_show_netlink(f,NULL,socktype)==0)return0;/* Sigh... We have to parse /proc/net/tcp... */
@@ -2980,7 +2983,7 @@ int main(int argc, char *argv[])exit(-1);}}-tcp_show_netlink(¤t_filter,dump_fp,TCPDIAG_GETSOCK);+inet_show_netlink(¤t_filter,dump_fp,IPPROTO_TCP);fflush(dump_fp);exit(0);}
@@ -3048,8 +3051,8 @@ int main(int argc, char *argv[])if(current_filter.dbs&(1<<UDP_DB))udp_show(¤t_filter);if(current_filter.dbs&(1<<TCP_DB))-tcp_show(¤t_filter,TCPDIAG_GETSOCK);+tcp_show(¤t_filter,IPPROTO_TCP);if(current_filter.dbs&(1<<DCCP_DB))-tcp_show(¤t_filter,DCCPDIAG_GETSOCK);+tcp_show(¤t_filter,IPPROTO_DCCP);return0;}
From: Pavel Emelyanov <hidden> Date: 2012-10-25 13:21:43
The existing function inet_show_netlink sends tcp-diag request and
then receives back the response and prints it on the screen.
The sock-diag and legacy tcp-diag have different request types, but
report sockets in the same format. In order to support both it's
convenient to split the code into sending and receiving parts.
Signed-off-by: Pavel Emelyanov <redacted>
---
misc/ss.c | 27 +++++++++++++++++++++------
1 files changed, 21 insertions(+), 6 deletions(-)
From: Pavel Emelyanov <hidden> Date: 2012-10-25 13:23:37
That is -- write the code, that sends diag request in new format. It's
mostly copied from tcp-diag code. Plus, sock-diag differentiates sockets
by families, thus we have to send two requests sequentially.
If we fail to submit new sock-diag request, try to fall-back and submit
the legacy tcp-diag one.
Signed-off-by: Pavel Emelyanov <redacted>
---
misc/ss.c | 95 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 87 insertions(+), 8 deletions(-)
From: Pavel Emelyanov <hidden> Date: 2012-10-25 13:24:59
Now everything is prepared for it, so the patch is straightforward.
Signed-off-by: Pavel Emelyanov <redacted>
---
misc/ss.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
From: Pavel Emelyanov <hidden> Date: 2012-10-25 13:26:45
To see this we need kernel >=3.7 with _SHUTDOWN nlarrts in diag messages.
The output will look like arrows at the end of each line, like this:
ESTAB 0 0 127.0.0.1:41705 127.0.0.1:12345 ino:143321 sk:ffff88003a8cea00 -->
ESTAB 0 0 127.0.0.1:46925 127.0.0.1:12346 ino:143322 sk:ffff88003a8ce4c0 <--
ESTAB 0 0 127.0.0.1:51678 127.0.0.1:12347 ino:143323 sk:ffff88003a8cdf80 ---
ESTAB 0 0 127.0.0.1:46911 127.0.0.1:12348 ino:143324 sk:ffff88003b7f05c0 <->
for SHUT_RD, SHUT_WR, SHUT_RDWR and non-shutdown sockets respectively.
Signed-off-by: Pavel Emelyanov <redacted>
---
include/linux/inet_diag.h | 3 ++-
include/linux/unix_diag.h | 1 +
misc/ss.c | 26 ++++++++++++++++++++------
3 files changed, 23 insertions(+), 7 deletions(-)
From: Stephen Hemminger <hidden> Date: 2012-10-25 15:53:18
On Thu, 25 Oct 2012 17:26:44 +0400
Pavel Emelyanov [off-list ref] wrote:
quoted hunk
To see this we need kernel >=3.7 with _SHUTDOWN nlarrts in diag messages.
The output will look like arrows at the end of each line, like this:
ESTAB 0 0 127.0.0.1:41705 127.0.0.1:12345 ino:143321 sk:ffff88003a8cea00 -->
ESTAB 0 0 127.0.0.1:46925 127.0.0.1:12346 ino:143322 sk:ffff88003a8ce4c0 <--
ESTAB 0 0 127.0.0.1:51678 127.0.0.1:12347 ino:143323 sk:ffff88003a8cdf80 ---
ESTAB 0 0 127.0.0.1:46911 127.0.0.1:12348 ino:143324 sk:ffff88003b7f05c0 <->
for SHUT_RD, SHUT_WR, SHUT_RDWR and non-shutdown sockets respectively.
Signed-off-by: Pavel Emelyanov <redacted>
---
include/linux/inet_diag.h | 3 ++-
include/linux/unix_diag.h | 1 +
misc/ss.c | 26 ++++++++++++++++++++------
3 files changed, 23 insertions(+), 7 deletions(-)
From: Eric Dumazet <hidden> Date: 2012-10-25 16:53:34
On Thu, 2012-10-25 at 08:52 -0700, Stephen Hemminger wrote:
On Thu, 25 Oct 2012 17:26:44 +0400
Pavel Emelyanov [off-list ref] wrote:
quoted
To see this we need kernel >=3.7 with _SHUTDOWN nlarrts in diag messages.
The output will look like arrows at the end of each line, like this:
ESTAB 0 0 127.0.0.1:41705 127.0.0.1:12345 ino:143321 sk:ffff88003a8cea00 -->
ESTAB 0 0 127.0.0.1:46925 127.0.0.1:12346 ino:143322 sk:ffff88003a8ce4c0 <--
ESTAB 0 0 127.0.0.1:51678 127.0.0.1:12347 ino:143323 sk:ffff88003a8cdf80 ---
ESTAB 0 0 127.0.0.1:46911 127.0.0.1:12348 ino:143324 sk:ffff88003b7f05c0 <->
for SHUT_RD, SHUT_WR, SHUT_RDWR and non-shutdown sockets respectively.
Signed-off-by: Pavel Emelyanov <redacted>
---
include/linux/inet_diag.h | 3 ++-
include/linux/unix_diag.h | 1 +
misc/ss.c | 26 ++++++++++++++++++++------
3 files changed, 23 insertions(+), 7 deletions(-)
Since this requires 3.8 or later kernel, please resubmit this
patch during that merge window.
--
I am wondering what possibly could happen if applying this before ?
iproute2 should be non dependent on kernel version, we make sure to not
add regressions.
From: Stephen Hemminger <hidden> Date: 2012-10-25 17:10:11
On Thu, 25 Oct 2012 18:53:30 +0200
Eric Dumazet [off-list ref] wrote:
On Thu, 2012-10-25 at 08:52 -0700, Stephen Hemminger wrote:
quoted
On Thu, 25 Oct 2012 17:26:44 +0400
Pavel Emelyanov [off-list ref] wrote:
quoted
To see this we need kernel >=3.7 with _SHUTDOWN nlarrts in diag messages.
The output will look like arrows at the end of each line, like this:
ESTAB 0 0 127.0.0.1:41705 127.0.0.1:12345 ino:143321 sk:ffff88003a8cea00 -->
ESTAB 0 0 127.0.0.1:46925 127.0.0.1:12346 ino:143322 sk:ffff88003a8ce4c0 <--
ESTAB 0 0 127.0.0.1:51678 127.0.0.1:12347 ino:143323 sk:ffff88003a8cdf80 ---
ESTAB 0 0 127.0.0.1:46911 127.0.0.1:12348 ino:143324 sk:ffff88003b7f05c0 <->
for SHUT_RD, SHUT_WR, SHUT_RDWR and non-shutdown sockets respectively.
Signed-off-by: Pavel Emelyanov <redacted>
---
include/linux/inet_diag.h | 3 ++-
include/linux/unix_diag.h | 1 +
misc/ss.c | 26 ++++++++++++++++++++------
3 files changed, 23 insertions(+), 7 deletions(-)
Since this requires 3.8 or later kernel, please resubmit this
patch during that merge window.
--
I am wondering what possibly could happen if applying this before ?
iproute2 should be non dependent on kernel version, we make sure to not
add regressions.
I don't want the stashed kernel headers to get out of date with kernel exported ones.
People who want to test early features are free to build their own pre-release versions.
From: Eric Dumazet <hidden> Date: 2012-10-25 18:00:57
On Thu, 2012-10-25 at 10:09 -0700, Stephen Hemminger wrote:
I don't want the stashed kernel headers to get out of date with kernel exported ones.
People who want to test early features are free to build their own pre-release versions.
--
Have you considered an iproute2-next tree, it would really help us a
lot.
Just to be clear, were the patches 1-4 accepted ?
(UDP diag was added kernel in December 2011)
Thanks
From: Stephen Hemminger <hidden> Date: 2012-10-25 23:02:14
On Thu, 25 Oct 2012 20:00:54 +0200
Eric Dumazet [off-list ref] wrote:
On Thu, 2012-10-25 at 10:09 -0700, Stephen Hemminger wrote:
quoted
I don't want the stashed kernel headers to get out of date with kernel exported ones.
People who want to test early features are free to build their own pre-release versions.
--
Have you considered an iproute2-next tree, it would really help us a
lot.
Just to be clear, were the patches 1-4 accepted ?
(UDP diag was added kernel in December 2011)
Thanks
The first 4 patches are fine, and I will probably take those.