git: fd86cd7a7f49 - stable/14 - netstat: report undelivered multi and broadcast UDP packets correctly
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 05 Sep 2025 19:03:37 UTC
The branch stable/14 has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=fd86cd7a7f499358f4402e9963529e3637b508ed
commit fd86cd7a7f499358f4402e9963529e3637b508ed
Author: Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2025-08-13 06:57:04 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2025-09-05 19:02:52 +0000
netstat: report undelivered multi and broadcast UDP packets correctly
When reporting undelivered broadcast/multicast datagrams, don't just
report the undelivered broadcast ones. Actually report the sum of both.
Alternatively, one could also report broadcast and multicast datagrams
separately, but that would change the output format of netstat.
While there, use the correct type for casting a variable printed
with %ju.
Reviewed by: cc
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D51881
(cherry picked from commit 2b068d35de84975ea4b04a19413786663a51dc70)
---
usr.bin/netstat/inet.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 93ce8fd59cb7..363224d5f913 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -905,7 +905,7 @@ void
udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
{
struct udpstat udpstat;
- uint64_t delivered;
+ uint64_t delivered, noportbmcast;
#ifdef INET6
if (udp_done != 0)
@@ -938,8 +938,11 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
"{N:/with no checksum}\n");
p1a(udps_noport, "{:dropped-no-socket/%ju} "
"{N:/dropped due to no socket}\n");
- p(udps_noportbcast, "{:dropped-broadcast-multicast/%ju} "
- "{N:/broadcast\\/multicast datagram%s undelivered}\n");
+ noportbmcast = udpstat.udps_noportmcast + udpstat.udps_noportbcast;
+ if (noportbmcast || sflag <= 1)
+ xo_emit("\t{:dropped-broadcast-multicast/%ju} "
+ "{N:/broadcast\\/multicast datagram%s undelivered}\n",
+ (uintmax_t)noportbmcast, plural(noportbmcast));
p1a(udps_fullsock, "{:dropped-full-socket-buffer/%ju} "
"{N:/dropped due to full socket buffers}\n");
p1a(udpps_pcbhashmiss, "{:not-for-hashed-pcb/%ju} "
@@ -952,7 +955,7 @@ udp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
udpstat.udps_fullsock;
if (delivered || sflag <= 1)
xo_emit("\t{:delivered-packets/%ju} {N:/delivered}\n",
- delivered);
+ (uintmax_t)delivered);
p(udps_opackets, "{:output-packets/%ju} {N:/datagram%s output}\n");
/* the next statistic is cumulative in udps_noportbcast */
p(udps_filtermcast, "{:multicast-source-filter-matches/%ju} "