Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Oct 2025 14:39:47 -0600
From:      Alan Somers <asomers@freebsd.org>
To:        Michael Tuexen <tuexen@freebsd.org>
Cc:        src-committers@freebsd.org, dev-commits-src-all@freebsd.org,  dev-commits-src-main@freebsd.org
Subject:   Re: git: 746eadecaa7d - main - sockstat: show path state column only when useful
Message-ID:  <CAOtMX2iy_Tb7e8XHTW%2BCAXinJRHBTPa3UBEpPkuTRuh4WKzg5w@mail.gmail.com>
In-Reply-To: <2B20483E-F15A-4BEA-AEE5-6490A94AC8B0@FreeBSD.org>
References:  <202510091919.599JJ5dd028526@gitrepo.freebsd.org> <CAOtMX2g_JyhQY%2BccLmt4c5Tq-oh%2BMazz4xCHdvcZzCyi%2BDGYcw@mail.gmail.com> <995AAC96-FFE6-4D25-90C5-1BE9B6BF3729@FreeBSD.org> <CAOtMX2hsa2v3ZVK2i93s%2Bt0AvYrEsYWTnQkqz0koiBbDFXdmyQ@mail.gmail.com> <2B20483E-F15A-4BEA-AEE5-6490A94AC8B0@FreeBSD.org>

index | next in thread | previous in thread | raw e-mail

[-- Attachment #1 --]
On Thu, Oct 9, 2025 at 2:38 PM Michael Tuexen <tuexen@freebsd.org> wrote:

> > On 9. Oct 2025, at 22:25, Alan Somers <asomers@FreeBSD.org> wrote:
> >
> > On Thu, Oct 9, 2025 at 2:22 PM Michael Tuexen <tuexen@freebsd.org>
> wrote:
> > > On 9. Oct 2025, at 22:01, Alan Somers <asomers@FreeBSD.org> wrote:
> > >
> > > It looks like this change will cause sockstat to skip output path
> state even in JSON output mode.  Is that deliberate?  I would think that it
> would be better for machine-readable formats if the output were predictable.
> > I haven't used it in that setup. So you would prefer to only drop the
> column
> > when generating plain text?
> >
> > Yes
> What about HTML? Wondering if I could base the display of the column
> on is_xo_style_encoding.
>

I would think that HTML should behave like JSON, since it's used for
creating tables.


> >   > Also, the English in the man page is awkward.  I think you mean "at
> least one path to show".
> > Would "at least one path state to show" be acceptable?
> >
> > Yes, that would be good.
> Will fix it in combination with the above issue.
>
> Best regards
> Michael
> >   Best regards
> > Michael
> > >
> > > On Thu, Oct 9, 2025 at 1:19 PM Michael Tuexen <tuexen@freebsd.org>
> wrote:
> > > The branch main has been updated by tuexen:
> > >
> > > URL:
> https://cgit.FreeBSD.org/src/commit/?id=746eadecaa7dc8913721cbaa9be4e603bd36ea49
> > >
> > > commit 746eadecaa7dc8913721cbaa9be4e603bd36ea49
> > > Author:     Michael Tuexen <tuexen@FreeBSD.org>
> > > AuthorDate: 2025-10-09 19:16:38 +0000
> > > Commit:     Michael Tuexen <tuexen@FreeBSD.org>
> > > CommitDate: 2025-10-09 19:16:38 +0000
> > >
> > >     sockstat: show path state column only when useful
> > >
> > >     Showing the path state column is only useful, if there is at least
> one
> > >     SCTP endpoint shown, which is not in the state CLOSED or LISTEN.
> > >     Don't show it when it is not useful.
> > >
> > >     Reviewed by:            rrs
> > >     MFC after:              3 days
> > >     Sponsored by:           Netflix, Inc.
> > >     Differential Revision:  https://reviews.freebsd.org/D52986
> > > ---
> > >  usr.bin/sockstat/main.c     | 8 ++++++--
> > >  usr.bin/sockstat/sockstat.1 | 3 ++-
> > >  2 files changed, 8 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c
> > > index f0eb83eb3e9f..7fedfd5b8724 100644
> > > --- a/usr.bin/sockstat/main.c
> > > +++ b/usr.bin/sockstat/main.c
> > > @@ -103,6 +103,7 @@ static bool  opt_u;         /* Show Unix domain
> sockets */
> > >  static u_int    opt_v;         /* Verbose mode */
> > >  static bool     opt_w;         /* Automatically size the columns */
> > >  static bool     is_xo_style_encoding;
> > > +static bool     show_path_state = false;
> > >
> > >  /*
> > >   * Default protocols to use if no -P was defined.
> > > @@ -584,6 +585,7 @@ gather_sctp(void)
> > >                                      !(local_all_loopback ||
> > >                                      foreign_all_loopback))) {
> > >                                         RB_INSERT(socks_t, &socks,
> sock);
> > > +                                       show_path_state = true;
> > >                                 } else {
> > >                                         free_socket(sock);
> > >                                 }
> > > @@ -1485,7 +1487,7 @@ display_sock(struct sock *s, struct col_widths
> *cw, char *buf, size_t bufsize)
> > >                         } else if (!is_xo_style_encoding)
> > >                                 xo_emit(" {:encaps/%*s}", cw->encaps,
> "??");
> > >                 }
> > > -               if (opt_s) {
> > > +               if (opt_s && show_path_state) {
> > >                         if (faddr != NULL &&
> > >                             s->proto == IPPROTO_SCTP &&
> > >                             s->state != SCTP_CLOSED &&
> > > @@ -1632,7 +1634,9 @@ display(void)
> > >                 if (opt_U)
> > >                         xo_emit(" {T:/%*s}", cw.encaps, "ENCAPS");
> > >                 if (opt_s) {
> > > -                       xo_emit(" {T:/%-*s}", cw.path_state, "PATH
> STATE");
> > > +                       if (show_path_state)
> > > +                               xo_emit(" {T:/%-*s}", cw.path_state,
> > > +                                   "PATH STATE");
> > >                         xo_emit(" {T:/%-*s}", cw.conn_state, "CONN
> STATE");
> > >                 }
> > >                 if (opt_b)
> > > diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1
> > > index dabb3042bfd4..d14eb967ad0f 100644
> > > --- a/usr.bin/sockstat/sockstat.1
> > > +++ b/usr.bin/sockstat/sockstat.1
> > > @@ -25,7 +25,7 @@
> > >  .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
> USE OF
> > >  .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
> > >  .\"
> > > -.Dd October 7, 2025
> > > +.Dd October 9, 2025
> > >  .Dt SOCKSTAT 1
> > >  .Os
> > >  .Sh NAME
> > > @@ -205,6 +205,7 @@ is specified (only for SCTP or TCP).
> > >  The path state if
> > >  .Fl s
> > >  is specified (only for SCTP).
> > > +This column is only shown when there is at least one path state shown.
> > >  .It Li CONN STATE
> > >  The connection state if
> > >  .Fl s
> >
>
>

[-- Attachment #2 --]
<div dir="ltr"><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Thu, Oct 9, 2025 at 2:38 PM Michael Tuexen &lt;<a href="mailto:tuexen@freebsd.org">tuexen@freebsd.org</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; On 9. Oct 2025, at 22:25, Alan Somers &lt;asomers@FreeBSD.org&gt; wrote:<br>
&gt; <br>
&gt; On Thu, Oct 9, 2025 at 2:22 PM Michael Tuexen &lt;<a href="mailto:tuexen@freebsd.org" target="_blank">tuexen@freebsd.org</a>&gt; wrote:<br>
&gt; &gt; On 9. Oct 2025, at 22:01, Alan Somers &lt;asomers@FreeBSD.org&gt; wrote:<br>
&gt; &gt; <br>
&gt; &gt; It looks like this change will cause sockstat to skip output path state even in JSON output mode.  Is that deliberate?  I would think that it would be better for machine-readable formats if the output were predictable.<br>
&gt; I haven&#39;t used it in that setup. So you would prefer to only drop the column<br>
&gt; when generating plain text?<br>
&gt; <br>
&gt; Yes<br>
What about HTML? Wondering if I could base the display of the column<br>
on is_xo_style_encoding.<br></blockquote><div><br></div><div>I would think that HTML should behave like JSON, since it&#39;s used for creating tables.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
&gt;   &gt; Also, the English in the man page is awkward.  I think you mean &quot;at least one path to show&quot;.<br>
&gt; Would &quot;at least one path state to show&quot; be acceptable?<br>
&gt; <br>
&gt; Yes, that would be good.<br>
Will fix it in combination with the above issue.<br>
<br>
Best regards<br>
Michael<br>
&gt;   Best regards<br>
&gt; Michael<br>
&gt; &gt; <br>
&gt; &gt; On Thu, Oct 9, 2025 at 1:19 PM Michael Tuexen &lt;<a href="mailto:tuexen@freebsd.org" target="_blank">tuexen@freebsd.org</a>&gt; wrote:<br>
&gt; &gt; The branch main has been updated by tuexen:<br>
&gt; &gt; <br>
&gt; &gt; URL: <a href="https://cgit.FreeBSD.org/src/commit/?id=746eadecaa7dc8913721cbaa9be4e603bd36ea49" rel="noreferrer" target="_blank">https://cgit.FreeBSD.org/src/commit/?id=746eadecaa7dc8913721cbaa9be4e603bd36ea49</a><br>;
&gt; &gt; <br>
&gt; &gt; commit 746eadecaa7dc8913721cbaa9be4e603bd36ea49<br>
&gt; &gt; Author:     Michael Tuexen &lt;tuexen@FreeBSD.org&gt;<br>
&gt; &gt; AuthorDate: 2025-10-09 19:16:38 +0000<br>
&gt; &gt; Commit:     Michael Tuexen &lt;tuexen@FreeBSD.org&gt;<br>
&gt; &gt; CommitDate: 2025-10-09 19:16:38 +0000<br>
&gt; &gt; <br>
&gt; &gt;     sockstat: show path state column only when useful<br>
&gt; &gt; <br>
&gt; &gt;     Showing the path state column is only useful, if there is at least one<br>
&gt; &gt;     SCTP endpoint shown, which is not in the state CLOSED or LISTEN.<br>
&gt; &gt;     Don&#39;t show it when it is not useful.<br>
&gt; &gt; <br>
&gt; &gt;     Reviewed by:            rrs<br>
&gt; &gt;     MFC after:              3 days<br>
&gt; &gt;     Sponsored by:           Netflix, Inc.<br>
&gt; &gt;     Differential Revision:  <a href="https://reviews.freebsd.org/D52986" rel="noreferrer" target="_blank">https://reviews.freebsd.org/D52986</a><br>;
&gt; &gt; ---<br>
&gt; &gt;  usr.bin/sockstat/main.c     | 8 ++++++--<br>
&gt; &gt;  usr.bin/sockstat/sockstat.1 | 3 ++-<br>
&gt; &gt;  2 files changed, 8 insertions(+), 3 deletions(-)<br>
&gt; &gt; <br>
&gt; &gt; diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c<br>
&gt; &gt; index f0eb83eb3e9f..7fedfd5b8724 100644<br>
&gt; &gt; --- a/usr.bin/sockstat/main.c<br>
&gt; &gt; +++ b/usr.bin/sockstat/main.c<br>
&gt; &gt; @@ -103,6 +103,7 @@ static bool  opt_u;         /* Show Unix domain sockets */<br>
&gt; &gt;  static u_int    opt_v;         /* Verbose mode */<br>
&gt; &gt;  static bool     opt_w;         /* Automatically size the columns */<br>
&gt; &gt;  static bool     is_xo_style_encoding;<br>
&gt; &gt; +static bool     show_path_state = false;<br>
&gt; &gt; <br>
&gt; &gt;  /*<br>
&gt; &gt;   * Default protocols to use if no -P was defined.<br>
&gt; &gt; @@ -584,6 +585,7 @@ gather_sctp(void)<br>
&gt; &gt;                                      !(local_all_loopback ||<br>
&gt; &gt;                                      foreign_all_loopback))) {<br>
&gt; &gt;                                         RB_INSERT(socks_t, &amp;socks, sock);<br>
&gt; &gt; +                                       show_path_state = true;<br>
&gt; &gt;                                 } else {<br>
&gt; &gt;                                         free_socket(sock);<br>
&gt; &gt;                                 }<br>
&gt; &gt; @@ -1485,7 +1487,7 @@ display_sock(struct sock *s, struct col_widths *cw, char *buf, size_t bufsize)<br>
&gt; &gt;                         } else if (!is_xo_style_encoding)<br>
&gt; &gt;                                 xo_emit(&quot; {:encaps/%*s}&quot;, cw-&gt;encaps, &quot;??&quot;);<br>
&gt; &gt;                 }<br>
&gt; &gt; -               if (opt_s) {<br>
&gt; &gt; +               if (opt_s &amp;&amp; show_path_state) {<br>
&gt; &gt;                         if (faddr != NULL &amp;&amp;<br>
&gt; &gt;                             s-&gt;proto == IPPROTO_SCTP &amp;&amp;<br>
&gt; &gt;                             s-&gt;state != SCTP_CLOSED &amp;&amp;<br>
&gt; &gt; @@ -1632,7 +1634,9 @@ display(void)<br>
&gt; &gt;                 if (opt_U)<br>
&gt; &gt;                         xo_emit(&quot; {T:/%*s}&quot;, cw.encaps, &quot;ENCAPS&quot;);<br>
&gt; &gt;                 if (opt_s) {<br>
&gt; &gt; -                       xo_emit(&quot; {T:/%-*s}&quot;, cw.path_state, &quot;PATH STATE&quot;);<br>
&gt; &gt; +                       if (show_path_state)<br>
&gt; &gt; +                               xo_emit(&quot; {T:/%-*s}&quot;, cw.path_state,<br>
&gt; &gt; +                                   &quot;PATH STATE&quot;);<br>
&gt; &gt;                         xo_emit(&quot; {T:/%-*s}&quot;, cw.conn_state, &quot;CONN STATE&quot;);<br>
&gt; &gt;                 }<br>
&gt; &gt;                 if (opt_b)<br>
&gt; &gt; diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1<br>
&gt; &gt; index dabb3042bfd4..d14eb967ad0f 100644<br>
&gt; &gt; --- a/usr.bin/sockstat/sockstat.1<br>
&gt; &gt; +++ b/usr.bin/sockstat/sockstat.1<br>
&gt; &gt; @@ -25,7 +25,7 @@<br>
&gt; &gt;  .\&quot; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF<br>
&gt; &gt;  .\&quot; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br>
&gt; &gt;  .\&quot;<br>
&gt; &gt; -.Dd October 7, 2025<br>
&gt; &gt; +.Dd October 9, 2025<br>
&gt; &gt;  .Dt SOCKSTAT 1<br>
&gt; &gt;  .Os<br>
&gt; &gt;  .Sh NAME<br>
&gt; &gt; @@ -205,6 +205,7 @@ is specified (only for SCTP or TCP).<br>
&gt; &gt;  The path state if<br>
&gt; &gt;  .Fl s<br>
&gt; &gt;  is specified (only for SCTP).<br>
&gt; &gt; +This column is only shown when there is at least one path state shown.<br>
&gt; &gt;  .It Li CONN STATE<br>
&gt; &gt;  The connection state if<br>
&gt; &gt;  .Fl s<br>
&gt; <br>
<br>
</blockquote></div></div>
help

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAOtMX2iy_Tb7e8XHTW%2BCAXinJRHBTPa3UBEpPkuTRuh4WKzg5w>