diff mbox series

ss: prevent "Process" column from being printed unless requested

Message ID 20231206111444.191173-1-qde@naccy.de (mailing list archive)
State Accepted
Commit 1607bf531fd2f984438d227ea97312df80e7cf56
Delegated to: Stephen Hemminger
Headers show
Series ss: prevent "Process" column from being printed unless requested | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch

Commit Message

Quentin Deslandes Dec. 6, 2023, 11:14 a.m. UTC
Commit 5883c6eba517 ("ss: show header for --processes/-p") added
"Process" to the list of columns printed by ss. However, the "Process"
header is now printed even if --processes/-p is not used.

This change aims to fix this by moving the COL_PROC column ID to the same
index as the corresponding column structure in the columns array, and
enabling it if --processes/-p is used.

Fixes: 5883c6eba517 ("ss: show header for --processes/-p")
Signed-off-by: Quentin Deslandes <qde@naccy.de>
---
 misc/ss.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Comments

patchwork-bot+netdevbpf@kernel.org Dec. 6, 2023, 5:50 p.m. UTC | #1
Hello:

This patch was applied to iproute2/iproute2.git (main)
by Stephen Hemminger <stephen@networkplumber.org>:

On Wed, 6 Dec 2023 12:14:44 +0100 you wrote:
> Commit 5883c6eba517 ("ss: show header for --processes/-p") added
> "Process" to the list of columns printed by ss. However, the "Process"
> header is now printed even if --processes/-p is not used.
> 
> This change aims to fix this by moving the COL_PROC column ID to the same
> index as the corresponding column structure in the columns array, and
> enabling it if --processes/-p is used.
> 
> [...]

Here is the summary with links:
  - ss: prevent "Process" column from being printed unless requested
    https://git.kernel.org/pub/scm/network/iproute2/iproute2.git/commit/?id=1607bf531fd2

You are awesome, thank you!
Matthieu Baerts (NGI0) Jan. 12, 2024, 6:39 p.m. UTC | #2
Hi Quentin,

On 06/12/2023 12:14, Quentin Deslandes wrote:
> Commit 5883c6eba517 ("ss: show header for --processes/-p") added
> "Process" to the list of columns printed by ss. However, the "Process"
> header is now printed even if --processes/-p is not used.
> 
> This change aims to fix this by moving the COL_PROC column ID to the same
> index as the corresponding column structure in the columns array, and
> enabling it if --processes/-p is used.

I recently noticed that some MPTCP selftests were broken after having
upgraded IPRoute2 to the latest version: from v6.6 to v6.7.

It looks like this is due to this patch here:

  1607bf53 ("ss: prevent "Process" column from being printed unless
requested")

If I revert it, MPTCP selftests are passing again.

From what I can see, the behaviour has changed recently: if '-i' is used
without '-p', the extra line is no longer not displayed any more, e.g.
'ss -tl' and 'ss -tli' gives the same output:

> $ ss -tl 
> State            Recv-Q           Send-Q                       Local Address:Port                       Peer Address:Port           
> LISTEN           0                1                                  0.0.0.0:4444                            0.0.0.0:*              

> $ ss -tli
> State            Recv-Q           Send-Q                       Local Address:Port                       Peer Address:Port           
> LISTEN           0                1                                  0.0.0.0:4444                            0.0.0.0:*              

If '-p' is added, '-i' works as before:

> $ ss -tlp
> State          Recv-Q         Send-Q                 Local Address:Port                   Peer Address:Port         Process         
> LISTEN         0              1                            0.0.0.0:4444                        0.0.0.0:*             users:(("netcat",pid=2668,fd=3))

> $ ss -tlpi
> State          Recv-Q         Send-Q                 Local Address:Port                   Peer Address:Port         Process         
> LISTEN         0              1                            0.0.0.0:4444                        0.0.0.0:*             users:(("netcat",pid=2668,fd=3))
>          cubic cwnd:10

(we can see the extra line with 'cubic cwnd:10')

I just noticed that you were working on other patches modifying 'ss',
and even adding a new column. Are you aware of this issue? Are you
already working -- or going to work -- on a fix for it?

Cheers,
Matt
diff mbox series

Patch

diff --git a/misc/ss.c b/misc/ss.c
index 9438382b..09dc1f37 100644
--- a/misc/ss.c
+++ b/misc/ss.c
@@ -100,8 +100,8 @@  enum col_id {
 	COL_SERV,
 	COL_RADDR,
 	COL_RSERV,
-	COL_EXT,
 	COL_PROC,
+	COL_EXT,
 	COL_MAX
 };
 
@@ -5795,6 +5795,9 @@  int main(int argc, char *argv[])
 	if (ssfilter_parse(&current_filter.f, argc, argv, filter_fp))
 		usage();
 
+	if (!show_processes)
+		columns[COL_PROC].disabled = 1;
+
 	if (!(current_filter.dbs & (current_filter.dbs - 1)))
 		columns[COL_NETID].disabled = 1;