git: 72016759dabd - releng/15.0 - netstat: add support for UDP-Lite endpoints
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 28 Oct 2025 01:59:09 UTC
The branch releng/15.0 has been updated by cperciva:
URL: https://cgit.FreeBSD.org/src/commit/?id=72016759dabd203eeaaf47dba534f9df5ce801e4
commit 72016759dabd203eeaaf47dba534f9df5ce801e4
Author: Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2025-10-23 07:15:22 +0000
Commit: Colin Percival <cperciva@FreeBSD.org>
CommitDate: 2025-10-28 01:58:18 +0000
netstat: add support for UDP-Lite endpoints
With this patch UDP-Lite endpoints are also shown per default.
Approved by: re (cperciva)
Reviewed by: Nick Banks
Differential Revision: https://reviews.freebsd.org/D53252
(cherry picked from commit c2b08c13c20d44c3368bcbf738624e5fac461314)
(cherry picked from commit 372b60422689b2bfb2ccf3ab22847eb54dae0b11)
---
usr.bin/netstat/inet.c | 37 ++++++++++++++++++++++++++-----------
usr.bin/netstat/main.c | 4 ++++
2 files changed, 30 insertions(+), 11 deletions(-)
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 5f36b1599cad..dee245b63a87 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -83,7 +83,7 @@ static void inetprint(const char *, struct in_addr *, int, const char *, int,
const int);
#endif
#ifdef INET6
-static int udp_done, tcp_done, sdp_done;
+static int udp_done, udplite_done, tcp_done, sdp_done;
#endif /* INET6 */
static int
@@ -100,6 +100,9 @@ pcblist_sysctl(int proto, const char *name, char **bufp)
case IPPROTO_UDP:
mibvar = "net.inet.udp.pcblist";
break;
+ case IPPROTO_UDPLITE:
+ mibvar = "net.inet.udplite.pcblist";
+ break;
default:
mibvar = "net.inet.raw.pcblist";
break;
@@ -220,13 +223,20 @@ protopr(u_long off, const char *name, int af1, int proto)
return;
else
udp_done = 1;
+#endif
+ break;
+ case IPPROTO_UDPLITE:
+#ifdef INET6
+ if (udplite_done != 0)
+ return;
+ else
+ udplite_done = 1;
#endif
break;
}
if (!pcblist_sysctl(proto, name, &buf))
return;
-
if (istcp && (cflag || Cflag)) {
fnamelen = strlen("Stack");
cnamelen = strlen("CC");
@@ -318,18 +328,18 @@ protopr(u_long off, const char *name, int af1, int proto)
"Proto", "Listen", "Local Address");
else if (Tflag)
xo_emit((Aflag && !Wflag) ?
- "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%s}" :
+ "{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%s}" :
((!Wflag || af1 == AF_INET) ?
- "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%s}" :
- "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%s}"),
+ "{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%s}" :
+ "{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%s}"),
"Proto", "Rexmit", "OOORcv", "0-win",
"Local Address", "Foreign Address");
else {
xo_emit((Aflag && !Wflag) ?
- "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%-18.18s}" :
+ "{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-18.18s} {T:/%-18.18s}" :
((!Wflag || af1 == AF_INET) ?
- "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%-22.22s}" :
- "{T:/%-5.5s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%-45.45s}"),
+ "{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-22.22s} {T:/%-22.22s}" :
+ "{T:/%-9.9s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-45.45s} {T:/%-45.45s}"),
"Proto", "Recv-Q", "Send-Q",
"Local Address", "Foreign Address");
if (!xflag && !Rflag)
@@ -382,9 +392,14 @@ protopr(u_long off, const char *name, int af1, int proto)
vchar = ((inp->inp_vflag & INP_IPV4) != 0) ?
"4" : "";
if (istcp && (tp->t_flags & TF_TOE) != 0)
- xo_emit("{:protocol/%-3.3s%-2.2s/%s%s} ", "toe", vchar);
- else
- xo_emit("{:protocol/%-3.3s%-2.2s/%s%s} ", name, vchar);
+ xo_emit("{:protocol/%-3.3s%-6.6s/%s%s} ", "toe", vchar);
+ else {
+ int len;
+
+ len = max (2, 9 - strlen(name));
+ xo_emit("{:protocol/%.7s%-*.*s/%s%s} ", name, len, len,
+ vchar);
+ }
if (Lflag) {
char buf1[33];
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index e8f657006982..79830049948a 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -83,6 +83,8 @@ static struct protox {
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
{ -1 , N_UDPSTAT, 1, protopr,
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
+ { -1, -1, 1, protopr,
+ NULL, NULL, "udplite", 1, IPPROTO_UDPLITE },
#ifdef SCTP
{ -1, N_SCTPSTAT, 1, sctp_protopr,
sctp_stats, NULL, "sctp", 1, IPPROTO_SCTP },
@@ -131,6 +133,8 @@ static struct protox ip6protox[] = {
tcp_stats, NULL, "tcp", 1, IPPROTO_TCP },
{ -1 , N_UDPSTAT, 1, protopr,
udp_stats, NULL, "udp", 1, IPPROTO_UDP },
+ { -1, -1, 1, protopr,
+ NULL, NULL, "udplite", 1, IPPROTO_UDPLITE },
{ -1 , N_IP6STAT, 1, protopr,
ip6_stats, ip6_ifstats, "ip6", 1, IPPROTO_RAW },
{ -1 , N_ICMP6STAT, 1, protopr,