Home | History | Annotate | Download | only in route
History log of /src/sbin/route/show.c
RevisionDateAuthorComments
 1.51  29-Aug-2020  christos Make the "interesting" flags match the netstat ones, so:

route show -inet
netstat -r -f inet

outputs match.
 1.50  04-Apr-2016  ozaki-r 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.49  23-Jan-2016  christos no need for <sys/mbuf.h>
 1.48  23-Mar-2015  roy Add RTF_BROADCAST to mark routes used for the broadcast address when
they are created on the fly. This makes it clear what the route is for
and allows an optimisation in ip_output() by avoiding a call to
in_broadcast() because most of the time we do talk to a host.
It also avoids a needless allocation for the storage of llinfo_arp and
thus vanishes from arp(8) - it showed as incomplete anyway so this
is a nice side effect.

Guard against this and routes marked with RTF_BLACKHOLE in
ip_fastforward().
While here, guard against routes marked with RTF_BLACKHOLE in
ip6_fastforward().
RTF_BROADCAST is IPv4 only, so don't bother checking that here.
 1.47  26-Feb-2015  roy Teach route(8) about RTF_LOCAL.
 1.46  06-Nov-2014  christos Factor out the netstat route printing code and use it here. There is no
point in having 2 different copies; fixes PR/49371
 1.45  01-Mar-2013  joerg branches: 1.45.8;
Retire OSI network stack. OK core@
 1.44  11-Nov-2011  gdt branches: 1.44.6;
Move RTF_ANNOUNCE flag so that it no longer conflicts with RTF_PROTO2.

RTF_ANNOUNCE was defined as RTF_PROTO2. The flag is used to indicated
that host should act as a proxy for a link level arp or ndp request.
(If RTF_PROTO2 is used as an experimental flag (as advertised),
various problems can occur.)

This commit provides a first-class definition with its own bit for
RTF_ANNOUNCE, removes the old aliasing definitions, and adds support
for the new RTF_ANNOUNCE flag to netstat(8) and route(8).,

Also, remove unused RTF_ flags that collide with RTF_PROTO1:
netinet/icmp6.h defined RTF_PROBEMTU as RTF_PROTO1
netinet/if_inarp.h defined RTF_USETRAILERS as RTF_PROTO1
(Neither of these flags are used anywhere. Both have been removed
to reduce chances of collision with RTF_PROTO1.)

Figuring this out and the diff are the work of Beverly Schwartz of
BBN.

(Passed release build, boot in VM, with no apparently related atf
failures.)

Approved for Public Release, Distribution Unlimited
This material is based upon work supported by the Defense Advanced
Research Projects Agency and Space and Naval Warfare Systems Center,
Pacific, under Contract No. N66001-09-C-2073.
 1.43  04-Feb-2011  martin branches: 1.43.4;
Use RT_ROUNDUP() and friends from sys/route.h instead of homegrown
variants.
 1.42  13-Dec-2010  pooka branches: 1.42.2;
Convert from RUMP_ACTION to RUMPPRG.
 1.41  26-Jun-2010  kefren add MPLS clue - mpls and tag keywords
 1.40  26-Jan-2010  is Add AF_APPLETALK support to getnameinfo(); make "route show" use it.
Doesn't print "ranges" yet (should it be done here?); only numeric
output.
 1.39  17-Mar-2009  lukem fix sign-compare issues
 1.38  10-Sep-2008  dyoung branches: 1.38.4;
Constify.
 1.37  09-Sep-2008  dyoung Use EXIT_FAILURE instead of anonymous constant '1'.
 1.36  09-Sep-2008  dyoung Use bool.
 1.35  16-Oct-2006  christos branches: 1.35.18; 1.35.22;
add missing initializer
 1.34  23-Sep-2006  pooka print the L flag for routes with llinfo. makes you not wonder why
non-llinfo routes are being printed for route show -llinfo
 1.33  23-Sep-2006  dyoung Let us qualify 'route flush' and 'route show' commands with -llinfo
and -host flags, which is useful for displaying/flushing ARP entries:

# route -n show -inet -llinfo -host
Routing table

Internet:
Destination Gateway Flags
169.254.1.119 link#1 UH
169.254.230.110 00:02:6f:21:e6:6e UH
# route -n flush -inet -llinfo -host
169.254.1.119 done
169.254.230.110 0.2.6f.21.e6.6e done
169.254.237.70 done
# route -n show -inet -llinfo -host
Routing table
#

This will help me address bin/11079, "dhclient may require arp and sed".

Extract common code from flushroutes() and show(), creating
parse_show_opts().

While I'm here, make small cosmetic changes to flushroutes().
 1.32  23-Sep-2006  dyoung Remove dead code.
 1.31  07-Sep-2006  dogcow remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.30  26-Aug-2006  matt Remove XNS and CCITT/X25 bits.
 1.29  25-Jan-2006  christos PR/32632: Yves-Emmanuel JUTARD: Improvment suggestion in 'route' display.
Add a new -S flag that prints a space for missing flags.
 1.28  31-Aug-2005  ginsbach Add full IPv6 syntax support when route is built with -DSMALL and -DINET6.
Fixes PR/23937. Adapted from supplied patch.
 1.27  30-Aug-2005  ginsbach Clean up some minor nits:
+ style (KNF).
. don't cast NULL
. white space clean up
+ use consistent format for error messages.
+ plug memory leaks and avoid malloc(0).
+ verbose message should display even when routing table is empty
(flushroutes).
 1.26  09-Aug-2005  ginsbach Accept protocol flags, i.e. -inet, -inet6, with the show command.
[From OpenBSD via DragonFly BSD]
 1.25  09-Aug-2005  ginsbach More style nits (KNF); casts and sizeof's are not followed by a space.
 1.24  26-Jun-2005  christos const poisoning.
 1.23  13-May-2005  ginsbach Adjust field width for route -n show similar to netstat -rn when displaying
INET6 route entries.
 1.22  05-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.21  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22308, verified by myself.
 1.20  17-May-2003  itojun strlcpy [a few mistakes found]
 1.19  24-Oct-2001  atatat Print a R on reject routes to indicate that they're not normal routes,
and check netmask (or prefix) length as well as the destination
address when determining if a route is a "default" or not. This means
that the output from 'route show' will no longer say:

Internet6:
Destination Gateway Flags
default localhost UG
default localhost UG

but instead

Internet6:
Destination Gateway Flags
::/104 localhost UGR
::/96 localhost UGR

which makes much more sense.
 1.18  06-Oct-2001  bjh21 When dumping the routing table, use getnameinfo() to print link-layer
addresses rather than doing it ourselves and falling back to link_ntoa().
 1.17  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.16  27-Jan-2001  itojun support RTF_BLACKHOLE.

XXX route show is total duplicate of netstat -r, we need to either remove
route show, or share the same source code, otherwise maintenance cost
bites (and is biting) us
 1.15  10-Oct-2000  is Format string cleanups by Bill Sommerfeld.
 1.14  09-Nov-1999  drochner branches: 1.14.4;
Since our gcc doesn't warn about NULL format strings anymore, we can
fix the incorrect err(1, "%s", "") et al.
Closes PR bin/7592 by cgd.
 1.13  03-Sep-1999  itojun branches: 1.13.4;
remove false fix for routing socket align issue.
 1.12  03-Sep-1999  itojun fix alignment issue in routing socket data, on 64bit arch (i.e. alpha).
sockaddrs are packed with ROUNDUP() in sys/net/rtsock.c so userland
programs needs to follow that.

PR: 8179
 1.11  17-Jul-1999  itojun tweak IPv6 case so that "route show" does not truncate numeric IPv6 address.

PR: 7955
 1.10  12-Jul-1999  itojun avoid using constants, use #define'd values.
 1.9  02-Jul-1999  itojun IPv6-ready route command (-inet6 and -prefixlen are added)
 1.8  23-Oct-1998  lukem branches: 1.8.2;
* implement -f; flush all routes before executing command
* reset af to 0 in flushroutes() and newroute()
* cleanup -DSMALL:
- `flush' and AF_APPLETALK is supported (the latter had partial support)
- AF_NS, AF_ISO, and AF_CCITT are not supported at all (rather than being
- partially unsupported).
 1.7  28-Jul-1998  mycroft __AUDIT__ cleanup.
 1.6  01-Dec-1997  kleink Recognize AF_APPLETALK as "AppleTalk".
 1.5  16-Nov-1997  christos Use {warn,err}{,x}(3) instead of printf's
 1.4  15-Sep-1997  lukem * cleanup for WARNS=1
* use .Nm correctly
* deprecate register
* getopt returns -1 not EOF
 1.3  21-Apr-1997  mrg be safe with buffers.
 1.2  03-Apr-1997  christos - Add netatalk bits
- Add prototypes
- Fix printf formats
 1.1  15-Nov-1996  gwr As discussed some time ago, add a "show" sub-command.
Also allow compilation with -DSMALL to ommit support for
non-essential protocols (i.e. when built into a ramdisk).
Use a less hack-ish way to generate keywords.[ch] and just
check in the result (helps ../../distrib/utils/x_route).
 1.8.2.1  10-Oct-2000  he Pull up revision 1.15 (requested by is):
Format string cleanup.
 1.13.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.14.4.3  05-Apr-2001  he Pull up revision 1.17 (requested by itojun):
Mark cloned routes with RTF_CLONED. Present it in ``netstat -r''
output by ``c''.
 1.14.4.2  05-Apr-2001  he Pull up revision 1.16 (requested by itojun):
Support RTF_BLACKHOLE routes.
 1.14.4.1  18-Oct-2000  tv Pullup sbin string format fixes [is].
See "cvs log" for explicit revision numbers per file, from sommerfeld.
 1.35.22.1  24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.35.18.1  28-Sep-2008  mjf Sync with HEAD.
 1.38.4.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.42.2.1  08-Feb-2011  bouyer Sync with HEAD
 1.43.4.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.43.4.1  17-Apr-2012  yamt sync with head
 1.44.6.1  23-Jun-2013  tls resync from head
 1.45.8.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

RSS XML Feed