git: f7a7c2026ccb - stable/14 - sockstat: show path state column only when useful
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 31 Oct 2025 18:36:08 UTC
The branch stable/14 has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=f7a7c2026ccb13f1ae76d1b0b3a2c60faa99e320
commit f7a7c2026ccb13f1ae76d1b0b3a2c60faa99e320
Author: Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2025-10-09 19:16:38 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2025-10-31 13:34:12 +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
(cherry picked from commit 746eadecaa7dc8913721cbaa9be4e603bd36ea49)
---
usr.bin/sockstat/sockstat.1 | 3 ++-
usr.bin/sockstat/sockstat.c | 7 +++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/usr.bin/sockstat/sockstat.1 b/usr.bin/sockstat/sockstat.1
index eba4b1c4aed5..abd83f049703 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
@@ -194,6 +194,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 to show.
.It Li CONN STATE
The connection state if
.Fl s
diff --git a/usr.bin/sockstat/sockstat.c b/usr.bin/sockstat/sockstat.c
index 4548eb8a0b11..afb635179d82 100644
--- a/usr.bin/sockstat/sockstat.c
+++ b/usr.bin/sockstat/sockstat.c
@@ -99,6 +99,7 @@ static int opt_U; /* Show remote UDP encapsulation port number */
static int opt_u; /* Show Unix domain sockets */
static int opt_v; /* Verbose mode */
static int opt_w; /* Wide print area for addresses */
+static bool show_path_state = false;
/*
* Default protocols to use if no -P was defined.
@@ -519,6 +520,7 @@ gather_sctp(void)
((xinpcb->flags & SCTP_PCB_FLAGS_UDPTYPE) ||
(xstcb->last == 1))) {
RB_INSERT(socks_t, &socks, sock);
+ show_path_state = true;
} else {
free_socket(sock);
}
@@ -1296,7 +1298,7 @@ displaysock(struct sock *s, int pos)
}
offset += 7;
}
- if (opt_s) {
+ if (opt_s && show_path_state) {
if (faddr != NULL &&
s->proto == IPPROTO_SCTP &&
s->state != SCTP_CLOSED &&
@@ -1401,7 +1403,8 @@ display(void)
if (opt_U)
printf(" %-6s", "ENCAPS");
if (opt_s) {
- printf(" %-12s", "PATH STATE");
+ if (show_path_state)
+ printf(" %-12s", "PATH STATE");
printf(" %-12s", "CONN STATE");
}
if (opt_b)