Subject: Re: iproute2 tools for 2.6.31

From: Eric Dumazet <[email-masked]>
Date: Fri, 11 Sep 2009 09:48:07 +0200

Stephen Hemminger a écrit :
> I am putting together release for 2.6.31 based tools.
> The only open issue is how to deal with the error handling in commands
> that do monitoring filtering.  Right now leaning towards the two socket
> solution.
> 
> So if you have anything else that you have been waiting for,
> please drop me a note.
>

One thing that is IMHO strange is the output of sk information 
on 64 bits (x86_64 for example)

# ss -e dst 55.225.18.6
State      Recv-Q Send-Q                                Local Address:Port                                    Peer Address:Port
ESTAB      0      0                                      55.225.18.96:9273                                     55.225.18.6:37405    timer:(keepalive,20min,0) ino:57807651 sk:36e40c80ffff8100

True sk pointer is ffff8100ffff8100, not 36e40c80ffff8100

ss/misc.c

                printf(" sk:%08x", r->id.idiag_cookie[0]);
                if (r->id.idiag_cookie[1] != 0)
                        printf("%08x", r->id.idiag_cookie[1]);

while kernel does :
        r->id.idiag_cookie[0] = (u32)(unsigned long)sk;
        r->id.idiag_cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);

What do you think of following patch ?

[PATCH] ss: correct display of sk pointer

On 64bit arches, sk pointer was 32/32 reversed.

Signed-off-by: Eric Dumazet <[email-masked]>
---

diff --git a/misc/ss.c b/misc/ss.c
index 651fe3b..2447186 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -1393,9 +1393,10 @@ static int tcp_show_sock(struct nlmsghdr *nlh, struct filter *f)
 		if (r->idiag_uid)
 			printf(" uid:%u", (unsigned)r->idiag_uid);
 		printf(" ino:%u", r->idiag_inode);
-		printf(" sk:%08x", r->id.idiag_cookie[0]);
+		printf(" sk:");
 		if (r->id.idiag_cookie[1] != 0)
 			printf("%08x", r->id.idiag_cookie[1]);
+ 		printf("%08x", r->id.idiag_cookie[0]);
 	}
 	if (show_mem || show_tcpinfo) {
 		printf("\n\t");