From 777eba52309e229853a4dd08566e3df4980de740 Mon Sep 17 00:00:00 2001
From: sangxu <sangxu@huawei.com>
Date: Fri, 26 Oct 2018 16:34:43 +0800
Subject: [PATCH] ss:Use "%u" to print port when show unix socket

When using ss command to display unix domain socket, the ss shows
as below, the local address port and peer address port may
overflow which looks like equal to the socket fd inode.

Netid  State  Recv-Q Send-Q Local Address:Port Peer Address:Port
u_str  ESTAB  0      0  /var/run/libvirt/libvirt-sock -1351042552
 * -1351050742           users:(("libvirtd",pid=2295,fd=51))

lrwx------ 1 root root 64 Oct 10 10:34 51 -> socket:[2943924744]

As we can see, it uses "%u" to print port when printing tcp socket
in function "resolve_service". So, it seems that it should use "%u"
to pirnt port when showing unix socket info as well.

---
 misc/ss.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/misc/ss.c b/misc/ss.c
index f99b687..abee4e4 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -3540,10 +3540,11 @@ static void unix_stats_print(struct sockstat *s, struct filter *f)
 
 	sock_state_print(s);
 
-	sock_addr_print(s->name ?: "*", " ",
-			int_to_str(s->lport, port_name), NULL);
-	sock_addr_print(s->peer_name ?: "*", " ",
-			int_to_str(s->rport, port_name), NULL);
+	sprintf(port_name, "%u", s->lport);
+	sock_addr_print(s->name ?: "*", " ", port_name, NULL);
+
+	sprintf(port_name, "%u", s->rport);
+	sock_addr_print(s->peer_name ?: "*", " ", port_name, NULL);
 
 	proc_ctx_print(s);
 }
-- 
1.8.3.1

