Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 9 Oct 2025 14:25:53 -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:  <CAOtMX2hsa2v3ZVK2i93s%2Bt0AvYrEsYWTnQkqz0koiBbDFXdmyQ@mail.gmail.com>
In-Reply-To: <995AAC96-FFE6-4D25-90C5-1BE9B6BF3729@FreeBSD.org>
References:  <202510091919.599JJ5dd028526@gitrepo.freebsd.org> <CAOtMX2g_JyhQY%2BccLmt4c5Tq-oh%2BMazz4xCHdvcZzCyi%2BDGYcw@mail.gmail.com> <995AAC96-FFE6-4D25-90C5-1BE9B6BF3729@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--00000000000047068c0640bf9c22
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, Oct 9, 2025 at 2:22=E2=80=AFPM 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 wou=
ld
> 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


> > 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.


> Best regards
> Michael
> >
> > On Thu, Oct 9, 2025 at 1:19=E2=80=AFPM Michael Tuexen <tuexen@freebsd.o=
rg>
> wrote:
> > The branch main has been updated by tuexen:
> >
> > URL:
> https://cgit.FreeBSD.org/src/commit/?id=3D746eadecaa7dc8913721cbaa9be4e60=
3bd36ea49
> >
> > 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 =3D 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 =3D 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 !=3D NULL &&
> >                             s->proto =3D=3D IPPROTO_SCTP &&
> >                             s->state !=3D 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
>
>

--00000000000047068c0640bf9c22
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div class=3D"gmail_quote gmail_quote_container"><div dir=
=3D"ltr" class=3D"gmail_attr">On Thu, Oct 9, 2025 at 2:22=E2=80=AFPM Michae=
l Tuexen &lt;<a href=3D"mailto:tuexen@freebsd.org">tuexen@freebsd.org</a>&g=
t; wrote:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0p=
x 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">&gt; O=
n 9. Oct 2025, at 22:01, Alan Somers &lt;asomers@FreeBSD.org&gt; wrote:<br>
&gt; <br>
&gt; It looks like this change will cause sockstat to skip output path stat=
e even in JSON output mode.=C2=A0 Is that deliberate?=C2=A0 I would think t=
hat it would be better for machine-readable formats if the output were pred=
ictable.<br>
I haven&#39;t used it in that setup. So you would prefer to only drop the c=
olumn<br>
when generating plain text?<br></blockquote><div><br></div><div>Yes</div><d=
iv>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0p=
x 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
&gt; Also, the English in the man page is awkward.=C2=A0 I think you mean &=
quot;at least one path to show&quot;.<br>
Would &quot;at least one path state to show&quot; be acceptable?<br></block=
quote><div><br></div><div>Yes, that would be good.</div><div>=C2=A0</div><b=
lockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-le=
ft:1px solid rgb(204,204,204);padding-left:1ex">
Best regards<br>
Michael<br>
&gt; <br>
&gt; On Thu, Oct 9, 2025 at 1:19=E2=80=AFPM Michael Tuexen &lt;<a href=3D"m=
ailto:tuexen@freebsd.org" target=3D"_blank">tuexen@freebsd.org</a>&gt; wrot=
e:<br>
&gt; The branch main has been updated by tuexen:<br>
&gt; <br>
&gt; URL: <a href=3D"https://cgit.FreeBSD.org/src/commit/?id=3D746eadecaa7d=
c8913721cbaa9be4e603bd36ea49" rel=3D"noreferrer" target=3D"_blank">https://=
cgit.FreeBSD.org/src/commit/?id=3D746eadecaa7dc8913721cbaa9be4e603bd36ea49<=
/a><br>
&gt; <br>
&gt; commit 746eadecaa7dc8913721cbaa9be4e603bd36ea49<br>
&gt; Author:=C2=A0 =C2=A0 =C2=A0Michael Tuexen &lt;tuexen@FreeBSD.org&gt;<b=
r>
&gt; AuthorDate: 2025-10-09 19:16:38 +0000<br>
&gt; Commit:=C2=A0 =C2=A0 =C2=A0Michael Tuexen &lt;tuexen@FreeBSD.org&gt;<b=
r>
&gt; CommitDate: 2025-10-09 19:16:38 +0000<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0sockstat: show path state column only when useful<b=
r>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0Showing the path state column is only useful, if th=
ere is at least one<br>
&gt;=C2=A0 =C2=A0 =C2=A0SCTP endpoint shown, which is not in the state CLOS=
ED or LISTEN.<br>
&gt;=C2=A0 =C2=A0 =C2=A0Don&#39;t show it when it is not useful.<br>
&gt; <br>
&gt;=C2=A0 =C2=A0 =C2=A0Reviewed by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 rrs<br>
&gt;=C2=A0 =C2=A0 =C2=A0MFC after:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 3 days<br>
&gt;=C2=A0 =C2=A0 =C2=A0Sponsored by:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0Netflix, Inc.<br>
&gt;=C2=A0 =C2=A0 =C2=A0Differential Revision:=C2=A0 <a href=3D"https://rev=
iews.freebsd.org/D52986" rel=3D"noreferrer" target=3D"_blank">https://revie=
ws.freebsd.org/D52986</a><br>
&gt; ---<br>
&gt;=C2=A0 usr.bin/sockstat/main.c=C2=A0 =C2=A0 =C2=A0| 8 ++++++--<br>
&gt;=C2=A0 usr.bin/sockstat/sockstat.1 | 3 ++-<br>
&gt;=C2=A0 2 files changed, 8 insertions(+), 3 deletions(-)<br>
&gt; <br>
&gt; diff --git a/usr.bin/sockstat/main.c b/usr.bin/sockstat/main.c<br>
&gt; index f0eb83eb3e9f..7fedfd5b8724 100644<br>
&gt; --- a/usr.bin/sockstat/main.c<br>
&gt; +++ b/usr.bin/sockstat/main.c<br>
&gt; @@ -103,6 +103,7 @@ static bool=C2=A0 opt_u;=C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0/* Show Unix domain sockets */<br>
&gt;=C2=A0 static u_int=C2=A0 =C2=A0 opt_v;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0/* Verbose mode */<br>
&gt;=C2=A0 static bool=C2=A0 =C2=A0 =C2=A0opt_w;=C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0/* Automatically size the columns */<br>
&gt;=C2=A0 static bool=C2=A0 =C2=A0 =C2=A0is_xo_style_encoding;<br>
&gt; +static bool=C2=A0 =C2=A0 =C2=A0show_path_state =3D false;<br>
&gt; <br>
&gt;=C2=A0 /*<br>
&gt;=C2=A0 =C2=A0* Default protocols to use if no -P was defined.<br>
&gt; @@ -584,6 +585,7 @@ gather_sctp(void)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 !(local_all_=
loopback ||<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 foreign_all_=
loopback))) {<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0RB_INSERT(socks_t, &amp;socks, sock);<br>
&gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0show_=
path_state =3D true;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0} else {<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0free_socket(sock);<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br>
&gt; @@ -1485,7 +1487,7 @@ display_sock(struct sock *s, struct col_widths *=
cw, char *buf, size_t bufsize)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0} else if (!is_xo_style_encoding)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0xo_emit(&quot; {:encaps/%*s=
}&quot;, cw-&gt;encaps, &quot;??&quot;);<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br>
&gt; -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (opt_s) {<b=
r>
&gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (opt_s &amp=
;&amp; show_path_state) {<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0if (faddr !=3D NULL &amp;&amp;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s-&gt;proto =3D=3D IPPROTO_SCTP &amp;&amp=
;<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0s-&gt;state !=3D SCTP_CLOSED &amp;&amp;<b=
r>
&gt; @@ -1632,7 +1634,9 @@ display(void)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (opt_U=
)<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0xo_emit(&quot; {T:/%*s}&quot;, cw.encaps, &quot;ENCAPS&=
quot;);<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (opt_s=
) {<br>
&gt; -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0xo_emit(&quot; {T:/%-*s}&quot;, cw.path_state, &quot;PATH STA=
TE&quot;);<br>
&gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0if (show_path_state)<br>
&gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0xo_emit(&quot; {T:/%-*s}&quot;, c=
w.path_state,<br>
&gt; +=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0=
 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0&quot;PATH STATE&qu=
ot;);<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0 =C2=A0 =C2=A0xo_emit(&quot; {T:/%-*s}&quot;, cw.conn_state, &quot;CO=
NN STATE&quot;);<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0}<br>
&gt;=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0if (opt_b=
)<br>
&gt; diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1=
<br>
&gt; index dabb3042bfd4..d14eb967ad0f 100644<br>
&gt; --- a/usr.bin/sockstat/sockstat.1<br>
&gt; +++ b/usr.bin/sockstat/sockstat.1<br>
&gt; @@ -25,7 +25,7 @@<br>
&gt;=C2=A0 .\&quot; (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY =
OUT OF THE USE OF<br>
&gt;=C2=A0 .\&quot; THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SU=
CH DAMAGE.<br>
&gt;=C2=A0 .\&quot;<br>
&gt; -.Dd October 7, 2025<br>
&gt; +.Dd October 9, 2025<br>
&gt;=C2=A0 .Dt SOCKSTAT 1<br>
&gt;=C2=A0 .Os<br>
&gt;=C2=A0 .Sh NAME<br>
&gt; @@ -205,6 +205,7 @@ is specified (only for SCTP or TCP).<br>
&gt;=C2=A0 The path state if<br>
&gt;=C2=A0 .Fl s<br>
&gt;=C2=A0 is specified (only for SCTP).<br>
&gt; +This column is only shown when there is at least one path state shown=
.<br>
&gt;=C2=A0 .It Li CONN STATE<br>
&gt;=C2=A0 The connection state if<br>
&gt;=C2=A0 .Fl s<br>
<br>
</blockquote></div></div>

--00000000000047068c0640bf9c22--



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