From mboxrd@z Thu Jan 1 00:00:00 1970 From: David Ahern Subject: Re: [PATCH iproute2 net-next 0/3] ss: Allow selection of columns to be displayed Date: Tue, 30 Oct 2018 10:45:33 -0600 Message-ID: References: <7ffc00c8-bdf6-5c75-564e-2663494bda5d@gmail.com> <20181030093842.0e174ea6@xeon-e3> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Cc: Stefano Brivio , "Yoann P." , netdev@vger.kernel.org To: Stephen Hemminger Return-path: Received: from mail-pg1-f193.google.com ([209.85.215.193]:38102 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727429AbeJaBju (ORCPT ); Tue, 30 Oct 2018 21:39:50 -0400 Received: by mail-pg1-f193.google.com with SMTP id f8-v6so5930868pgq.5 for ; Tue, 30 Oct 2018 09:45:36 -0700 (PDT) In-Reply-To: <20181030093842.0e174ea6@xeon-e3> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 10/30/18 10:38 AM, Stephen Hemminger wrote: > On Tue, 30 Oct 2018 10:34:45 -0600 > David Ahern wrote: > >> On 10/30/18 9:05 AM, Stefano Brivio wrote: >>> Now that we have an abstraction for columns, it's relatively easy to >>> selectively display only some of them, and Yoann has a use case for it. >>> >>> Patch 1/3 fixes a rendering issue that shows up only when display of >>> arbitrary columns is disabled. Patch 2/3 implements the relevant option, >>> and patch 3/3 makes the output more readable when some columns are >>> disabled. >>> >>> >> >> I like the intent, and I have prototyped something similar for 'ip'. >> >> A more flexible approach is to use format strings to allow users to >> customize the output order and whitespace as well. So for ss and your >> column list (winging it here): >> >> netid = %N >> state = %S >> recv Q = %Qr >> send Q = %Qs >> local address = %Al >> lport port = %Pl >> remote address = %Ar >> remote port = %Pr >> process data = %p >> ... >> >> then a format string could be: "%S %Qr %Qs %Al:%Pl %Ar:%Pr %p\n" >> >> or for csv output: "%S,%Qr,%Qs,%Al,%Pl,%Ar,%Pr,%p\n" >> >> I have not had time to look into an implementation for ip. Conceptually >> - and scanning the kernel's vsprintf code - it does not look that >> difficult, just time consuming on the frontend with the initial setup. > > The problem with custom formats is that you lose all ability for Gcc > to check format strings. > Sure, trade-offs. A custom print string is powerful. While selecting columns is an improvement, column ordering is also important - even handling other output formats (csv).