Home | History | Annotate | Download | only in netstat
History log of /src/usr.bin/netstat/route.c
RevisionDateAuthorComments
 1.88  02-Sep-2022  msaitoh KNF. No functional change.
 1.87  01-Sep-2022  msaitoh KNF. No functional change.
 1.86  27-May-2020  yamaguchi Update sysctl key in netstat(1)
 1.85  04-Apr-2016  ozaki-r branches: 1.85.8; 1.85.18;
Separate nexthop caches from the routing table

By this change, nexthop caches (IP-MAC address pair) are not stored
in the routing table anymore. Instead nexthop caches are stored in
each network interface; we already have lltable/llentry data structure
for this purpose. This change also obsoletes the concept of cloning/cloned
routes. Cloned routes no longer exist while cloning routes still exist
with renamed to connected routes.

Noticeable changes are:
- Nexthop caches aren't listed in route show/netstat -r
- sysctl(NET_RT_DUMP) doesn't return them
- If RTF_LLDATA is specified, it returns nexthop caches
- Several definitions of routing flags and messages are removed
- RTF_CLONING, RTF_XRESOLVE, RTF_LLINFO, RTF_CLONED and RTM_RESOLVE
- RTF_CONNECTED is added
- It has the same value of RTF_CLONING for backward compatibility
- route's -xresolve, -[no]cloned and -llinfo options are removed
- -[no]cloning remains because it seems there are users
- -[no]connected is introduced and recommended
to be used instead of -[no]cloning
- route show/netstat -r drops some flags
- 'L' and 'c' are not seen anymore
- 'C' now indicates a connected route
- Gateway value of a route of an interface address is now not
a L2 address but "link#N" like a connected (cloning) route
- Proxy ARP: "arp -s ... pub" doesn't create a route

You can know details of behavior changes by seeing diffs under tests/.

Proposed on tech-net and tech-kern:
http://mail-index.netbsd.org/tech-net/2016/03/11/msg005701.html
 1.84  25-May-2015  manu Make sure netstat builds with -DSMALL

src/usr.bin/netstat relies on code from src/sbin/route. WHen building
with -DSMALL, some functions such as mpls_ntoa() or p_rtrmx() are not
built in src/sbin/route. We therefore have to make sure they are not
used in src/usr.bin/netstat.
 1.83  06-Nov-2014  christos use the common code from route.c
 1.82  28-Apr-2014  christos branches: 1.82.2;
use the same for the route metrics part, both in the sysctl and kmem paths.
From Takahiro HAYASHI
 1.81  24-Apr-2014  christos The sysctl code does not support verbose route printing that prints the
internal route statistics. Restore the old kmem route printing code that
was not just used for post-mortem displays. Reported by kardel@, test by
netstat -nrvf inet
 1.80  28-Jan-2013  joerg branches: 1.80.6;
Use sysctl based code netstat -r. Remove support for post-mortem
analysis.
 1.79  20-Mar-2012  matt branches: 1.79.2;
Use C89 function definitions
 1.78  21-Jun-2011  kefren branches: 1.78.2;
print multiple tags if exists, comma separated
 1.77  04-Feb-2011  martin Use RT_ROUNDUP() and friends from sys/route.h instead of homegrown
variants.
 1.76  01-Feb-2011  matt Add a new AF/PF_ROUTE which is 64-bit clean which makes the routing socket
interface (and its associated sysctls) act identically for both 32 and 64 bit
programs. The old unclean one remains for backward compatibility.
 1.75  27-Jun-2010  kefren branches: 1.75.2;
Add -T flag, that shows tags in route output
 1.74  22-Apr-2010  plunky it is not [any longer] necessary to #define _KERNEL while including
<net/route.h> so remove it.

This fixes a build problem with pcc which is not as clever as gcc
when optimising away unused static inline functions which refer to
unknown symbols (eg sockaddr_dup).
 1.73  12-Apr-2009  lukem Fix many WARNS=4 issues (-Wshadow -Wcast-qual -Wsign-compare).
Fix probable bug with numeric printing of anon ports when using sysctl.
 1.72  29-Dec-2008  christos branches: 1.72.2;
fix for 64 bit time_t
 1.71  23-Apr-2008  thorpej branches: 1.71.10;
netns is no longer in the tree; completely purge it from netstat(1).
 1.70  21-Jan-2008  dyoung branches: 1.70.4;
#include <stdbool.h> for 'bool', so that this kernel groveller will
hopefully compile again.
 1.69  19-Jul-2007  dyoung branches: 1.69.4; 1.69.8;
rt_key() is no more. Use rt_getkey().
 1.68  26-Aug-2006  matt Conditionalize XNS support. No longer enabled.
 1.67  28-May-2006  elad Make netstat use sysctl when dumping routing tables/stats.
Heavily based on similar code from Claudio Jeker (at OpenBSD).

While here, fix inet/inet6 sysctl stuff commited previously to
actually work, and some other nits to make netstat more sysctl
friendly.

One step closer to losing setgid kmem on this one...
 1.66  04-Aug-2005  rpaulo branches: 1.66.2;
Added #include <kvm.h> since netstat.h, which is included too, needs it.
 1.65  16-Nov-2004  itojun NI_WITHSCOPEID was not picked up by IETF standardization process
 1.64  16-Nov-2004  itojun NI_WITHSCOPEID was not picked up by IETF standardization process.
 1.63  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22365, verified by myself.
 1.62  04-Aug-2003  itojun always print prefixlen for routes. it's CIDR age.
 1.61  12-Jul-2003  itojun strlcpy
 1.60  14-May-2003  itojun use proper #ifdef to determine behavior (__KAME__)
 1.59  13-May-2002  matt Don't count on kernel includes to exports user variables.
 1.58  06-Oct-2001  bjh21 Use getnameinfo() to format link-layer addresses for netstat -r rather than
doing it ourselves and falling back to link_ntoa().
 1.57  19-Aug-2001  itojun snprintf length audit. from openbsd
 1.56  28-May-2001  assar add `-s' that prints port numbers symbolically but addresses numerically
 1.55  06-Apr-2001  itojun pedant changes for strcpy/sprintf.
 1.54  08-Mar-2001  enami Print hopcount too when -rv is given.
 1.53  21-Feb-2001  itojun use u_quad_t for rtstat.
not sure if it really matters, but short (32K) looks way too small given
recent fat pipes connecting *BSD boxes, and our great uptime :-).
 1.52  27-Jan-2001  itojun mark cloned routes with RTF_CLONED. present it with netstat -r by "c".

let static routes overwrite cloned routes, as cloned routes can come back again
if necessary. behavior same as freebsd/bsdi, code partially from bsdi42.
(NRL rt->rt_parent was not added)
should fix PR 11916 and maybe some other PRs with ARP behavior.

recompilation of usr.sbin/route6d is suggested.
 1.51  14-Nov-2000  matt Do the same IEEE1394 address hack in here.
 1.50  11-Oct-2000  is More format string cleanup by sommerfeld.
 1.49  06-Jul-2000  itojun more stats. from kame
 1.48  17-Jan-2000  itojun branches: 1.48.4;
fix default route determination for inet6.
 1.47  17-Jan-2000  itojun mask addresses properly on netstat -inv.
From: Matt Thomas <matt@3am-software.com>
 1.46  15-Jan-2000  hubertf Properly print the "B"(lackhole) flag (as documented :).
Patch submitted in PR 9190 by URA Hiroshi <ura@hiru.aoba.yokohama.jp>
 1.45  07-Jan-2000  sommerfeld Pay attention to the netmask of routes to 0.0.0.0;
e.g., a route to 0.0.0.0/1 is *not* a default route.

Inspired by a patch by Rodney Grimes sent to the zebra list.
 1.44  13-Dec-1999  itojun per-interface statistics.
bring in and enable KAME scopeid hack.
lots of cleanups.
(sync with latest KAME)
 1.43  27-Nov-1999  soren Print Internet6 header properly without -f.
 1.42  24-Nov-1999  itojun more clarification to field width of netstat -rn -f inet6.
 1.41  22-Nov-1999  itojun use old WID_{DST,GW} value (field width for netstat -rn) for non-INET6
address families (see tech-net discussion).
 1.40  15-Sep-1999  is branches: 1.40.4;
Add -L option. netstat -r -L behaves like 4.3BSD netstat -r, that is, it
does not show route table entries pointing to link level addresses (ARP
entries or IPv6 neighbour discovery entries).
 1.39  03-Sep-1999  itojun sync with recent KAME.
- fix routing socket align issue on 64bit arch.
- avoid s6_addr{8,16,32}, which are nonstandard.
 1.38  01-Jul-1999  itojun make netstat IPv6-ready.
 1.37  02-Apr-1999  chopps don't use malloc for large sockaddr's, just name the union declared above
 1.36  01-Apr-1999  chopps branches: 1.36.2;
user err() not errx()
 1.35  01-Apr-1999  chopps fix for sockaddr's that are bigger than standard sockaddr's (e.g., iso)
 1.34  15-Jan-1999  kml Added a verbose flag for route display that will show
the various route metrics.
 1.33  11-Jan-1999  mrg #ifndef SMALL changes. saves 30k on the sparc
 1.32  05-Dec-1998  pk Make a network number by shifting out host bits in octet units.
This is currently required still to get correct lookups in `/etc/networks'.
 1.31  23-Nov-1998  msaitoh fix invalid shift. colsed PR#5160.
 1.30  31-Oct-1998  mrg put all the different struct sockaddr_xxx types into the union pt_u, to force the alignment to be correct for all of them.
 1.29  12-Jul-1998  mrg - KNF
- use err(3)
- sprintf/strcpy -> snprintf/strncpy
- change route.c:domask() to take a size_t of the buffer passed.
 1.28  06-Jul-1998  mrg - use an array MAXHOSTNAMELEN+1 size to hold hostnames
- ensure hostname from gethostname() is nul-terminated in all cases
- minor KNF
- use MAXHOSTNAMELEN over various other values/defines
- be safe will buffers that hold hostnames
 1.27  14-May-1998  kml Partial fix for PR kern/5435 -- changed netstat to use unsigned counters
instead of signed. The rest of the fix will have to wait for 64-bit counters.
 1.26  14-May-1998  kml Ensure that the 'L' lock flag for MTU is always displayed when present.
 1.25  28-Oct-1997  kml Added (and documented) a change to the route display, so that mtu values
which have been locked are indicated by an 'L' appended to the MTU value.
Locked routes have path mtu discovery turned off.
 1.24  20-Oct-1997  mrg branches: 1.24.2;
fix compile warnings on the sparc.
 1.23  19-Oct-1997  lukem fix up .Nm usage, getopt returns -1 not EOF
 1.22  10-Apr-1997  christos Make the first field 2 characters wider so that XXX.XXX.XXX.XXX/XX fits.
From Kimmo
 1.21  03-Apr-1997  christos - netatalk additions
- printf format fixes
- minor prototype cleanups
 1.20  26-Mar-1997  thorpej Print Ethernet and FDDI addresses in the same format as ether_ntoa().
From Matt Thomas <matt@3am-software.com>
 1.19  18-Mar-1997  mycroft Get the byte-swapping right in netmask().
 1.18  02-Jan-1997  mellon ns_print: fix type conflict
 1.17  02-Jan-1997  mellon ns_print: undo bogus type conflict
 1.16  02-Jan-1997  mellon Lite2 Merge
 1.15  07-May-1996  thorpej Update for the changes to struct ifnet. While I'm here, fix a couple
of long-standing bugs:

- Actually deal with the fact that the kernel ifnet list is
a TAILQ; it just happened to work before.

- Use kvm_openfiles() instead of kvm_open(). The code passed
arguments to kvm_open() as if it were kvm_openfiles(), but
apparently went unnoticed since the prototypes are the same.
Amusing bit: there were XXX's in the code which seemed to
apologize for a verbose libkvm, when it happened to be a
bug in netstat!
 1.14  03-Oct-1995  thorpej New-style RCS ids.
 1.13  10-Aug-1995  thorpej If set, show a route's mtu in the routing table display.
 1.12  03-Jul-1995  mycroft Byte-swap correctly. Make some types 64-bit safe. Use INADDR_ANY rather
than an explicit 0.
 1.11  28-Mar-1995  jtc KERNEL -> _KERNEL
 1.10  13-May-1994  mycroft Clean up import.
 1.9  01-Apr-1994  cgd kill lots of off_t's.
 1.8  28-Mar-1994  cgd clean up, for off_t... ugliest 'cleaning' possible, i think...
 1.7  07-Mar-1994  cgd feedback on the last, from sklower
 1.6  06-Mar-1994  cgd print netmask properly
 1.5  01-Aug-1993  mycroft Add RCS identifiers.
 1.4  11-Jul-1993  paul Included Havard Eidnes' latest changes.
 1.3  18-May-1993  cgd fix from David Burren <davidb@otto.bf.rmit.oz.au> to print address families
more nicely, and to print host names when showing routes w/o -n.
 1.2  01-May-1993  mycroft Fix typo.
 1.1  21-Mar-1993  cgd branches: 1.1.1;
after 0.2.2 "stable" patches applied
 1.1.1.2  02-Jan-1997  mellon imported from 44lite2
 1.1.1.1  06-Oct-1994  mycroft Import original 4.4-Lite version.
 1.24.2.2  19-Jan-1999  cgd pull up rev 1.33 (mrg)
 1.24.2.1  29-Oct-1997  mellon Pull rev 1.25 up from trunk (kml)
 1.36.2.3  19-Oct-2000  he Pull up revision 1.50 (via patch, requested by he):
Format string cleanup.
 1.36.2.2  21-Jan-2000  he Pull up revision 1.46 (requested by hubertf):
Properly print "B" for "Blackhole" routes. Fixes PR#9190.
 1.36.2.1  02-Apr-1999  chopps pull-up revision 1.37 to fix previous revision (no longer use malloc)
 1.40.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.48.4.2  05-Apr-2001  he Pull up revision 1.52 (requested by itojun):
Mark cloned routes with RTF_CLONED. Present it in ``netstat -r''
output by ``c''.
 1.48.4.1  18-Oct-2000  tv Pullup usr.bin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.66.2.1  19-Jun-2006  chap Sync with head.
 1.69.8.2  19-Jul-2007  dyoung rt_key() is no more. Use rt_getkey().
 1.69.8.1  19-Jul-2007  dyoung file route.c was added on branch matt-mips64 on 2007-07-19 20:51:05 +0000
 1.69.4.1  23-Mar-2008  matt sync with HEAD
 1.70.4.1  18-May-2008  yamt sync with head.
 1.71.10.1  11-May-2010  matt Fixup for u_quad_t route changes.
 1.72.2.1  13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html
 1.75.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.78.2.2  22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.78.2.1  17-Apr-2012  yamt sync with head
 1.79.2.2  20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.79.2.1  25-Feb-2013  tls resync with head
 1.80.6.1  10-Aug-2014  tls Rebase.
 1.82.2.2  01-Jun-2015  snj Pull up following revision(s) (requested by manu in ticket #809):
usr.bin/netstat/route.c: revision 1.84
Make sure netstat builds with -DSMALL
src/usr.bin/netstat relies on code from src/sbin/route. WHen building
with -DSMALL, some functions such as mpls_ntoa() or p_rtrmx() are not
built in src/sbin/route. We therefore have to make sure they are not
used in src/usr.bin/netstat.
 1.82.2.1  08-Jan-2015  martin Pull up following revision(s) (requested by prlw1 in ticket #390):
usr.bin/netstat/mroute.c: revision 1.25
usr.bin/netstat/Makefile: revision 1.40
sbin/route/prog_ops.h: revision 1.3
sbin/route/rtutil.c: revision 1.1
sbin/route/rtutil.h: revision 1.1
usr.bin/netstat/mroute6.c: revision 1.15
sbin/route/extern.h: revision 1.15
usr.bin/netstat/show.c: file removal
usr.bin/netstat/main.c: revision 1.93
usr.bin/netstat/route.c: revision 1.83
usr.bin/netstat/netstat.h: revision 1.51
distrib/utils/x_route/Makefile: revision 1.18
sbin/route/show.c: revision 1.46
usr.bin/netstat/if.c: revision 1.80
sbin/route/route.c: revision 1.145
sbin/route/Makefile: revision 1.26
Factor out the netstat route printing code and use it here. There is no
point in having 2 different copies; fixes PR/49371
 1.85.18.1  12-Sep-2022  martin Pull up the following, requested by msaitoh in ticket #1522:

usr.bin/netstat/atalk.c 1.18,1.20-1.21
usr.bin/netstat/bpf.c 1.16 via patch
usr.bin/netstat/fast_ipsec.c 1.24
usr.bin/netstat/if.c 1.97-1.99,1.101-1.104 via patch
usr.bin/netstat/inet.c 1.111,1.115-1.116 via patch
usr.bin/netstat/inet6.c 1.74-1.75,1.80-1.81 via patch
usr.bin/netstat/main.c 1.100-1.103
usr.bin/netstat/mbuf.c 1.35
usr.bin/netstat/mroute.c 1.26-1.27
usr.bin/netstat/mroute6.c 1.16
usr.bin/netstat/netstat.h 1.52-1.53
usr.bin/netstat/pfkey.c 1.4-1.5 via patch
usr.bin/netstat/pfsync.c 1.4-1.5 via patch
usr.bin/netstat/route.c 1.86-1.88
usr.bin/netstat/unix.c 1.36-1.37
usr.bin/netstat/vtw.c 1.11,1.13

- sprintf() -> snprintf(), and adjust a buffer size to avoid any
potential for overflow.
- Fix netstat -rs to print it correctly.
- Add missing {IP,IP6}_STAT_NOIPSEC to netstat.
- Don't show any of the completely and utterly undocumented VTW info
if the feature isn't enabled.
- Print oqdrops correctly.
- Remove Network ATM soft intr queue reporting, we don't have that
in the kernel anymore.
- netstat.1: Add various xrefs present in the body to "See Also".
- KNF. Style fixes.
 1.85.8.1  12-Sep-2022  martin Pull up the following, requested by msaitoh in ticket #1762:

usr.bin/netstat/atalk.c 1.18,1.20-1.21
usr.bin/netstat/bpf.c 1.16 via patch
usr.bin/netstat/fast_ipsec.c 1.24 via patch
usr.bin/netstat/if.c 1.97-1.99,1.101-1.104 via patch
usr.bin/netstat/inet.c 1.111,1.115-1.116 via patch
usr.bin/netstat/inet6.c 1.70,1.74-1.75,1.80-1.81 via patch
usr.bin/netstat/main.c 1.100,1.102-1.103
usr.bin/netstat/mbuf.c 1.34-1.35
usr.bin/netstat/mroute.c 1.26-1.27
usr.bin/netstat/mroute6.c 1.16
usr.bin/netstat/netstat.h 1.52-1.53
usr.bin/netstat/pfkey.c 1.4-1.5 via patch
usr.bin/netstat/pfsync.c 1.4-1.5 via patch
usr.bin/netstat/route.c 1.87-1.88
usr.bin/netstat/unix.c 1.36-1.37
usr.bin/netstat/vtw.c 1.11,1.13

- Add names of a few more ICMPv6 messages.
Also make the array be explicitly 256 entries long.
- sprintf() -> snprintf(), and adjust a buffer size to avoid any
potential for overflow.
- Add missing {IP,IP6}_STAT_NOIPSEC to netstat.
- Don't show any of the completely and utterly undocumented VTW info
if the feature isn't enabled.
- Print oqdrops correctly.
- netstat.1: Add various xrefs present in the body to "See Also".
- Limit maximum owner name to appease gcc.
- KNF. Style fixes.

RSS XML Feed