summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
Commit message (Collapse)AuthorAgeFilesLines
...
* Add ECN stats.rpaulo2008-08-261-0/+5
|
* Fix buildemax2008-07-291-1/+1
|
* Update the kernel to count the number of mbufs and clustersgnn2008-05-154-11/+67
| | | | | | | | | | | | (all types) used per socket buffer. Add support to netstat to print out all of the socket buffer statistics. Update the netstat manual page to describe the new -x flag which gives the extended output. Reviewed by: rwatson, julian
* Fix build.delphij2008-05-101-3/+4
|
* Add code to allow the system to handle multiple routing tables.julian2008-05-091-4/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This particular implementation is designed to be fully backwards compatible and to be MFC-able to 7.x (and 6.x) Currently the only protocol that can make use of the multiple tables is IPv4 Similar functionality exists in OpenBSD and Linux. From my notes: ----- One thing where FreeBSD has been falling behind, and which by chance I have some time to work on is "policy based routing", which allows different packet streams to be routed by more than just the destination address. Constraints: ------------ I want to make some form of this available in the 6.x tree (and by extension 7.x) , but FreeBSD in general needs it so I might as well do it in -current and back port the portions I need. One of the ways that this can be done is to have the ability to instantiate multiple kernel routing tables (which I will now refer to as "Forwarding Information Bases" or "FIBs" for political correctness reasons). Which FIB a particular packet uses to make the next hop decision can be decided by a number of mechanisms. The policies these mechanisms implement are the "Policies" referred to in "Policy based routing". One of the constraints I have if I try to back port this work to 6.x is that it must be implemented as a EXTENSION to the existing ABIs in 6.x so that third party applications do not need to be recompiled in timespan of the branch. This first version will not have some of the bells and whistles that will come with later versions. It will, for example, be limited to 16 tables in the first commit. Implementation method, Compatible version. (part 1) ------------------------------- For this reason I have implemented a "sufficient subset" of a multiple routing table solution in Perforce, and back-ported it to 6.x. (also in Perforce though not always caught up with what I have done in -current/P4). The subset allows a number of FIBs to be defined at compile time (8 is sufficient for my purposes in 6.x) and implements the changes needed to allow IPV4 to use them. I have not done the changes for ipv6 simply because I do not need it, and I do not have enough knowledge of ipv6 (e.g. neighbor discovery) needed to do it. Other protocol families are left untouched and should there be users with proprietary protocol families, they should continue to work and be oblivious to the existence of the extra FIBs. To understand how this is done, one must know that the current FIB code starts everything off with a single dimensional array of pointers to FIB head structures (One per protocol family), each of which in turn points to the trie of routes available to that family. The basic change in the ABI compatible version of the change is to extent that array to be a 2 dimensional array, so that instead of protocol family X looking at rt_tables[X] for the table it needs, it looks at rt_tables[Y][X] when for all protocol families except ipv4 Y is always 0. Code that is unaware of the change always just sees the first row of the table, which of course looks just like the one dimensional array that existed before. The entry points rtrequest(), rtalloc(), rtalloc1(), rtalloc_ign() are all maintained, but refer only to the first row of the array, so that existing callers in proprietary protocols can continue to do the "right thing". Some new entry points are added, for the exclusive use of ipv4 code called in_rtrequest(), in_rtalloc(), in_rtalloc1() and in_rtalloc_ign(), which have an extra argument which refers the code to the correct row. In addition, there are some new entry points (currently called rtalloc_fib() and friends) that check the Address family being looked up and call either rtalloc() (and friends) if the protocol is not IPv4 forcing the action to row 0 or to the appropriate row if it IS IPv4 (and that info is available). These are for calling from code that is not specific to any particular protocol. The way these are implemented would change in the non ABI preserving code to be added later. One feature of the first version of the code is that for ipv4, the interface routes show up automatically on all the FIBs, so that no matter what FIB you select you always have the basic direct attached hosts available to you. (rtinit() does this automatically). You CAN delete an interface route from one FIB should you want to but by default it's there. ARP information is also available in each FIB. It's assumed that the same machine would have the same MAC address, regardless of which FIB you are using to get to it. This brings us as to how the correct FIB is selected for an outgoing IPV4 packet. Firstly, all packets have a FIB associated with them. if nothing has been done to change it, it will be FIB 0. The FIB is changed in the following ways. Packets fall into one of a number of classes. 1/ locally generated packets, coming from a socket/PCB. Such packets select a FIB from a number associated with the socket/PCB. This in turn is inherited from the process, but can be changed by a socket option. The process in turn inherits it on fork. I have written a utility call setfib that acts a bit like nice.. setfib -3 ping target.example.com # will use fib 3 for ping. It is an obvious extension to make it a property of a jail but I have not done so. It can be achieved by combining the setfib and jail commands. 2/ packets received on an interface for forwarding. By default these packets would use table 0, (or possibly a number settable in a sysctl(not yet)). but prior to routing the firewall can inspect them (see below). (possibly in the future you may be able to associate a FIB with packets received on an interface.. An ifconfig arg, but not yet.) 3/ packets inspected by a packet classifier, which can arbitrarily associate a fib with it on a packet by packet basis. A fib assigned to a packet by a packet classifier (such as ipfw) would over-ride a fib associated by a more default source. (such as cases 1 or 2). 4/ a tcp listen socket associated with a fib will generate accept sockets that are associated with that same fib. 5/ Packets generated in response to some other packet (e.g. reset or icmp packets). These should use the FIB associated with the packet being reponded to. 6/ Packets generated during encapsulation. gif, tun and other tunnel interfaces will encapsulate using the FIB that was in effect withthe proces that set up the tunnel. thus setfib 1 ifconfig gif0 [tunnel instructions] will set the fib for the tunnel to use to be fib 1. Routing messages would be associated with their process, and thus select one FIB or another. messages from the kernel would be associated with the fib they refer to and would only be received by a routing socket associated with that fib. (not yet implemented) In addition Netstat has been edited to be able to cope with the fact that the array is now 2 dimensional. (It looks in system memory using libkvm (!)). Old versions of netstat see only the first FIB. In addition two sysctls are added to give: a) the number of FIBs compiled in (active) b) the default FIB of the calling process. Early testing experience: ------------------------- Basically our (IronPort's) appliance does this functionality already using ipfw fwd but that method has some drawbacks. For example, It can't fully simulate a routing table because it can't influence the socket's choice of local address when a connect() is done. Testing during the generating of these changes has been remarkably smooth so far. Multiple tables have co-existed with no notable side effects, and packets have been routes accordingly. ipfw has grown 2 new keywords: setfib N ip from anay to any count ip from any to any fib N In pf there seems to be a requirement to be able to give symbolic names to the fibs but I do not have that capacity. I am not sure if it is required. SCTP has interestingly enough built in support for this, called VRFs in Cisco parlance. it will be interesting to see how that handles it when it suddenly actually does something. Where to next: -------------------- After committing the ABI compatible version and MFCing it, I'd like to proceed in a forward direction in -current. this will result in some roto-tilling in the routing code. Firstly: the current code's idea of having a separate tree per protocol family, all of the same format, and pointed to by the 1 dimensional array is a bit silly. Especially when one considers that there is code that makes assumptions about every protocol having the same internal structures there. Some protocols don't WANT that sort of structure. (for example the whole idea of a netmask is foreign to appletalk). This needs to be made opaque to the external code. My suggested first change is to add routing method pointers to the 'domain' structure, along with information pointing the data. instead of having an array of pointers to uniform structures, there would be an array pointing to the 'domain' structures for each protocol address domain (protocol family), and the methods this reached would be called. The methods would have an argument that gives FIB number, but the protocol would be free to ignore it. When the ABI can be changed it raises the possibilty of the addition of a fib entry into the "struct route". Currently, the structure contains the sockaddr of the desination, and the resulting fib entry. To make this work fully, one could add a fib number so that given an address and a fib, one can find the third element, the fib entry. Interaction with the ARP layer/ LL layer would need to be revisited as well. Qing Li has been working on this already. This work was sponsored by Ironport Systems/Cisco PR: Reviewed by: several including rwatson, bz and mlair (parts each) Approved by: Obtained from: Ironport systems/Cisco MFC after: Security:
* Fixes typo's in sctp.crrs2008-04-161-4/+4
|
* Catch netstat up for the new bpf stats structures. Print 64 bit valuescsjp2008-03-241-2/+6
| | | | | | | properly. Sponsored by: Seccuris Inc MFC after: 4 months
* Change .8s port name restriction to .15s.ume2008-03-181-1/+1
| | | | | | This change corresponds to inet.c 1.13. MFC after: 1 week
* Make netstat -rn more resilient to having the routing table change out fromjhb2008-02-141-19/+43
| | | | | | | | | | | under it while running. Note that this is still not perfect: - Try to do something intelligent if kvm_read() fails to read a routing table structure such as an rtentry, radix_node, or ifnet. - Don't follow left and right node pointers in radix_nodes unless RNF_ACTIVE is set in rn_flags. This avoids walking through freed radix_nodes. MFC after: 1 week
* Change another argument and a variable both related to netname() tomarius2008-02-111-3/+3
| | | | | | be also 32-bit on all archs. MFC after: 3 days
* Fix netname() [1] and routename() on big-endian LP64 archs.marius2008-02-072-8/+7
| | | | | Submitted by: Yuri Pankov [1] MFC after: 3 days
* Add IFT_BRIDGE to the Ethernet section so l2 addresses are formatted correctly.thompsa2008-01-101-0/+1
| | | | | PR: bin/119542 Submitted by: Niki Denev
* quiet compiler complaint about unused parameterssam2008-01-101-2/+2
|
* Make a few messages more consistant with the others.obrien2008-01-041-2/+2
|
* more style(9)obrien2008-01-041-69/+70
|
* style(9)obrien2008-01-0218-256/+251
| | | | | | | + kread is not a boolean, so check it as such + fix $FreeBSD$ Ids + denote copyrights with /*- + misc whitespace changes.
* Fix printing of the number of syncache entries added.ru2007-12-181-2/+2
|
* These are the things that the tinderbox has problems with because itjb2007-11-201-0/+1
| | | | | | | | doesn't use the default CFLAGS which contain -fno-strict-aliasing. Until the code is cleaned up, just add -fno-strict-aliasing to the CFLAGS of these for the tinderboxes' sake, allowing the rest of the tree to have -Werror enabled again.
* Fix incorrect string formats for netstat/srrs2007-10-171-48/+48
| | | | | | PR: 117175 Obtained from: Weongyo Jeong (weongyo.jeong@gmail.com) MFC after: 1 week
* - Netstat warning removal for 64 bit aware platforms.rrs2007-09-091-117/+108
| | | | Approved by: re@freebsd.org (B Mah)
* - Fix typo in netstat's display of Nagle algorithm - refer to the RFC.rrs2007-08-241-2/+2
| | | | | Submitted by: bruce@cran.org.uk Approved by: re@freebsd.org (Bruce Mah)
* Make tcpstates[] static, and make sure TCPSTATES is defined beforedes2007-07-301-2/+1
| | | | | | | | | <netinet/tcp_fsm.h> is included into any compilation unit that needs tcpstates[]. Also remove incorrect extern declarations and TCPDEBUG conditionals. This allows kernels both with and without TCPDEBUG to build, and unbreaks the tinderbox. Approved by: re (rwatson)
* Bah, fix a cosmetic nit and remove a debugging aid missed in the previousjhb2007-07-161-2/+1
| | | | | | | fixes for netstat -M. Pointy hat to: jhb Approved by: re (kensmith)
* Restore netstat -M functionality for most statistics on core dumps. Injhb2007-07-1618-366/+750
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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)
* Commit IPv6 support for FAST_IPSEC to the tree.gnn2007-07-015-78/+23
| | | | | | | | This commit includes all remaining changes for the time being including user space updates. Submitted by: bz Approved by: re
* o style(9) nit.rrs2007-06-171-100/+87
| | | | | | | o shorten explainations which are over 80 columns in console. o group rows o clean up and change explanations a little bit. Obtained from: weongyo.jeong@gmail.com
* - Forced commit to update who actually did this code (I forgotrrs2007-06-171-0/+1
| | | | | the obtained from in the original line) Obtained from: Weongyo Jeong (weongyo.jeong@gmail.com)
* sctp_process_inpcb() wants an offset parameter in size_t,delphij2007-06-131-1/+1
| | | | | so define it as what it is expected. This fixes WARNS=3 without NO_WERROR build.
* Import rewrite of IPv4 socket multicast layer to support source-specificbms2007-06-121-1/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and protocol-independent host mode multicast. The code is written to accomodate IPv6, IGMPv3 and MLDv2 with only a little additional work. This change only pertains to FreeBSD's use as a multicast end-station and does not concern multicast routing; for an IGMPv3/MLDv2 router implementation, consider the XORP project. The work is based on Wilbert de Graaf's IGMPv3 code drop for FreeBSD 4.6, which is available at: http://www.kloosterhof.com/wilbert/igmpv3.html Summary * IPv4 multicast socket processing is now moved out of ip_output.c into a new module, in_mcast.c. * The in_mcast.c module implements the IPv4 legacy any-source API in terms of the protocol-independent source-specific API. * Source filters are lazy allocated as the common case does not use them. They are part of per inpcb state and are covered by the inpcb lock. * struct ip_mreqn is now supported to allow applications to specify multicast joins by interface index in the legacy IPv4 any-source API. * In UDP, an incoming multicast datagram only requires that the source port matches the 4-tuple if the socket was already bound by source port. An unbound socket SHOULD be able to receive multicasts sent from an ephemeral source port. * The UDP socket multicast filter mode defaults to exclusive, that is, sources present in the per-socket list will be blocked from delivery. * The RFC 3678 userland functions have been added to libc: setsourcefilter, getsourcefilter, setipv4sourcefilter, getipv4sourcefilter. * Definitions for IGMPv3 are merged but not yet used. * struct sockaddr_storage is now referenced from <netinet/in.h>. It is therefore defined there if not already declared in the same way as for the C99 types. * The RFC 1724 hack (specify 0.0.0.0/8 addresses to IP_MULTICAST_IF which are then interpreted as interface indexes) is now deprecated. * A patch for the Rhyolite.com routed in the FreeBSD base system is available in the -net archives. This only affects individuals running RIPv1 or RIPv2 via point-to-point and/or unnumbered interfaces. * Make IPv6 detach path similar to IPv4's in code flow; functionally same. * Bump __FreeBSD_version to 700048; see UPDATING. This work was financially supported by another FreeBSD committer. Obtained from: p4://bms_netdev Submitted by: Wilbert de Graaf (original work) Reviewed by: rwatson (locking), silence from fenner, net@ (but with encouragement)
* Backout mess mistakenly committed with manpage update.ceri2007-06-101-0/+10
|
* Document SCTP support.ceri2007-06-102-12/+2
|
* Adds support for SCTP.rrs2007-06-094-1/+719
|
* 'netstat -A -p tcp' doesn't print the Socket but the Tcpcb pointer in theandre2007-05-131-1/+1
| | | | first column.
* o Fill the list of icmp types; make its size depend on ICMP_MAXTYPE.maxim2007-04-301-20/+50
| | | | | | | | | | o Print "unknown ICMP" instead of "(null)" if we don't have a description for a icmp type. Based on code Submitted by: Christoph Weber-Fahr PR: misc/112126 MFC after: 2 weeks
* Mark netstat -g host-mode output as deprecated.bms2007-04-101-0/+9
| | | | MFC after: 2 weeks
* Fixing NO_INET6 build as addr2ascii() has been nuked in previous commit.avatar2007-03-021-0/+2
|
* stub call to addr2ascii().bms2007-03-011-1/+3
| | | | Noticed by: brooks
* Nuke ascii2addr() and addr2ascii(). They have no consumers anywherebms2007-02-281-0/+2
| | | | | | | | | | | | | | in FreeBSD, and originated from INRIA IPv6. Stub out netstat reference to addr2ascii() I mistakenly introduced. Update misleading man page sections. Merge NetBSD's getnameinfo() AF_LINK extensions for a portable way to print link-layer addresses given a sockaddr_dl(), minus the IEEE 1394 bits which don't map directly to our code. Obtained from: NetBSD (getnameinfo.c) Discussed on: current (March 2006)
* Fixed some style bugs (whitespace lossage for removal of __P(()), andbde2007-02-271-8/+8
| | | | lots of naming and typing errors involving `interval').
* Use a periodic itimer instead of repeated calls to alarm() inbde2007-02-271-7/+9
| | | | | | | | | | | | | | sidewaysintpr(). This increases the accuracy of the per-interval counts when they are interpreted as rates. Repeated calls to alarm(n) give an average interval that is about 2 ticks larger than n and has a large variance. Periodic itimers normally get the average almost right but have similarly large variance (due to scheduling delays). Statistics utilities should use clock_gettime() to determine the actual interval, but it is still useful to maximize the accuracy of the interval, especially for cases like netstat -w where counts are displayed so the program cannot hide the inaccuracy in a rate conversion.
* Reap FIN_WAIT_2 connections marked SOCANTRCVMORE faster. This mitigatemohans2007-02-261-0/+1
| | | | | | | | potential issues where the peer does not close, potentially leaving thousands of connections in FIN_WAIT_2. This is controlled by a new sysctl fast_finwait2_recycle, which is disabled by default. Reviewed by: gnn, silby.
* Add three new ioctl(2) commands for bpf(4).jkim2007-02-261-3/+6
| | | | | | | | | | | | | | | | | | | | | | - BIOCGDIRECTION and BIOCSDIRECTION get or set the setting determining whether incoming, outgoing, or all packets on the interface should be returned by BPF. Set to BPF_D_IN to see only incoming packets on the interface. Set to BPF_D_INOUT to see packets originating locally and remotely on the interface. Set to BPF_D_OUT to see only outgoing packets on the interface. This setting is initialized to BPF_D_INOUT by default. BIOCGSEESENT and BIOCSSEESENT are obsoleted by these but kept for backward compatibility. - BIOCFEEDBACK sets packet feedback mode. This allows injected packets to be fed back as input to the interface when output via the interface is successful. When BPF_D_INOUT direction is set, injected outgoing packet is not returned by BPF to avoid duplication. This flag is initialized to zero by default. Note that libpcap has been modified to support BPF_D_OUT direction for pcap_setdirection(3) and PCAP_D_OUT direction is functional now. Reviewed by: rwatson
* Use sysctl(2), not kvm(3), to read IPv6 multicast information frombms2007-02-242-21/+60
| | | | | | the running system. Use the name 'IPv6 Forwarding Table', not 'IPv6 Routing Table', to be consistent with what the code actually does and is.
* Use the names 'IPv4' and 'Forwarding Table' in program output, notbms2007-02-241-4/+4
| | | | 'Routing Table', to be consistent with what the code actually does and is.
* Add comments about where netstat is using KVM to read things whichbms2007-02-241-1/+3
| | | | should really be available via sysctl for a running system.
* Update host-mode multicast group information output.bms2007-02-211-33/+87
| | | | | | | | | | | | Display IPv4 and IPv6 memberships separately. Obey the MK_INET6_SUPPORT flag. Display link-layer memberships. Use addr2ascii() to correctly print non-IEEE 802 sockaddr_dl instances. Eliminate redundant switch..case blocks. Update copyright. Misc style changes. MFC after: 3 weeks
* Change wording of warnings when there is no ip_mroute.ko modulebms2007-02-212-11/+19
| | | | | | | | 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.
* Retire most of the classful network behaviour of netstat -r output, for IPv4.bms2007-02-141-52/+9
| | | | | | | | | | | | | | | | Without -n, we now only print a "network name" without the prefix length under the following conditions: 1) the network address and mask matches a classful network prefix; 2) getnetbyaddr(3) returns a network name for this network address. With -n, we unconditionally print the full unabbreviated CIDR network prefix in the form "a.b.c.d/p". 0.0.0.0/0 is still printed as "default". This change is in preparation for changes such as equal-cost multipath, and to more generally assist operational deployment of FreeBSD as a modern IPv4 router. There are currently no plans to backport this change. Discussed on: freebsd-net
* Don't shadow globals.yar2006-11-273-7/+7
| | | | | Found by: WARNS=6 MFC after: 3 days
* We should return the name in cp, not printf it.yar2006-11-271-1/+3
| | | | | Found by: WARNS=6 MFC after: 3 days
OpenPOWER on IntegriCloud