git: 2b068d35de84 - main - netstat: report undelivered multi and broadcast UDP packets correctly
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 13 Aug 2025 07:00:22 UTC
The branch main has been updated by tuexen:
URL: https://cgit.FreeBSD.org/src/commit/?id=2b068d35de84975ea4b04a19413786663a51dc70
commit 2b068d35de84975ea4b04a19413786663a51dc70
Author: Michael Tuexen <tuexen@FreeBSD.org>
AuthorDate: 2025-08-13 06:57:04 +0000
Commit: Michael Tuexen <tuexen@FreeBSD.org>
CommitDate: 2025-08-13 06:57:04 +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
MFC after: 1 week
Sponsored by: Netflix, Inc.
Differential Revision: https://reviews.freebsd.org/D51881
---
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 3c4d6d4b62f9..7014f02032c2 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -904,7 +904,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)
@@ -937,8 +937,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} "
@@ -951,7 +954,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} "