From: vadimk Date: Sat, 18 Oct 2014 17:46:29 +0000 (+0300) Subject: ss: Fixed broken output for Netlink 'Peer Address:Port' column X-Git-Tag: v3.18.0~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2dc854854b7f1b0a08ae496c7c4b27a107badf5e;p=thirdparty%2Fiproute2.git ss: Fixed broken output for Netlink 'Peer Address:Port' column When output the netlink sockets: ss -A netlink state close the layout is a little broken with a shifted 'Peer Address:Port' stars and empty new lines. Fixed by making the port field to be wider for 'Local Address:Port' column. Signed-off-by: Vadim Kochan --- diff --git a/misc/ss.c b/misc/ss.c index d45122404..b7730b6e2 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -88,6 +88,8 @@ int state_width; int addrp_width; int addr_width; int serv_width; +int paddr_width; +int pserv_width; int screen_width; static const char *TCP_PROTO = "tcp"; @@ -3031,10 +3033,10 @@ static void netlink_show_one(struct filter *f, if (state == NETLINK_CONNECTED) { printf("%*d:%-*d", - addr_width, dst_group, serv_width, dst_pid); + paddr_width, dst_group, pserv_width, dst_pid); } else { printf("%*s*%-*s", - addr_width, "", serv_width, ""); + paddr_width, "", pserv_width, ""); } char *pid_context = NULL; @@ -3777,9 +3779,22 @@ int main(int argc, char *argv[]) printf("%-*s ", state_width, "State"); printf("%-6s %-6s ", "Recv-Q", "Send-Q"); + paddr_width = addr_width; + pserv_width = serv_width; + + /* Netlink service column can be resolved as process name/pid thus it + * can be much wider than address column which is just a + * protocol name/id. + */ + if (current_filter.dbs & (1<