aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/netstat/main.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r186644: show unix sockets listen queues stats with -L flag.Maxim Konovalov2009-02-111-1/+1
| | | | Notes: svn path=/stable/7/; revision=188479
* MFC:Ruslan Ermilov2009-01-191-5/+6
| | | | | | | | | | - Fix crash with "netstat -m -N foo". PR: bin/124724 - Sync usage() with SYNOPSIS. Notes: svn path=/stable/7/; revision=187431
* bring in bits missed in r187106: sync build infrastructure changes with HEADSam Leffler2009-01-141-2/+8
| | | | | | | Noticed by: attilio Notes: svn path=/stable/7/; revision=187229
* MFC: style(9)David E. O'Brien2008-03-161-28/+28
| | | | Notes: svn path=/stable/7/; revision=177241
* Bah, fix a cosmetic nit and remove a debugging aid missed in the previousJohn Baldwin2007-07-161-2/+1
| | | | | | | | | | fixes for netstat -M. Pointy hat to: jhb Approved by: re (kensmith) Notes: svn path=/head/; revision=171466
* Restore netstat -M functionality for most statistics on core dumps. InJohn Baldwin2007-07-161-83/+134
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Commit IPv6 support for FAST_IPSEC to the tree.George V. Neville-Neil2007-07-011-22/+5
| | | | | | | | | | | This commit includes all remaining changes for the time being including user space updates. Submitted by: bz Approved by: re Notes: svn path=/head/; revision=171135
* Adds support for SCTP.Randall Stewart2007-06-091-0/+4
| | | | Notes: svn path=/head/; revision=170461
* - Achieve WARNS=3 by using sparse initializers or avoiding initializers at all.Yaroslav Tykhiy2006-07-281-44/+44
| | | | | | | | | | | - Fix a nlist initialization: it should be terminated by a NULL entry. - Constify. - Catch an unused parameter. Tested on: i386 amd64 ia64 Notes: svn path=/head/; revision=160789
* Achieve WARNS=2 by using uintmax_t to pass around 64-bit quantities,Yaroslav Tykhiy2006-07-281-4/+4
| | | | | | | | | | 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
* Add support for printing IPSEC protocol stats if the kernel was compiledKelly Yancey2005-12-281-0/+29
| | | | | | | | | | | | | | | | with FAST_IPSEC rather than the KAME IPSEC stack. Note that the output of "netstat -s -p ipsec" differs depending on which stack is compiled into the kernel since they each keep different stats. This delta also adds the "esp", "ah", and "ipcomp" protocol stats, which are also available when the kernel is compiled with the FAST_IPSEC stack (e.g. "netstat -s -p esp"). Submitted by: Matt Titus <titus at nttmcl dot com> MFC after: 3 days Notes: svn path=/head/; revision=153809
* Modify netstat -mb to use libmemstat when accessing a core dump or liveRobert Watson2005-11-131-12/+2
| | | | | | | | | | | | | | | | | | | kernel memory and not using sysctl. Previously, libmemstat was used only for the live kernel via sysctl paths. This results in netstat output becoming both more consistent between core dumps and the live kernel, and also more information in the core dump case than previously (i.e., mbuf cache information). Statistics relating to sfbufs still rely on a kvm descriptor as they are not currently exposed via libmemstat. netstat -m operating on a core is still unable to print certain sfbuf stats available on the live kernel. MFC after: 1 week Notes: svn path=/head/; revision=152378
* Fix obvious copy'n'paste-O in rev.1.36 While here nit style.Max Laier2005-10-221-3/+3
| | | | | | | | | PR: bin/87783 Submitted by: Mats Palmgren MFC after: 1 week Notes: svn path=/head/; revision=151557
* Remove bridge(4) from the tree. if_bridge(4) is a full functionalMax Laier2005-09-271-4/+0
| | | | | | | | | | | replacement and has additional features which make it superior. Discussed on: -arch Reviewed by: thompsa X-MFC-after: never (RELENG_6 as transition period) Notes: svn path=/head/; revision=150636
* Update usage to reflect the new option.Christian S.J. Peron2005-09-071-1/+2
| | | | | | | Pointed out by: ru Notes: svn path=/head/; revision=149866
* Merge bpfstat's functionality into the netstat(1) utility. This addsChristian S.J. Peron2005-09-071-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | a -B option which causes bpf peers to be printed. This option can be used in conjunction with -I if information about specific interfaces is desired. This is similar to what NetBSD added to their version of netstat. $ netstat -B Pid Netif Flags Recv Drop Match Sblen Hblen Command 1137 lo0 p--s-- 0 0 0 0 0 tcpdump 205 sis0 -ifs-l 37331 0 1 0 0 dhclient $ $ netstat -I lo0 -B Pid Netif Flags Recv Drop Match Sblen Hblen Command 1174 lo0 p--s-- 0 0 0 0 0 tcpdump $ -Add bpf.c which stores all the code for retrieving and parsing bpf related statistics. -Modify main.c to add support for the -B option and hook it into the program logic. -Add bpf.c to the build. -Document this new functionality in the man page and bump the revision date. -Add prototype for bpf_stats function. Notes: svn path=/head/; revision=149862
* Add a new switch -h for interface stats mode, which prints all interfaceGleb Smirnoff2005-08-181-2/+6
| | | | | | | | | | statistics in human readable form. In collaboration with: vsevolod Reviewed by: cperciva Notes: svn path=/head/; revision=149254
* Make IPX support depend on NO_IPXPoul-Henning Kamp2005-08-051-1/+8
| | | | Notes: svn path=/head/; revision=148744
* Print newly exported pfsync statistics with netstat(8).Max Laier2005-07-141-0/+4
| | | | | | | | Requested by: glebius MFC after: 1 week Notes: svn path=/head/; revision=148016
* Add CARP (Common Address Redundancy Protocol), which allows multipleGleb Smirnoff2005-02-221-0/+4
| | | | | | | | | | | | | | | | hosts to share an IP address, providing high availability and load balancing. Original work on CARP done by Michael Shalayeff, with many additions by Marco Pfatschbacher and Ryan McBride. FreeBSD port done solely by Max Laier. Patch by: mlaier Obtained from: OpenBSD (mickey, mcbride) Notes: svn path=/head/; revision=142215
* Update netstat(1) for recent conversion of netipx to queue(9) fromRobert Watson2004-12-311-1/+1
| | | | | | | | | | home-brew linked lists. Read in the ipxpcb_list structure first in order to find the first pcb pointer. Then follow the chain as before, only the termination condition is a NULL next pointer rather than a next pointer equal to the original offset. Notes: svn path=/head/; revision=139463
* -c flag (cache stats) was killed in rev. 1.68. Fix getopt(3) andMaxim Konovalov2004-10-201-2/+2
| | | | | | | | | usage() accordingly. Submitted by: Pawel Worach Notes: svn path=/head/; revision=136726
* Add __FBSDID. Replace local variable sin by sockin to not conflict with sin(3).Philippe Charnier2004-07-261-8/+10
| | | | | | | | Use warnx() instead of warn() when error message is not of any interest. Add prototypes. Notes: svn path=/head/; revision=132671
* Bring in mbuma to replace mballoc.Bosko Milekic2004-05-311-8/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | mbuma is an Mbuf & Cluster allocator built on top of a number of extensions to the UMA framework, all included herein. Extensions to UMA worth noting: - Better layering between slab <-> zone caches; introduce Keg structure which splits off slab cache away from the zone structure and allows multiple zones to be stacked on top of a single Keg (single type of slab cache); perhaps we should look into defining a subset API on top of the Keg for special use by malloc(9), for example. - UMA_ZONE_REFCNT zones can now be added, and reference counters automagically allocated for them within the end of the associated slab structures. uma_find_refcnt() does a kextract to fetch the slab struct reference from the underlying page, and lookup the corresponding refcnt. mbuma things worth noting: - integrates mbuf & cluster allocations with extended UMA and provides caches for commonly-allocated items; defines several zones (two primary, one secondary) and two kegs. - change up certain code paths that always used to do: m_get() + m_clget() to instead just use m_getcl() and try to take advantage of the newly defined secondary Packet zone. - netstat(1) and systat(1) quickly hacked up to do basic stat reporting but additional stats work needs to be done once some other details within UMA have been taken care of and it becomes clearer to how stats will work within the modified framework. From the user perspective, one implication is that the NMBCLUSTERS compile-time option is no longer used. The maximum number of clusters is still capped off according to maxusers, but it can be made unlimited by setting the kern.ipc.nmbclusters boot-time tunable to zero. Work should be done to write an appropriate sysctl handler allowing dynamic tuning of kern.ipc.nmbclusters at runtime. Additional things worth noting/known issues (READ): - One report of 'ips' (ServeRAID) driver acting really slow in conjunction with mbuma. Need more data. Latest report is that ips is equally sucking with and without mbuma. - Giant leak in NFS code sometimes occurs, can't reproduce but currently analyzing; brueffer is able to reproduce but THIS IS NOT an mbuma-specific problem and currently occurs even WITHOUT mbuma. - Issues in network locking: there is at least one code path in the rip code where one or more locks are acquired and we end up in m_prepend() with M_WAITOK, which causes WITNESS to whine from within UMA. Current temporary solution: force all UMA allocations to be M_NOWAIT from within UMA for now to avoid deadlocks unless WITNESS is defined and we can determine with certainty that we're not holding any locks when we're M_WAITOK. - I've seen at least one weird socketbuffer empty-but- mbuf-still-attached panic. I don't believe this to be related to mbuma but please keep your eyes open, turn on debugging, and capture crash dumps. This change removes more code than it adds. A paper is available detailing the change and considering various performance issues, it was presented at BSDCan2004: http://www.unixdaemons.com/~bmilekic/netbuf_bmilekic.pdf Please read the paper for Future Work and implementation details, as well as credits. Testing and Debugging: rwatson, brueffer, Ketrien I. Saihr-Kesenchedra, ... Reviewed by: Lots of people (for different parts) Notes: svn path=/head/; revision=129906
* Output style: Get rid of an unnecessary newline.Bruce M Simpson2004-03-251-1/+0
| | | | Notes: svn path=/head/; revision=127398
* Teach netstat(1) how to print the multicast group memberships presentBruce M Simpson2004-03-251-0/+2
| | | | | | | | | within the running system. Sponsored by: Ralf the Wonder Llama Notes: svn path=/head/; revision=127395
* More cleanups:Ruslan Ermilov2004-03-181-20/+20
| | | | | | | | | | | - 0 should have been -1 in previous commit (just to stay consistent), - Spell null pointers as NULL, not 0, - Fixed the comment about pr_usesysctl to not confuse it with boolean. Pointed by: bde Notes: svn path=/head/; revision=127163
* NULL -> 0.Ruslan Ermilov2004-03-171-1/+1
| | | | Notes: svn path=/head/; revision=127142
* Restore old netstat -m output.Alfred Perlstein2003-12-231-3/+11
| | | | | | | A new flag '-c' can be used to ask for the cache stats. Notes: svn path=/head/; revision=123764
* 1. Add support for printing PIM-related statistics withJeffrey Hsu2003-08-071-0/+2
| | | | | | | | | | | | 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
* Kill #ifdef NS and some leftover #ifdef ISO code. Re-pack the nlist[]Peter Wemm2003-03-051-121/+33
| | | | | | | array, it isn't likely to find any ARPAnet IMP drivers in FreeBSD. Notes: svn path=/head/; revision=111923
* o Allow "buckets" in mb_alloc to be differently sized (according toBosko Milekic2003-02-201-7/+13
| | | | | | | | | | | | | | | | | | | compile-time constants). That is, a "bucket" now is not necessarily a page-worth of mbufs or clusters, but it is MBUF_BUCK_SZ, CLUS_BUCK_SZ worth of mbufs, clusters. o Rename {mbuf,clust}_limit to {mbuf,clust}_hiwm and introduce {mbuf,clust}_lowm, which currently has no effect but will be used to set the low watermarks. o Fix netstat so that it can deal with the differently-sized buckets and teach it about the low watermarks too. o Make sure the per-cpu stats for an absent CPU has mb_active set to 0, explicitly. o Get rid of the allocate refcounts from mbuf map mess. Instead, just malloc() the refcounts in one shot from mbuf_init() o Clean up / update comments in subr_mbuf.c Notes: svn path=/head/; revision=111164
* o Typo/Grammar fixesMike Makonnen2003-01-141-0/+6
| | | | | | | | | | | o Added mini-function to correctly handle singular/plural of words ending in 'ly' Approved by: markm (mentor) Not objected to by: -audit Notes: svn path=/head/; revision=109234
* Warns cleanups for netstat:David Malone2002-09-051-17/+15
| | | | | | | | | | | | | | 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
* Some easy const fixes.Mark Murray2002-04-281-3/+3
| | | | Notes: svn path=/head/; revision=95634
* Implement the ``-f address_family'' filter for -i.Ruslan Ermilov2001-09-111-1/+4
| | | | | | | Prodded by: Igor Podlesny <poige@morning.ru> Notes: svn path=/head/; revision=83349
* Update usage() to match reality.Ruslan Ermilov2001-09-111-5/+12
| | | | Notes: svn path=/head/; revision=83347
* Deprecate the -l option in favour of more natural -W.Ruslan Ermilov2001-09-071-4/+1
| | | | | | | | | | | The compatibility glue is still provided. (This change is not yet reflected in the manpage, nor in usage(). This will be fixed at a later time today, with the general manpage cleanup commit.) Notes: svn path=/head/; revision=83200
* SECURITY: Drop `setgid kmem' bit as early as possible.Ruslan Ermilov2001-08-311-0/+1
| | | | Notes: svn path=/head/; revision=82664
* Make `rttrash' variable (#routes not in table but not freed) visibleRuslan Ermilov2001-06-291-1/+3
| | | | | | | through ``netstat -rs''. Notes: svn path=/head/; revision=78958
* - create an entry of IPV6CTL_STATS sysctl.Hajimu UMEMOTO2001-06-281-4/+4
| | | | | | | | | | | | - fix the problem that netstat doesn't show raw6 and icmp6 pcblist. - make netstat use sysctl to retreive stats of ipv6 and icmpv6 instead of kread. Obtained from: KAME MFC after: 1 week Notes: svn path=/head/; revision=78931
* Add netstat(1) knob to reset net.inet.{ip|icmp|tcp|udp|igmp}.stats.Ruslan Ermilov2001-06-231-1/+5
| | | | | | | | | For example, ``netstat -s -p ip -z'' will show and reset IP stats. PR: bin/17338 Notes: svn path=/head/; revision=78667
* Introduce numerous SMP friendly changes to the mbuf allocator. Namely,Bosko Milekic2001-06-221-2/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | introduce a modified allocation mechanism for mbufs and mbuf clusters; one which can scale under SMP and which offers the possibility of resource reclamation to be implemented in the future. Notable advantages: o Reduce contention for SMP by offering per-CPU pools and locks. o Better use of data cache due to per-CPU pools. o Much less code cache pollution due to excessively large allocation macros. o Framework for `grouping' objects from same page together so as to be able to possibly free wired-down pages back to the system if they are no longer needed by the network stacks. Additional things changed with this addition: - Moved some mbuf specific declarations and initializations from sys/conf/param.c into mbuf-specific code where they belong. - m_getclr() has been renamed to m_get_clrd() because the old name is really confusing. m_getclr() HAS been preserved though and is defined to the new name. No tree sweep has been done "to change the interface," as the old name will continue to be supported and is not depracated. The change was merely done because m_getclr() sounds too much like "m_get a cluster." - TEMPORARILY disabled mbtypes statistics displaying in netstat(1) and systat(1) (see TODO below). - Fixed systat(1) to display number of "free mbufs" based on new per-CPU stat structures. - Fixed netstat(1) to display new per-CPU stats based on sysctl-exported per-CPU stat structures. All infos are fetched via sysctl. TODO (in order of priority): - Re-enable mbtypes statistics in both netstat(1) and systat(1) after introducing an SMP friendly way to collect the mbtypes stats under the already introduced per-CPU locks (i.e. hopefully don't use atomic() - it seems too costly for a mere stat update, especially when other locks are already present). - Optionally have systat(1) display not only "total free mbufs" but also "total free mbufs per CPU pool." - Fix minor length-fetching issues in netstat(1) related to recently re-enabled option to read mbuf stats from a core file. - Move reference counters at least for mbuf clusters into an unused portion of the cluster itself, to save space and need to allocate a counter. - Look into introducing resource freeing possibly from a kproc. Reviewed by (in parts): jlemon, jake, silby, terry Tested by: jlemon (Intel & Alpha), mjacob (Intel & Alpha) Preliminary performance measurements: jlemon (and me, obviously) URL: http://people.freebsd.org/~bmilekic/mb_alloc/ Notes: svn path=/head/; revision=78592
* remove warningsAssar Westerlund2001-06-151-20/+1
| | | | | | | | remove superfluous declarations make things more consistent Notes: svn path=/head/; revision=78316
* remove K&R supportAssar Westerlund2001-06-151-20/+15
| | | | Notes: svn path=/head/; revision=78314
* revert removal of warning and K&R supportAssar Westerlund2001-06-151-12/+36
| | | | | | | Requested by: bde Notes: svn path=/head/; revision=78309
* First round of netstat(1) cleanup.Ruslan Ermilov2001-06-151-26/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | Removed the ambiguity in -s, -f, -p and -i flags handling. Basically, there are four displays (except others): 1. PCB display. 2. Protocol statistics display. (-s) 3. Interface statistics display. (-i) 4. Per-interface protocol statistics display. (-i -s) All of the above except 3) can be limited to a particular protocol family (-f) or a single protocol (-p). Some examples: 1. netstat -f inet -- show PCBs of all INET protocols 2. netstat -p udp -- show PCB of UDP protocol only (NEW!) 3. netstat -s -- show protocol statistics for all families 4. netstat -s -f inet -- show INET protocols statistics 5. netstat -s -p icmp -- show ICMP protocol statistics This is a work in progress. Manpage has been fixed slightly, but is still incomplete. Notes: svn path=/head/; revision=78284
* remove most of the warningsAssar Westerlund2001-06-151-19/+14
| | | | Notes: svn path=/head/; revision=78245
* add the option -S for printing port numbers symbolically but addressesAssar Westerlund2001-06-151-4/+8
| | | | | | | numerically. clean up the CFLAGS in Makefile. Notes: svn path=/head/; revision=78238
* Restore -M -N support for -m.Ruslan Ermilov2001-06-141-3/+19
| | | | | | | PR: 20808 Notes: svn path=/head/; revision=78219