summaryrefslogtreecommitdiff
path: root/usr.bin/netstat/mroute.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix netstat -gs with ip_mroute module and/or vnetMike Karels2019-11-121-6/+4
| | | | | | | | | | | | | | | | | | | | The code for "netstat -gs -f inet" failed if the kernel namelist did not include the _mrtstat symbol. However, that symbol is not in a standard kernel even with the ip_mroute module loaded, where the functionality is available. It is also not in a kernel with MROUTING but also VIMAGE, as there can be multiple sets of stats. However, when running the command on a live system, the symbol is not used; a sysctl is used. Go ahead and try the sysctl in any case, and complain that IPv4 MROUTING is not present only if the sysctl fails with ENOENT. Also fail if _mrtstat is not defined when running on a core file; netstat doesn't know about vnets, so can only work if MROUTING was included, and VIMAGE was not. Reviewed by: bz MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22311 Notes: svn path=/head/; revision=354633
* spdx: initial adoption of licensing ID tags.Pedro F. Giffuni2017-11-181-0/+2
| | | | | | | | | | | | | | | | | | | | The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Special thanks to Wind River for providing access to "The Duke of Highlander" tool: an older (2014) run over FreeBSD tree was useful as a starting point. Initially, only tag files that use BSD 4-Clause "Original" license. RelNotes: yes Differential Revision: https://reviews.freebsd.org/D13133 Notes: svn path=/head/; revision=325966
* Use strlcpy and snprintf in netstat(1).Xin LI2017-01-051-10/+14
| | | | | | | | | | | | Expand inet6name() line buffer to NI_MAXHOST and use strlcpy/snprintf in various places. Reported by: Anton Yuzhaninov <citrin citrin ru> MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D8916 Notes: svn path=/head/; revision=311392
* Use a common subroutine to fetch and zero protocol stats instead ofMark Johnston2015-09-111-9/+3
| | | | | | | | | duplicating roughly similar code for each protocol. MFC after: 2 weeks Notes: svn path=/head/; revision=287649
* Simplify kvm symbol resolution and error handling. The symbol tableHiroki Sato2015-09-021-22/+5
| | | | | | | | nl_symbols will eventually be organized into several modules depending on MK_* variables. Notes: svn path=/head/; revision=287407
* - Add -W flag support for network column in intpr() (-i flag) andHiroki Sato2015-09-011-4/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | routepr() (-r flag). It is too narrow to show an IPv6 prefix in most cases. - Accept "local" as a synonym of "unix" in protocol family name. - Show a prefix length in CIDR notation when name resolution failed in netname(). - Make routename() and netname() AF-independent and remove unnecessary typecasting from struct sockaddr. - Use getnameinfo(3) to format L2 addr in intpr(). - Fix a bug which showed "Address" when -A flag is specfied in pr_rthdr(). - Replace cryptic GETSA() macro with SA_SIZE(). - Fix declarations shadowing local variables with the same names. - Add more static, remove unused header files and variables. MFC after: 1 week Notes: svn path=/head/; revision=287351
* Convert netstat to use libxo.Marcel Moolenaar2015-02-211-81/+126
| | | | | | | | | | Obtained from: Phil Shafer <phil@juniper.net> Ported to -current by: alfred@ (mostly), Kim Shrier Formatting: marcel@ Sponsored by: Juniper Networks, Inc. Notes: svn path=/head/; revision=279122
* Fix "netstat -gW" behavior broken in r259638.Alexander V. Chernikov2014-04-291-11/+13
| | | | | | | | | | | | | | | | netstat has two options for printing multicast tables: sysctl (the default one for live systems) and kvm-based one (for cores). It looks like kvm-based one hasn't been working since it's been introduced in r190012 due to absence of mfctablesize kernel symbol. Check for all ipv4-multicast symbols being correctly resolved was introduced in r259638 regardless of 'live' value leading to "No IPv4 MROUTING" error message. Reported by: Olivier Cochard-Labbé MFC after: 1 week Notes: svn path=/head/; revision=265096
* Use more fine-grained kvm(3) symbol lookup: routing code retrieves onlyAlexander V. Chernikov2013-12-201-4/+39
| | | | | | | | | | | | | | necessary symbols needed per subsystem. Main kvm(3) init is now delayed as much as possbile. This finally fixes performance issues reported in kern/167204. Some non-working code (ng_socket.ko symbol addresses calculation) removed. Some global variables eliminated. PR: kern/167204 MFC after: 4 weeks Notes: svn path=/head/; revision=259638
* Migrate structs arpstat, icmpstat, mrtstat, pimstat and udpstat to PCPUAndrey V. Elsukov2013-07-091-1/+1
| | | | | | | counters. Notes: svn path=/head/; revision=253084
* Prepare network statistics structures for migration to PCPU counters.Andrey V. Elsukov2013-07-091-15/+15
| | | | | | | | | | | | | Use uint64_t as type for all fields of structures. Changed structures: ahstat, arpstat, espstat, icmp6_ifstat, icmp6stat, in6_ifstat, ip6stat, ipcompstat, ipipstat, ipsecstat, mrt6stat, mrtstat, pfkeystat, pim6stat, pimstat, rip6stat, udpstat. Discussed with: arch@ Notes: svn path=/head/; revision=253081
* Bracket struct mfc and struct rtdetq with #ifdef _KERNEL.Bruce M Simpson2009-04-211-0/+3
| | | | | | | | | | | | | Match the bracketing in netstat. Since the cleanup of MROUTING, ports have broken because they expect to include <netinet/ip_mroute.h> without including <sys/queue.h>. Fix breakage at source. The real fix, of course, is to fix the MROUTING APIs by blowing them away and replacing them with something else... Notes: svn path=/head/; revision=191356
* Fix size_t merge-o.Bruce M Simpson2009-03-191-1/+1
| | | | Notes: svn path=/head/; revision=190024
* Introduce a number of changes to the MROUTING code.Bruce M Simpson2009-03-191-117/+189
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is purely a forwarding plane cleanup; no control plane code is involved. Summary: * Split IPv4 and IPv6 MROUTING support. The static compile-time kernel option remains the same, however, the modules may now be built for IPv4 and IPv6 separately as ip_mroute_mod and ip6_mroute_mod. * Clean up the IPv4 multicast forwarding code to use BSD queue and hash table constructs. Don't build our own timer abstractions when ratecheck() and timevalclear() etc will do. * Expose the multicast forwarding cache (MFC) and virtual interface table (VIF) as sysctls, to reduce netstat's dependence on libkvm for this information for running kernels. * bandwidth meters however still require libkvm. * Make the MFC hash table size a boot/load-time tunable ULONG, net.inet.ip.mfchashsize (defaults to 256). * Remove unused members from struct vif and struct mfc. * Kill RSVP support, as no current RSVP implementation uses it. These stubs could be moved to raw_ip.c. * Don't share locks or initialization between IPv4 and IPv6. * Don't use a static struct route_in6 in ip6_mroute.c. The v6 code is still using a cached struct route_in6, this is moved to mif6 for the time being. * More cleanup remains to be merged from ip_mroute.c to ip6_mroute.c. v4 path tested using ports/net/mcast-tools. v6 changes are mostly mechanical locking and *have not* been tested. As these changes partially break some kernel ABIs, they will not be MFCed. There is a lot more work to be done here. Reviewed by: Pavlin Radoslavov Notes: svn path=/head/; revision=190012
* style(9)David E. O'Brien2008-01-021-4/+4
| | | | | | | | | | + kread is not a boolean, so check it as such + fix $FreeBSD$ Ids + denote copyrights with /*- + misc whitespace changes. Notes: svn path=/head/; revision=175061
* Restore netstat -M functionality for most statistics on core dumps. InJohn Baldwin2007-07-161-27/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | general, when support was added to netstat for fetching data using sysctl, no provision was left for fetching equivalent data from a core dump, and in fact, netstat would _always_ fetch data from the live kernel using sysctl even when -M was specified resulting in the user believing they were getting data from coredumps when they actually weren't. Some specific changes: - Add a global 'live' variable that is true if netstat is running against the live kernel and false if -M has been specified. - Stop abusing the sysctl flag in the protocol tables to hold the protocol number. Instead, the protocol is now its own field in the tables, and it is passed as a separate parameter to the PCB and stat routines rather than overloading the KVM offset parameter. - Don't run PCB or stats functions who don't have a namelist offset if we are being run against a crash dump (!live). - For the inet and unix PCB routines, we generate the same buffer from KVM that the sysctl usually generates complete with the header and trailer. - Don't run bpf stats for !live (before it would just silently always run live). - kread() no longer trashes memory when opening the buffer if there is an error on open and the passed in buffer is smaller than _POSIX2_LINE_MAX. - The multicast routing code doesn't fallback to kvm on live kernels if the sysctl fails. Keeping this made the code rather hairy, and netstat is already tied to the kernel ABI anyway (even when using sysctl's since things like xinpcb contain an inpcb) so any kernels this is run against that have the multicast routing stuff should have the sysctls. - Don't try to dig around in the kernel linker in the netgraph PCB routine for core dumps. Other notes: - sctp's PCB routine only works on live kernels, it looked rather complicated to generate all the same stuff via KVM. Someone can always add it later if desired though. - Fix the ipsec removal bug where N_xxx for IPSEC stats weren't renumbered. - Use sysctlbyname() everywhere rather than hardcoded mib values. MFC after: 1 week Approved by: re (rwatson) Notes: svn path=/head/; revision=171465
* Use the names 'IPv4' and 'Forwarding Table' in program output, notBruce M Simpson2007-02-241-4/+4
| | | | | | | 'Routing Table', to be consistent with what the code actually does and is. Notes: svn path=/head/; revision=166951
* Add comments about where netstat is using KVM to read things whichBruce M Simpson2007-02-241-1/+3
| | | | | | | should really be available via sysctl for a running system. Notes: svn path=/head/; revision=166950
* Change wording of warnings when there is no ip_mroute.ko moduleBruce M Simpson2007-02-211-7/+12
| | | | | | | | | | | loaded into the system. Change wording of comments to reflect the fact we should unconditionally use KVM if the -M option is used to specify a core file. Add comments to document the fact that IPv6 multicast forwarding information display still relies on KVM for gathering information. Notes: svn path=/head/; revision=166869
* Nits.Bruce M Simpson2006-09-291-1/+1
| | | | | | | Submitted by: ru Notes: svn path=/head/; revision=162797
* Push removal of mrouted down to the rest of the tree.Bruce M Simpson2006-09-291-1/+1
| | | | Notes: svn path=/head/; revision=162794
* Achieve WARNS=2 by using uintmax_t to pass around 64-bit quantities,Yaroslav Tykhiy2006-07-281-4/+5
| | | | | | | | | | including to printf(). Using uintmax_t is also robust to further extensions in both the C language and the bitwidth of kernel counters. Tested on: i386 amd64 ia64 Notes: svn path=/head/; revision=160787
* Both fields of struct timeval are of a non-basic type,Yaroslav Tykhiy2006-07-281-6/+10
| | | | | | | so we should cast them to a type printf() knows about. Notes: svn path=/head/; revision=160781
* Add __FBSDID. Replace local variable sin by sockin to not conflict with sin(3).Philippe Charnier2004-07-261-4/+2
| | | | | | | | Use warnx() instead of warn() when error message is not of any interest. Add prototypes. Notes: svn path=/head/; revision=132671
* 1. Add support for printing PIM-related statistics withJeffrey Hsu2003-08-071-0/+93
| | | | | | | | | | | | netstat -s -p pim 2. Print information about the bandwidth meters installed in the kernel with netstat -g Submitted by: Pavlin Radoslavov <pavlin@icir.org> Notes: svn path=/head/; revision=118627
* * Use sysctlbyname(3) to print statistics about the MFC andJeffrey Hsu2003-08-051-6/+24
| | | | | | | | | | | | | | | | | multicast VIF tables. This change is needed for consistency with the rest of the netstat/mroute.c implementation, and because in some cases "netstat -g" may fail to report the multicast forwarding information (e.g., if we run a multicast router on PicoBSD). * Remove "DVMRP" from the head comment of file netstat/mroute.c, because the printed multicast-related statistics are not DVMRP-specific anymore. Submitted by: Pavlin Radoslavov <pavlin@icir.org> Notes: svn path=/head/; revision=118502
* Warns cleanups for netstat:David Malone2002-09-051-5/+5
| | | | | | | | | | | | | | 1) Include arpa/inet.h for ntohs. 2) Constness fixes. 3) Fix shadowing except for "sin" which shouldn't be in scope. 4) Remove register keyword. 5) Add missing initialsers to user defined structs. 5) Make prototype of netname6 globally visable. 6) Use right macros for printing syncache stats (even though entrie isn't a word). Notes: svn path=/head/; revision=102975
* If -s -s is specified, don't show zero multicast routing statistics.Ruslan Ermilov2001-09-071-26/+23
| | | | Notes: svn path=/head/; revision=83204
* Use sysctl to export multicast routing statsBill Fenner2001-07-251-5/+13
| | | | Notes: svn path=/head/; revision=80351
* remove K&R supportAssar Westerlund2001-06-151-4/+2
| | | | Notes: svn path=/head/; revision=78314
* revert removal of warning and K&R supportAssar Westerlund2001-06-151-2/+4
| | | | | | | Requested by: bde Notes: svn path=/head/; revision=78309
* remove most of the warningsAssar Westerlund2001-06-151-4/+2
| | | | Notes: svn path=/head/; revision=78245
* add the option -S for printing port numbers symbolically but addressesAssar Westerlund2001-06-151-4/+4
| | | | | | | numerically. clean up the CFLAGS in Makefile. Notes: svn path=/head/; revision=78238
* sync with latest kame netstat. basically, more statisticsJun-ichiro itojun Hagino2000-07-041-4/+3
| | | | Notes: svn path=/head/; revision=62584
* IPv6 multicast routing.Yoshinobu Inoue2000-01-281-1/+1
| | | | | | | | | | | | | | | | kernel IPv6 multicast routing support. pim6 dense mode daemon pim6 sparse mode daemon netstat support of IPv6 multicast routing statistics Merging to the current and testing with other existing multicast routers is done by Tatsuya Jinmei <jinmei@kame.net>, who writes and maintainances the base code in KAME distribution. Make world check and kernel build check was also successful. Notes: svn path=/head/; revision=56722
* Cleanup towards -WallJulian Elischer1999-10-211-1/+6
| | | | Notes: svn path=/head/; revision=52415
* Don't use ip_mrtproto to determine whether multicast routing is inBill Fenner1999-01-181-66/+19
| | | | | | | | | | | the kernel; this was left over from the earlier protocol-dependent kernel multicast routing code. Learn how to handle the malloc'd multicast routing table (instead of expecting it to be in mbufs) Notes: svn path=/head/; revision=42778
* Update to match changes in <net/if.h> and <netinet/ip_mroute.h>.Garrett Wollman1997-01-031-2/+0
| | | | Notes: svn path=/head/; revision=21263
* Fix up programs which expect <net/if.h> to include <sys/time.h> to insteadGarrett Wollman1996-12-101-0/+1
| | | | | | | | | do it themselves. (Some of these programs actually depended on this beyond compiling the definition of struct ifinfo!) Also fix up some other #include messes while we're at it. Notes: svn path=/head/; revision=20287
* Code cleanup: remove unused variables, use correct *printf formatAlexander Langer1996-06-021-16/+15
| | | | | | | | | specifiers (some unsigned values were printed as signed, some longs were printed as ints), and place parentheses around assignments in if statements. Notes: svn path=/head/; revision=16080
* Move #include of queue.h before #include of socketvar.h in preparation forDavid Greenman1996-03-111-0/+1
| | | | | | | struct socket changes. Notes: svn path=/head/; revision=14543
* Merge in Lite-2 changes.Peter Wemm1996-01-141-1/+1
| | | | Notes: svn path=/head/; revision=13430
* Re-write `netstat -g' code to match the 3.5 data structures.Garrett Wollman1995-06-131-49/+47
| | | | Notes: svn path=/head/; revision=9215
* Tell netstat about the new multicast forwarding statistics. For the moment,Garrett Wollman1994-09-081-8/+23
| | | | | | | | don't try to do any multicast forwarding cache printouts; it's not clear that netstat can do anything particularly useful or meaningful. Notes: svn path=/head/; revision=2553
* BSD 4.4 Lite Usr.bin SourcesRodney W. Grimes1994-05-271-0/+222
Notes: svn path=/cvs2svn/branches/CHRISTOS/; revision=1590