aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/netstat
Commit message (Collapse)AuthorAgeFilesLines
* netstat(1): Add nexthop statistics support with -os flagPouria Mousavizadeh Tehrani2 hours4-4/+88
| | | | | | | | Add support nexthop statistics and update its manual. While here, fix manual of other nexthop related options. Reviewed by: kfv Differential Revision: https://reviews.freebsd.org/D58538
* netlink: Parse repeated nested attributesKevin Bowling41 hours1-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | Modern Netlink arrays encode their elements as repeated attributes of the same type rather than as children of an additional array container. Add an SNL callback that parses one nested element for each occurrence and appends it to a geometrically grown parser array. Retain the existing parray callback for protocols that use the legacy container form. Store the growth capacity in struct snl_parray, appended after its existing public count and items fields so their offsets remain stable on LP64 and ILP32. Require parser targets to be real snl_parray objects, and convert bitset, generic Netlink, and route multipath arrays accordingly. This avoids relying on layout aliases for private growth state. Add regression coverage for a nested bit array that grows beyond its initial allocation, while preserving replacement semantics when a legacy array target is reused. Reviewed by: melifaro, pouria Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D58775
* netstat(1): Emit nhop flags for encoding styles with WflagPouria Mousavizadeh Tehrani2026-07-281-3/+4
| | | | | | | | | Show nhop flags like invalid nexthop to debug cases like the PR below. PR: 296883 Reviewed by: glebius Differential Revision: https://reviews.freebsd.org/D58347
* netstat(1): Show metric value for routesPouria Mousavizadeh Tehrani2026-05-204-9/+17
| | | | | | | | | | | Add metric support and show its value in wide flag and libxo output. Also, add metric to the description of wide flag (`-w`) in routing display (`-r`) section of manual page. Reviewed by: markj (manpage) Discussed with: markj Differential Revision: https://reviews.freebsd.org/D57011
* netstat: Add -F support for -gBojan Novković2026-04-072-1/+14
| | | | | | | | | | | | This change adds the ability to examine the contents of multicast routing tables for other FIBs without the need for executing `netstat` with `setfib(1)`. MFC after: 3 days Sponsored by: Klara, Inc. Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D56205 Reviewed by: glebius, markj, zlei
* netstat(1): '-w': Banners to appear before a new statistics line, not afterOlivier Certner2026-04-073-75/+91
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recurring banners except the first are printed just after the latest interval's statistics line, giving the false impression that the latter are omitted. It is also better to print a new banner only if it is going to be followed by a new line of statistics, in case netstat(1) is interrupted or we have reached the number of iterations specified by '-q'. Fix this by pushing printing these banners inside the loop producing statistics lines, after having waited for the next interval. The first banner is printed before the loop, as we want it to be printed immediately at launch, even if at this point we do not have statistics to display (we have to wait for an interval to compute these, as they are based on a difference). While here, remove the 'goto' spaghetti by putting banner printing into its own private function and using a proper infinite loop in sidewaysintpr(). While here, document the why of the 21 statistics line span between two banners. While here, check for the number of output lines of statistics once such a line has effectively been printed. This allows to remove the internal incrementation performed when reading '-w''s argument, which was a hack to compensate the misplaced check. While here, in the manual page, simplify the description of the '-w' mode and mention that passing 0 to '-q' means "no count limit". Reviewed by: glebius Fixes: 84c1edcbad7d ("Rewrite netstat/if.c to use ...") Fixes: bf10ffe1d3a9 ("Add a new option, -q howmany, ...") MFC after: 1 week Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D56227
* netstat(1): Fix expire column in -r flag using netlinkPouria Mousavizadeh Tehrani2026-02-261-2/+3
| | | | | | Reviewed by: glebius MFC after: 3 weeks Differential Revision: https://reviews.freebsd.org/D55440
* netstat: Fix whitespace in libxo output for multicast routesMark Johnston2026-01-302-13/+11
| | | | | | | | | | Also fix some bogus libxo format strings in mroute6.c, and close a couple of lists instead of opening them twice. Fixes: ade9ccfe211a ("Convert netstat to use libxo.") MFC after: 2 weeks Sponsored by: Stormshield Sponsored by: Klara, Inc.
* netstat: fix typoMichael Tuexen2026-01-181-1/+1
| | | | MFC after: 3 days
* netstat: Remove padding from cc and stack fieldsJohan Söllvander2026-01-151-2/+2
| | | | | | | | | | | | | | Trim white space padding that gets added libxo fields cc and stack when using -C and -c. The padding is only visible if you're using multiple stacks or congestion algorithms. PR: 292262 MFC after: 5 days Reviewed by: asomers, tuexen Approved by: asomers (mentor) Differential Revision: https://reviews.freebsd.org/D54709
* netstat: fix a segfault with --libxoAlan Somers2026-01-071-6/+5
| | | | | | | | | | | | | | Fix a segfault when printing the "protocol" field. The field-format and encoding-format were expecting different numbers of arguments. Also, fix the width of the tcp-state field in encoded output. PR: 292228 Fixes: c2b08c13c20 netstat: add support for UDP-Lite endpoints MFC after: 1 week Sponsored by: ConnectWise Reviewed by: tuexen, js, des Differential Revision: https://reviews.freebsd.org/D54567
* netstat: add support for UDP-Lite endpointsMichael Tuexen2025-10-232-11/+30
| | | | | | | | With this patch UDP-Lite endpoints are also shown per default. Reviewed by: Nick Banks MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D53252
* netstat: Fix -ia missing multicast addresses on some interfacesNick Reilly2025-10-031-1/+2
| | | | | | | | | | sdl_data isn't always NULL terminated Signed-off-by: nreilly@qnx.com PR: 288958 Reviewed by: markj MFC after: 1 week
* pf: Add pfsync protocol for FreeBSD 15Kajetan Staszkiewicz2025-09-231-4/+8
| | | | | | | | | | | | A new version of pfsync packet is introduced: 1500. This version solves the issues with data alignment introduced in version 1400 and adds syncing of information needed to sync states created by rules with af-to (original interface, af and proto separate for wire and stack keys), of rt_af needed for prefer-ipv6-nexthop, and of tag names. Reviewed by: kp Sponsored by: InnoGames GmbH Differential Revision: https://reviews.freebsd.org/D52176
* netstat: improve output for tcp statsMichael Tuexen2025-09-011-4/+9
| | | | | | | | | | Put SYN-cookie related counters in its own container and use consistent indentation for them. Reviewed by: glebius MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D52227
* netstat: improve statistic output for sctpMichael Tuexen2025-08-261-0/+8
| | | | | | | Provide counters for receive and transmit checksum offloading for SCTP. MFC after: 1 week
* netstat: report undelivered multi and broadcast UDP packets correctlyMichael Tuexen2025-08-131-4/+7
| | | | | | | | | | | | | | 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
* netstat: remove unneeded castMichael Tuexen2025-08-121-1/+1
| | | | | | | | delivered is already an uint64_t, so no need to cast it to that type. MFC after: 1 week Sponsored by: Netflix, Inc.
* netstat: fix reporting of delivered UDP packetsMichael Tuexen2025-08-121-1/+0
| | | | | | | | | | | The counter udps_noport includes udps_noportbcast, so don't subtract udps_noportbcast twice. PR: 288680 Reviewed by: rrs MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D51870
* manpages: prefer linking to xo_options.7 over xo_parse_args.3Alan Somers2025-07-161-3/+3
| | | | | | | | | | | | | | | Most libxo-enabled utilities link to xo_parse_args.3. But that man page doesn't actually describe how to format command-line arguments. Rather, xo_options.7 does. I suspect that these utilities link to the former because the latter man page did not exist until libxo-0.7.2 (8a6eceff3ce). And newer utilities have probably been copy/pasting the same text from older ones. But the superior man page does exist now, so we should link to it instead. MFC after: 2 weeks Sponsored by: ConnectWise Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D51354
* netstat.1: Add common example to list listening socketsLukas Engelhardt2025-07-131-14/+16
| | | | | | | While here, wrap to 80 characters. Approved by: ziaee Differential Revision: https://reviews.freebsd.org/D51280
* tcp: count two previously ignored kinds of syncookie failuresGleb Smirnoff2025-06-171-1/+5
| | | | | Reviewed by: tuexen Differential Revision: https://reviews.freebsd.org/D50899
* Don't include netinet/tcp_timer.h when not neededMichael Tuexen2025-06-171-1/+0
| | | | | | | Reviewed by: glebius MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D50889
* netstat(1): add description for option -o and -O.K Rin2025-04-301-1/+33
| | | | | | | | Reviewed by: kevans, ziaee, ivy Approved by: kevans (mentor) Fixes: fedeb08b6a58 ("Introduce scalable route multipath.") Fixes: a666325282ea ("Introduce nexthop objects and new routing KPI.") Pull Request: https://github.com/freebsd/freebsd-src/pull/1643
* netstat: fix table header alignment for -xMichael Tuexen2025-04-211-1/+1
| | | | | | | | | | Add a missing space before R-HIWA to align the table header with the table contents. Reviewed by: rrs, cc MFC after: 3 days Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D49941
* netstat: strip the binary of sgidKyle Evans2025-04-202-14/+2
| | | | | | | | | | Everything in the live path seems to use sysctls these days, with kvm only being used for pulling information from core dumps. Strip the binary of /dev/{k,}mem access to reduce the surface area with access to kmem. Reviewed by: glebius, markj Differential Revision: https://reviews.freebsd.org/D47210
* netstat: Use bool more widelyEd Maste2025-02-042-67/+67
| | | | | | | | | | Following c2aa91745e87 ("netstat: restore printing the "default" keyword, provide -nn option"), consistently use bool where appropriate for commandline flags. Reviewed by: glebius Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D48832
* netstat: restore printing the "default" keyword, provide -nn optionGleb Smirnoff2025-02-034-8/+15
| | | | | | | | | | | | | | | Avoid POLA breakage and preserve output standard that really predates the FreeBSD project itself. There are scripts in the wild that rely on the behavior. Provide option to specify -nn twice to have a completely numeric output of the routing tables. Fixes: 9206c79961986c2114a9a2cfccf009ac010ad259 This reverts commit e090646d6f5a4a6848ecd4bcb1f2db498ea3b3e2. Reviewed by: zlei, gallatin, melifaro, allanjude, markj, emaste Differential Revision: https://reviews.freebsd.org/D48729
* protosw: this is a kernel only header, put back #ifdef _KERNELGleb Smirnoff2025-02-031-0/+1
| | | | | | | | | | The uncommented #ifdef _KERNEL originates from 1997 by wollman@ (see 57bf258e3dc9e) with no clear original reason. Since these old times two abusers of the header leak were created - libprocstat(3) and netstat(1). These two already have a lot of _WANT_FOO hacks, so satisfy them with _WANT_PROTOSW. While here, cleanup and sort forward declaraions.
* netstat: cleanup includes in mroute6.cGleb Smirnoff2025-02-031-2/+1
| | | | | | The file obtains some kernel structures in a dirty way and needs forward declaration of struct sockopt for that. Make it explicit instead of getting it via headers that were not designed for that.
* usr.bin/netstat: -n should not print symbolic namesAllan Jude2024-11-261-2/+3
| | | | | | | | | | | | | | | | | | | | In numeric mode, the default route is printed as "default" rather than 0.0.0.0/0 or ::/0 From the man page: "-n: Show network addresses and ports as numbers. Normally netstat attempts to resolve addresses and ports, and display them symbolically. If the -n option is specified, the address is printed numerically, according to the address family. For more information regarding the Internet IPv4 ``dot format'', refer to inet(3). Unspecified, or `wildcard'', addresses and ports appear as `*''." Reported By: rgrimes Reviewed by: emaste, ngie, eadler, seanc Relnotes: yes Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D10320
* netstat: switch to using the sysctl-exported stats for live statsKyle Evans2024-10-242-10/+5
| | | | | | | | | | | | | | | | | Now that we export the relevant stats via the net.route.stats sysctl, switch to using that to avoid having to dig around in mem(4) for live kernel statistics. Based on callers of kresolve_list(), this is the last live path using mem(4) that could be functional today. Tested both with `netstat -rs` and `netstat -rs -M`. Note that this will not be able to extract stats from a running kernel that predates 3360a15898 / 1500026, but this can be worked around by specifying `-M /dev/mem` explicitly in the interim to fallback to libkvm against /dev/mem. Reviewed by: glebius, markj, zlei Differential Revision: https://reviews.freebsd.org/D47231
* netstat(1): Complete libxo transitionYan-Hao Wang2024-10-1217-109/+103
| | | | | | Reviewed by: des MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D41427
* Revert "netstat: Resolve duplicate "dropped-packets" key from libxo output"Warner Losh2024-09-221-8/+2
| | | | | | | | | | | This reverts commit 94567c8641e235763b5b2926416d89d36654cde1. This breaks normal netstat output. It's kinda tricky to do a quick fix on, so revert this until that can be fixed. If via github, please open a new pull request... Sponsored by: Netflix Pull Request: https://github.com/freebsd/freebsd-src/pull/1331
* netstat: Add missing "shutdown-ack-timer" key to libxo outputBram2024-09-202-3/+3
| | | | | | | | | The key "shutdown-timer" was present twice in the libxo output. The second occurence of "shutdown-time" has been renamed to "shutdown-ack-timer". PR: 254672 Reviewed by: imp, zlei Pull Request: https://github.com/freebsd/freebsd-src/pull/1331
* netstat: Resolve duplicate "dropped-packets" key from libxo outputBram2024-09-201-2/+8
| | | | | | | | | | | The current libxo output uses the "dropped-packets" key for both incoming and outgoing packets. This commit distinguishes between the two by adding an "in" and "out" suffix. The original "dropped-packets" key is kept for backwards compatibility for now. PR: 244589 Reviewed by: imp, zlei Pull Request: https://github.com/freebsd/freebsd-src/pull/1331
* netstat: Add version information to libxo outputBram2024-09-062-0/+9
| | | | | | | | Add version information to libxo output so that libxo content consumers can track changes. Reviewed by: imp, markj Pull Request: https://github.com/freebsd/freebsd-src/pull/1350
* netstat.1: Clarify -d argumentBram2024-07-291-3/+3
| | | | | | | | | | | The man page states that the -d flag can be used to show the dropped packets. But, the number of dropped input packets are always shown, independent of the -d flag. This commit clarifies that the -d flag will add the number of dropped output packets to the output. MFC after: 3 days Reviewed by: imp, Alexander Ziaee Pull Request: https://github.com/freebsd/freebsd-src/pull/1332
* tcp: improve SEG.ACK validationMichael Tuexen2024-07-211-2/+6
| | | | | | | | | | | | | | | Implement the improved SEG.ACK validation described in RFC 5961. In addition to that, also detect ghost ACKs, which are ACKs for data that has never been sent. The additional checks are enabled by default, but can be disabled by setting the sysctl-variable net.inet.tcp.insecure_ack to a non-zero value. PR: 250357 Reviewed by: Peter Lei, rscheff (older version) MFC after: 1 week Sponsored by: Netflix, Inc. Differential Revision: https://reviews.freebsd.org/D45894
* Remove residual blank line at start of MakefileWarner Losh2024-07-151-1/+0
| | | | | | | This is a residual of the $FreeBSD$ removal. MFC After: 3 days (though I'll just run the command on the branches) Sponsored by: Netflix
* netstat(8): for -W, use IFNAMSIZLexi Winter2024-05-162-2/+2
| | | | | | | | If -W is specified, use IFNAMSIZ as the width of the Netif column, instead of the default 12. Reviewed by: imp,zlei,Mina Galić Pull Request: https://github.com/freebsd/freebsd-src/pull/1223
* netstat(1): increase width of Netif columnLexi Winter2024-05-162-6/+4
| | | | | | | | | | | | | | | | | The previous width of Netif (10 or 8) was too short for modern interface names; make it 12, which is long enough to display "epair0a.1000". This came up in practice with genet(4) interfaces, since the base interface name is long enough that with the previous limit, VLAN identifiers would be truncated at 1 character in the IPv6 output: "genet0.100" becomes "genet0.1". The width is now fixed, and doesn't depend on the address family, because there's no reason that length of the interface name would vary based on the AF. Reviewed by: imp,zlei,Mina Galić Pull Request: https://github.com/freebsd/freebsd-src/pull/1223
* tcp: add counter to track when SACK loss recovery uses TSORichard Scheffenegger2024-05-081-3/+5
| | | | | | | | | | | Add a counter to track how frequently SACK has transmitted more than one MSS using TSO. Instances when this will be beneficial is the use of PRR, or when ACK thinning due to GRO/LRO or ACK discards by the network are present. Reviewed By: tuexen, #transport Sponsored by: NetApp, Inc. Differential Revision: https://reviews.freebsd.org/D45070
* pflow: netstat statisticsKristof Provost2024-01-164-0/+30
| | | | | | | Expose pflow counters via netstat. Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D43107
* usr.bin: Automated cleanup of cdefs and other formattingWarner Losh2023-11-2715-40/+0
| | | | | | | | | | | | | | | | Apply the following automated changes to try to eliminate no-longer-needed sys/cdefs.h includes as well as now-empty blank lines in a row. Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/ Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/ Remove /\n+#if.*\n#endif.*\n+/ Remove /^#if.*\n#endif.*\n/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/ Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/ Sponsored by: Netflix
* Remove copyright strings ifdef'd outWarner Losh2023-11-271-10/+0
| | | | | | | | | | | We've ifdef'd out the copyright strings for some time now. Go ahead and remove the ifdefs. Plus whatever other detritis was left over from other recent removals. These copyright strings are present in the comments and are largely from CSRG's attempt at adding their copyright to every binary file (which modern interpretations of the license doesn't require). Sponsored by: Netflix
* usr.bin: Remove ancient SCCS tags.Warner Losh2023-11-2716-41/+0
| | | | | | | | Remove ancient SCCS tags from the tree, automated scripting, with two minor fixup to keep things compiling. All the common forms in the tree were removed with a perl script. Sponsored by: Netflix
* netstat: fix missing tab in icmp6 outputKristof Provost2023-11-121-1/+1
| | | | | | | PR: 275044 Submitted by: sigsys@gmail.com Reviewed by: kp MFC after: 1 week
* Remove $FreeBSD$: one-line nroff patternWarner Losh2023-08-161-1/+0
| | | | Remove /^\.\\"\s*\$FreeBSD\$$\n/
* Remove $FreeBSD$: one-line sh patternWarner Losh2023-08-164-4/+0
| | | | Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/