From nobody Wed Aug 13 07:00:22 2025 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4c1zlp494bz647lv; Wed, 13 Aug 2025 07:00:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4c1zlp38q5z3VLl; Wed, 13 Aug 2025 07:00:22 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755068422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m2GKolM8984pa194/OxsuJKH9oGmy6VJRgY6aSGfOB0=; b=gWQo5U7mSX9J5/Yg1fSILLP/hgb8zpxk8B62r7hAzImM4url0SNhewidh8kP+sxtq/kK3S OERA9+Q1TAUoC/0YPs7IzAr66ATrMnAbWCMypnNHqRPe46JwLFfoqTPwpSedwhQNvW5c1a xCBJ9VO7vqkdAthSlwQ/Kqy+zfV3W+9b6iaCq6Drrf1ikHnE4f2ZkDe3o5uFYwaK18OtSO qIRj9XPmf1+Av8zDrV0yr6lLicIgMfRi+gLih6ttJNM/RcYmn0V2nx7nk0sJE+pbD+usEm qY0WRby+Wtsd1C/Z4Y8Kv3PEOJjBWfKdtTjDioqaj/Kz+2F9nXJdeodCR1jkrg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1755068422; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=m2GKolM8984pa194/OxsuJKH9oGmy6VJRgY6aSGfOB0=; b=xFAXHV1QRJGHjehMcCj5X+CVoRVxR4G5M/uIlpScQ9//qWY8ZGhK/XQnTsoMbtJDdDe3M2 LwZaL5pdiNXUbV1cYJgYpftuycMBq8vR5XzUsxvSbetKWAoSf91lKW3iOsxxExdtkSgj0D 0p84tK0js4EN9QGLd9ODX/0a7Nn3DoGpjSe0Opwgvev0zwz3esonVf3XVynMqz7pHV5Mw6 oSszRsm/di60kS09uCMJmJuEG1E1gGhPpptVs6tZFwO3/sLZpCIXfpkC13XLelYPpl4+Eq NJsQ5h5rHepFnIJUvrRAofo38aT5SLJj2j3rxJQYaNBk1pnc0SDmQrbL4o72Ow== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1755068422; a=rsa-sha256; cv=none; b=sDR+2q2rjZpYc50vmMYEwPxlo7+WFU4zvgxUL46LVsMYYKiM+u++KfkIvFHfLvi6icSIew IME7cZpxa79r8S/SEAbRVWOP8XBgrCuVSwAPfDm+b5L3O1ZjYPggpwoDdNl42R2rovvfo9 YYugjUKZw8AzAcVXyZRCQivL/BQKhfHdUothRScIKRX95HrJCnkkZWAvkRyfpVMCYroZRr ci+DXN8mr6TzDlHgnuvAi1DSoDc3hJtsuraXDcsksKX9fAcvAjGnFPnrcl1dmwtni6CDqE a+8WjU2/dBsnuSTx9gZ3GBjiZFGO221UDdu2jTcLfaybt4y+L23srpL30rklLA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4c1zlp26DTz1BvF; Wed, 13 Aug 2025 07:00:22 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 57D70M3d040858; Wed, 13 Aug 2025 07:00:22 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 57D70Mew040856; Wed, 13 Aug 2025 07:00:22 GMT (envelope-from git) Date: Wed, 13 Aug 2025 07:00:22 GMT Message-Id: <202508130700.57D70Mew040856@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Michael Tuexen Subject: git: 2b068d35de84 - main - netstat: report undelivered multi and broadcast UDP packets correctly List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: tuexen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 2b068d35de84975ea4b04a19413786663a51dc70 Auto-Submitted: auto-generated The branch main has been updated by tuexen: URL: https://cgit.FreeBSD.org/src/commit/?id=2b068d35de84975ea4b04a19413786663a51dc70 commit 2b068d35de84975ea4b04a19413786663a51dc70 Author: Michael Tuexen AuthorDate: 2025-08-13 06:57:04 +0000 Commit: Michael Tuexen 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} "