On Mon, 2 Mar 2015 04:48:13 -0500, Mike Frysinger <vap...@gentoo.org> wrote:
> --- a/socketutils.c
> +++ b/socketutils.c
> @@ -64,7 +64,7 @@ inet_parse_response(const char *proto_name, const void 
> *data, int data_len,
>                   const unsigned long inode)
>  {
>       const struct inet_diag_msg *diag_msg = data;
> -     static const char zero_addr[sizeof(struct in6_addr)];
> +     static const char zero_addr[sizeof(struct in6_addr) + 20];
>       socklen_t addr_size, text_size;
>  
>       if (diag_msg->idiag_inode != inode)


Thank you. but I just wonder why this has effects on the result.

Could you try the patch and run tests on alpha?

The patch generates /tmp/strace-yy-debug, which helps us to debug.

The patch dumps diag_msg like:

    TCP:[127.0.0.1:53834->127.0.0.1:57272]
    0000: 02  01  00  00  d2  4a  df  b8 | 7f  00  00  01  00  00  00  00  
    0010: 00  00  00  00  00  00  00  00 | 7f  00  00  01  00  00  00  00  
    0020: 00  00  00  00  00  00  00  00 | 00  00  00  00  00  9d  a7  18  
    0030: 02  88  ff  ff  00  00  00  00 | 00  00  00  00  00  00  00  00  
    0040: e8  03  00  00  4e  fe  02  00 | 
    TCP:[127.0.0.1:53834->127.0.0.1:57272]
    0000: 02  01  00  00  d2  4a  df  b8 | 7f  00  00  01  00  00  00  00  
    0010: 00  00  00  00  00  00  00  00 | 7f  00  00  01  00  00  00  00  
    0020: 00  00  00  00  00  00  00  00 | 00  00  00  00  00  9d  a7  18  
    0030: 02  88  ff  ff  00  00  00  00 | 00  00  00  00  00  00  00  00  
    0040: e8  03  00  00  4e  fe  02  00 | 


If ss command, which is part of iproute2, is available on the alpha system,

    %  ss -n -t -p 
    State      Recv-Q Send-Q        Local Address:Port          Peer 
Address:Port 
    ESTAB      0      0              10.64.244.96:49945          
10.64.255.1:631    users:(("gnome-settings-",pid=4724,fd=21))
    ESTAB      0      0             192.168.11.12:42019         
96.43.148.82:443    users:(("firefox",pid=6415,fd=40))
    CLOSE-WAIT 1      0             192.168.11.12:58661       
152.19.134.142:443   

Older ss just opens /proc/net/tcp and read it.
Newer ss uses netlink socket to get tcp socket informaton as strace -yy does.

You can detect newer or older with "/usr/bin/strace -e open ss -t".
Older implentation may open /proc/net/tcp. Newer one may not.

Regards,
Masatake YAMATO
diff --git a/socketutils.c b/socketutils.c
index 2de59cd..8d6d563 100644
--- a/socketutils.c
+++ b/socketutils.c
@@ -8,6 +8,8 @@
 #include <linux/unix_diag.h>
 #include <linux/rtnetlink.h>
 
+#include <stdio.h>
+
 #if !defined NETLINK_SOCK_DIAG && defined NETLINK_INET_DIAG
 # define NETLINK_SOCK_DIAG NETLINK_INET_DIAG
 #endif
@@ -97,6 +99,35 @@ inet_parse_response(const char *proto_name, const void *data, int data_len,
 			       dst_buf, text_size))
 			return false;
 
+		{
+			static FILE *fp;
+			unsigned int i;
+			unsigned char *b;
+			
+			if (!fp)
+			{
+				fp = fopen("/tmp/strace-yy-debug","a");
+				if(!fp)
+				{
+					perror("fopen for -yy debug");
+					exit(1);
+				}
+			}
+
+			fprintf(fp, "%s:[%s:%u->%s:%u]",
+				proto_name,
+				src_buf, ntohs(diag_msg->id.idiag_sport),
+				dst_buf, ntohs(diag_msg->id.idiag_dport));
+			b = (unsigned char *)diag_msg;
+			for (i = 0; i < sizeof (struct inet_diag_msg); i++)
+			{
+				if ((i % 16)  == 0)
+					fprintf(fp, "\n%04x: ", i);
+				fprintf(fp, "%02x%s", b[i], ((i % 16) == 7)? " | ": "  ");
+			}
+			fputc('\n', fp);
+			fflush (fp);
+		}
 		tprintf("%s:[%s:%u->%s:%u]",
 			proto_name,
 			src_buf, ntohs(diag_msg->id.idiag_sport),
------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to