From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Yoann P." Subject: Re: [PATCH] Fix ss Netid column and Local/Peer_Address Date: Mon, 29 Oct 2018 21:06:35 +0100 Message-ID: <2356588.cRoqrM3dbm@yo-gs> References: <5185850.l7bAsbzJZX@yo-gs> <20181029192036.567fc122@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7Bit Cc: netdev@vger.kernel.org, Stephen Hemminger To: Stefano Brivio Return-path: Received: from mail-wr1-f65.google.com ([209.85.221.65]:36263 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726725AbeJ3E4w (ORCPT ); Tue, 30 Oct 2018 00:56:52 -0400 Received: by mail-wr1-f65.google.com with SMTP id y16so10103997wrw.3 for ; Mon, 29 Oct 2018 13:06:39 -0700 (PDT) In-Reply-To: <20181029192036.567fc122@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: > Hi Yohann, > > On Fri, 26 Oct 2018 22:53:32 +0200 > > "Yoann P." wrote: > > When using ss -Hutn4 or -utn3, Netid and State columns are sometime > > merged, it can be confusing when trying to pipe into awk or column. > > Thanks for fixing this. A few comments though: > > @@ -144,9 +144,9 @@ static struct column columns[] = { > > > > { ALIGN_LEFT, "State", " ", 0, 0, 0 }, > > { ALIGN_LEFT, "Recv-Q", " ", 0, 0, 0 }, > > { ALIGN_LEFT, "Send-Q", " ", 0, 0, 0 }, > > > > - { ALIGN_RIGHT, "Local Address:", " ", 0, 0, 0 }, > > + { ALIGN_RIGHT, "Local_Address:", " ", 0, 0, 0 }, > > > > { ALIGN_LEFT, "Port", "", 0, 0, 0 }, > > > > - { ALIGN_RIGHT, "Peer Address:", " ", 0, 0, 0 }, > > + { ALIGN_RIGHT, "Peer_Address:", " ", 0, 0, 0 }, > > This is needed only if you pipe the output to column(1), I don't think > it's a bug, because printing the header when you pass the output to > column(1) makes little sense -- one should use -H then. I don't really care about this modification, I came across it while making the github issue example, seemed to be little change, so I dit it. > > By the way, why do you use column(1), when ss already prints output in > columns? Any other issue you are working around? column can hide columns with "-H -" and is a bit faster than awk to output a single column according to time, it's the only reason I mentioned it. > > > { ALIGN_LEFT, "Port", "", 0, 0, 0 }, > > { ALIGN_LEFT, "", "", 0, 0, 0 }, > > > > }; > > > > @@ -1334,7 +1334,7 @@ static void sock_state_print(struct sockstat *s) > > > > out("`- %s", sctp_sstate_name[s->state]); > > > > } else { > > > > field_set(COL_NETID); > > > > - out("%s", sock_name); > > + out("%-6s", sock_name); > > I could reproduce this issue with a 70-columns terminal and the options > you gave. > > Anyway, I don't think this is the right way to fix it: this will waste > one to two columns in case we have three letters for the Netid > specifier, and won't work the day we get six-letters names. In general, > it looks like a bad idea to reintroduce hardcoded width counts. I agree, I just not found the proper way to do it (Not a programmer). > > The actual issue seems to be that in some cases the left delimiter for > the State column is not printed, and I think you should fix that > instead. I'll look into this within a couple of days and give you some > more specific hints in case you still need them by then.