Home | History | Annotate | only in /src/sbin/route
History log of /src/sbin/route
RevisionDateAuthorComments
 1.33 03-Jun-2023  lukem bsd.own.mk: rename GCC_NO_* to CC_WNO_*

Rename compiler-warning-disable variables from
GCC_NO_warning
to
CC_WNO_warning
where warning is the full warning name as used by the compiler.

GCC_NO_IMPLICIT_FALLTHRU is CC_WNO_IMPLICIT_FALLTHROUGH

Using the convention CC_compilerflag, where compilerflag
is based on the full compiler flag name.
 1.32 13-Oct-2019  mrg introduce some common variables for use in GCC warning disables:

GCC_NO_FORMAT_TRUNCATION -Wno-format-truncation (GCC 7/8)
GCC_NO_STRINGOP_TRUNCATION -Wno-stringop-truncation (GCC 8)
GCC_NO_STRINGOP_OVERFLOW -Wno-stringop-overflow (GCC 8)
GCC_NO_CAST_FUNCTION_TYPE -Wno-cast-function-type (GCC 8)

use these to turn off warnings for most GCC-8 complaints. many
of these are false positives, most of the real bugs are already
commited, or are yet to come.


we plan to introduce versions of (some?) of these that use the
"-Wno-error=" form, which still displays the warnings but does
not make it an error, and all of the above will be re-considered
as either being "fix me" (warning still displayed) or "warning
is wrong."
 1.31 13-Dec-2017  christos branches: 1.31.4;
Use the definitions from the standard header files and replace homebrew
snprintb with the libutil one.
 1.30 10-Oct-2017  christos user librumpres
 1.29 14-Sep-2015  ozaki-r Include a few additional libc functions in rump.route to make it work with inet6

getaddrinfo and if_nametoindex are newly added to interpret interface names
in IPv6 link-local addresses. if_nametoindex looks not used in rump.route,
but it is needed because it is used indirectly from getaddrinfo.

From s-yamaguchi@IIJ
 1.28 15-May-2015  ozaki-r Fix rump.{netstat,route} shows host's interface names in link local addresses

Interface names of IPv6 link local addresses are resolved
by getnameinfo(3). So we need to rump-ify it as well as
if_indextoname and getifaddrs.
 1.27 22-Apr-2015  ozaki-r Fix rump.route shows host's interface names

Let it use rump-ified if_indextoname and getifaddrs
to get rump kernel's interfaces, which is the same way
as ifconfig.
 1.26 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.25 13-Dec-2010  pooka branches: 1.25.24;
Convert from RUMP_ACTION to RUMPPRG.
 1.24 04-Nov-2010  pooka Support RUMP_ACTION to compile a rump kernel client.
 1.23 26-Aug-2006  matt Remove XNS and CCITT/X25 bits.
 1.22 10-Jan-2005  lukem Only compile in IPv6 support if ${USE_INET6} != "no"

MKINET6 is for providing IPv6 infrastructure.
USE_INET6 is for compiling IPv6 support into the programs (needs MKINET6).
 1.21 26-Oct-2003  lukem Use ${HOST_SH} instead of `sh'.

If necessary, pull in <bsd.sys.mk> to get the definition of HOST_SH;
Makefiles that pull in one of (most of) <bsd.*.mk> will get this anyway.
 1.20 03-Jul-1999  itojun s/CFLAGS/CPPFLAGS/ for -D and -I.
 1.19 02-Jul-1999  itojun IPv6-ready route command (-inet6 and -prefixlen are added)
 1.18 10-Oct-1997  christos CFLAGS->CPPFLAGS
 1.17 09-May-1997  mycroft Eliminate bogus redefinitions of standard targets.
 1.16 03-Apr-1997  christos - Add netatalk bits
- Add prototypes
- Fix printf formats
 1.15 22-Feb-1997  thorpej Now that non-superuser can open the routing socket, this program no
longer needs to be setuid-root. Superuser status is required to
alter the routing table, but is enforced by the kernel.
 1.14 15-Nov-1996  gwr Note that distrib/utils/x_route uses these files.
 1.13 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.12 19-Apr-1995  cgd route.o, not route, depends on keywords.h. from jhawk@mit.edu; pr 978
 1.11 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.10 22-Dec-1994  cgd specify man pages the new way.
 1.9 20-May-1994  cgd don't need that 'all' line.
 1.8 13-May-1994  cgd need dep. first
 1.7 13-May-1994  mycroft Clean up import.
 1.6 01-Aug-1993  mycroft Add RCS identifiers.
 1.5 25-Apr-1993  mycroft Reenable building keywords.h dynamically.
 1.4 25-Apr-1993  mycroft Compile X.25, OSI, and NS code.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 14-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.25.24.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.31.4.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.16 07-Sep-2006  dogcow remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.15 09-Aug-2005  ginsbach More style nits (KNF); casts and sizeof's are not followed by a space.
 1.14 05-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.13 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.12 16-Sep-1997  lukem resolve conflicts from lite-2 import
 1.11 15-Sep-1997  lukem wrap line @ 80 columns
 1.10 15-Sep-1997  lukem * cleanup for WARNS=1
* use .Nm correctly
* deprecate register
* getopt returns -1 not EOF
 1.9 03-Apr-1997  christos - Add netatalk bits
- Add prototypes
- Fix printf formats
 1.8 23-Apr-1995  cgd slightly clean rcs ids, etc.
 1.7 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.6 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.5 13-May-1994  mycroft Clean up import.
 1.4 01-Aug-1993  mycroft Add RCS identifiers.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 14-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.15 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.14 21-Oct-2009  snj branches: 1.14.24;
Remove 3rd and 4th clauses in christos' license. OK christos.
 1.13 10-Sep-2008  dyoung Constify.
 1.12 09-Sep-2008  dyoung Constify.
 1.11 09-Sep-2008  dyoung Shorten a staircase. Remove superfluous parentheses from return
statements. Constify.
 1.10 09-Sep-2008  dyoung Use bool.
 1.9 23-Sep-2006  dyoung branches: 1.9.18; 1.9.22;
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.8 07-Sep-2006  dogcow remove more vestiges of CCITT, LLC, HDLC, NS, and NSIP.
 1.7 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.6 15-Aug-2005  ginsbach Make sure that a netmask socket address value prints appropriately when the
family is unset. Either the destination or interface address socket address
family value is used. This change prevents the following sort of output:

RTM_NEWADDR: address being added to iface: len 60, metric 0, flags:<UP>
sockaddrs: <NETMASK,IFA,BRD>
(0) 00.00.ff.00.00 127.0.0.1 127.0.0.1

With this change the last line becomes:

255.0.0.0 127.0.0.1 127.0.0.1

Also make sure that when using a generated inet netmask the address family
is set. With this change a generated netmask will print appropriately
when using the verbose (-v) option.
 1.5 09-Aug-2005  ginsbach Accept protocol flags, i.e. -inet, -inet6, with the show command.
[From OpenBSD via DragonFly BSD]
 1.4 26-Jun-2005  christos const poisoning.
 1.3 05-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.2 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.1 03-Apr-1997  christos - Add netatalk bits
- Add prototypes
- Fix printf formats
 1.9.22.1 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.9.18.1 28-Sep-2008  mjf Sync with HEAD.
 1.14.24.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.7 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.6 20-Apr-1995  mycroft Implement the document `-llinfo' flag.
 1.5 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.4 13-May-1994  mycroft Clean up import.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 14-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11 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.10 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.9 11-Nov-2011  gdt branches: 1.9.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.8 26-Jun-2010  kefren branches: 1.8.6;
add MPLS clue - mpls and tag keywords
 1.7 12-May-2010  christos PR/40455: Mihai Chelaru: Add noreject noblackhole options
 1.6 06-Aug-2006  dyoung Add route keywords -nocloned, -nocloning.
 1.5 19-Jul-2003  jrf This is an updated submitted patch originally written by Jim Rees
and sent in by Greg Hudson as seen in PR misc/3227. Basically what it
does is adds a flushall option which deletes all but localhost routes.
This is done by andoring in a flag called doall (1 means do all routes
including gateway, 0 means do a regular flush). I have seen some
platforms that do this. I tested it out on ipv4 only, it works as
advertised. Commit was approved by christos@.
 1.4 27-Jan-2001  itojun regen
 1.3 02-Jul-1999  itojun IPv6-ready route command (-inet6 and -prefixlen are added)
 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.6.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.8.6.1 17-Apr-2012  yamt sync with head
 1.9.6.1 23-Jun-2013  tls resync from head
 1.14 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.13 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.12 11-Nov-2011  gdt branches: 1.12.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.11 26-Jun-2010  kefren branches: 1.11.6;
add MPLS clue - mpls and tag keywords
 1.10 12-May-2010  christos PR/40455: Mihai Chelaru: Add noreject noblackhole options
 1.9 06-Aug-2006  dyoung Add route keywords -nocloned, -nocloning.
 1.8 26-Jun-2005  christos const poisoning.
 1.7 19-Jul-2003  jrf This is an updated submitted patch originally written by Jim Rees
and sent in by Greg Hudson as seen in PR misc/3227. Basically what it
does is adds a flushall option which deletes all but localhost routes.
This is done by andoring in a flag called doall (1 means do all routes
including gateway, 0 means do a regular flush). I have seen some
platforms that do this. I tested it out on ipv4 only, it works as
advertised. Commit was approved by christos@.
 1.6 27-Jan-2001  itojun regen
 1.5 02-Jul-1999  itojun IPv6-ready route command (-inet6 and -prefixlen are added)
 1.4 03-Apr-1997  christos - Add netatalk bits
- Add prototypes
- Fix printf formats
 1.3 16-Dec-1996  cgd declare the keywords structure 'extern' in keywords.h, to avoid a common defn.
 1.2 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.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.2 25-Apr-1993  mycroft Clean up deleted files.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.11.6.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.11.6.1 17-Apr-2012  yamt sync with head
 1.12.6.1 23-Jun-2013  tls resync from head
 1.11 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.10 11-Nov-2011  gdt branches: 1.10.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.9 26-Jun-2010  kefren branches: 1.9.6;
add MPLS clue - mpls and tag keywords
 1.8 12-May-2010  kefren Update also keywords.{c,h} generator in order to reflect latest changes.
 1.7 19-Jul-2003  jrf This is an updated submitted patch originally written by Jim Rees
and sent in by Greg Hudson as seen in PR misc/3227. Basically what it
does is adds a flushall option which deletes all but localhost routes.
This is done by andoring in a flag called doall (1 means do all routes
including gateway, 0 means do a regular flush). I have seen some
platforms that do this. I tested it out on ipv4 only, it works as
advertised. Commit was approved by christos@.
 1.6 27-Jan-2001  itojun add a keyword, cloned
 1.5 02-Jul-1999  itojun IPv6-ready route command (-inet6 and -prefixlen are added)
 1.4 03-Apr-1997  christos - Add netatalk bits
- Add prototypes
- Fix printf formats
 1.3 16-Dec-1996  cgd declare the keywords structure 'extern' in keywords.h, to avoid a common defn.
 1.2 15-Nov-1996  gwr Remove comment that was no longer applicable.
 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.9.6.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.9.6.1 17-Apr-2012  yamt sync with head
 1.10.6.1 23-Jun-2013  tls resync from head
 1.5 03-Apr-2020  martin Make route and netstat share the same struct progops (and initialization
code)
 1.4 02-Apr-2020  christos Add a prog_setsockopt (thanks kre@)
 1.3 06-Nov-2014  christos branches: 1.3.16;
Factor out the netstat route printing code and use it here. There is no
point in having 2 different copies; fixes PR/49371
 1.2 13-Dec-2010  pooka branches: 1.2.24;
be a happy crunch build
 1.1 13-Dec-2010  pooka Convert from RUMP_ACTION to RUMPPRG.
 1.2.24.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.3.16.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.65 02-Jan-2021  uwe route(8): group RTF_GATEWAY and ~RTF_GATEWAY (-iface).

While here, tweak RTF_GATEWAY description. Passive voice elsewhere in
this table is used to talk about the routes themselves, while here
it's about packets.
 1.64 02-Jan-2021  uwe route(8): be consistent about capitalization.
 1.63 02-Jan-2021  uwe route(8): don't split -blackhole and -noblackhole.
 1.62 29-Aug-2020  christos Document 'L'
 1.61 31-Jul-2018  sevan Remove references to XNS
 1.60 04-Jul-2017  wiz branches: 1.60.4; 1.60.6;
Use Ex.
 1.59 03-Jul-2017  wiz Remove workaround for ancient HTML generation code.
 1.58 19-Jun-2017  wiz Remove unnecessary Pp.
 1.57 16-Jun-2017  ozaki-r Support -c <count> option for route monitor

route command exits if it receives <count> routing messages where
<count> is a value specified by -c.

The option is useful to get only particular message(s) in a test script.
 1.56 04-Apr-2016  ozaki-r branches: 1.56.8;
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.55 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.54 26-Feb-2015  roy Teach route(8) about RTF_LOCAL.
 1.53 01-Dec-2014  christos Complete the routing argument table by including the ID's used in the routing
display.
 1.52 12-Nov-2014  christos PR/47704: Takahiro HAYASHI: Add -L flag
 1.51 07-Nov-2014  christos Now that the code can support tags and verbose route printing, enable them.
Also document previously undocumented flags.
 1.50 05-Nov-2013  kefren Remove esis reference
 1.49 07-Oct-2013  dholland english usage patrol
 1.48 24-Jul-2013  kefren Add -tag description as suggested in PR/45071
 1.47 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.46 11-Nov-2011  gdt branches: 1.46.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.45 17-Jul-2011  dholland branches: 1.45.2;
prune stray commas
 1.44 03-Jul-2011  wiz Whitespace nit.
 1.43 03-Jul-2011  kefren Mention -mpls and -tag and xref mpls(4)
bin/45071
 1.42 16-Jun-2011  yamt xref link_addr for -link.
 1.41 12-May-2010  christos branches: 1.41.4;
PR/40455: Mihai Chelaru: Add noreject noblackhole options
 1.40 06-Aug-2006  wiz Bump date for previous.
 1.39 06-Aug-2006  dyoung Document -nocloning, -nocloned flags. Shift a couple of columns
right by a character width, to make room for the new flags.
 1.38 29-Jan-2006  wiz Use default option order (AaBbCc...).
 1.37 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.36 02-Oct-2003  itojun correct typo. PR misc/22944
 1.35 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.34 07-Aug-2003  wiz Bump date for flushall description.
 1.33 19-Jul-2003  jrf This is an updated submitted patch originally written by Jim Rees
and sent in by Greg Hudson as seen in PR misc/3227. Basically what it
does is adds a flushall option which deletes all but localhost routes.
This is done by andoring in a flag called doall (1 means do all routes
including gateway, 0 means do a regular flush). I have seen some
platforms that do this. I tested it out on ipv4 only, it works as
advertised. Commit was approved by christos@.
 1.32 03-Jun-2003  itojun permit foo/bar notation, like "route add 10.0.0.0/8 127.0.0.1".
originally by provos
 1.31 25-Feb-2003  wiz Split .Nm with other macro arguments on two lines.
 1.30 03-Oct-2002  wiz New sentence, new line. From Robert Elz.
 1.29 08-Feb-2002  hubertf branches: 1.29.2;
the modifiers (-inet6, ...) do not only affect the behaviour of "flush",
but at least also of "get", so make the wording a bit more general.
 1.28 08-Feb-2002  ross Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.27 16-Nov-2001  wiz Punctuation fix, sort sections, sort SEE ALSO.
 1.26 24-Oct-2001  atatat Provide a short output format for the get command that only prints the
address corresponding to RTA_GATEWAY, or nothing if it doesn't exist.
Modify the exit value of route depending on this, so that one can do
stuff like:

#!/bin/sh
gw=`route -sn get default 2>/dev/null`
if [ -z "$gw" ]; then
echo no default route
exit 1
fi
ping -w1 -c1 $gw >/dev/null 2>&1
if ! route -sn get $gw >/dev/null; then
echo default gateway not responding
exit 1
fi
echo default gateway is at $gw
 1.25 18-Oct-2001  christos PR/14286: reed@reedmedia.net: Explain default.
 1.24 20-Jul-2001  itojun make prefixlen work on IPv4 too
 1.23 05-Jun-2001  wiz Fix Nd and some whitespace and punctuation.
 1.22 05-Jun-2001  wiz Drop arguments of .Os.
 1.21 27-Apr-2001  manu Added a few examples and a reference to sysctl to enable IP forwarding
Approved by Christos
 1.20 27-Jan-2001  itojun support -cloned command line flag.
i don't think anyone ever going to use it.
 1.19 17-Jul-1999  itojun tweak IPv6 case so that "route show" does not truncate numeric IPv6 address.

PR: 7955
 1.18 02-Jul-1999  itojun IPv6-ready route command (-inet6 and -prefixlen are added)
 1.17 24-Mar-1999  mycroft Remove spurious .ne's.
 1.16 04-Mar-1999  bgrayson Typo fixed
 1.15 23-Oct-1998  lukem * 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.14 29-Apr-1998  fair fix bad .Xr references
 1.13 16-Sep-1997  lukem resolve conflicts from lite-2 import
 1.12 15-Sep-1997  lukem * cleanup for WARNS=1
* use .Nm correctly
* deprecate register
* getopt returns -1 not EOF
 1.11 27-Aug-1997  mikel fix numerous tyops and use some -mdoc macros to advantage
 1.10 10-Jul-1997  mikel comment out xref to XNSrouted(8)
 1.9 03-Apr-1997  christos - Add netatalk bits
- Add prototypes
- Fix printf formats
 1.8 22-Feb-1997  carrel Remove uid checks since the kernel now handles this and route(1) is no
longer setuid.
Document the "Permission denied" msg in the man page since this is
_slightly_ less clear than route(1)'s old error msg.
 1.7 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.6 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.5 13-May-1994  mycroft Clean up import.
 1.4 01-Aug-1993  mycroft Add RCS indentifiers.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 14-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.29.2.1 02-Oct-2003  tron Pull up revision 1.36 (requested by itojun in ticket #1494):
correct typo. PR misc/22944
 1.41.4.1 23-Jun-2011  cherry Catchup with rmind-uvmplock merge.
 1.45.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.45.2.1 17-Apr-2012  yamt sync with head
 1.46.6.2 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.46.6.1 23-Jun-2013  tls resync from head
 1.56.8.1 07-Jul-2017  martin Pull up following revision(s) (requested by ozaki-r in ticket #107):
usr.sbin/arp/arp.c: revision 1.56
sys/net/rtsock.c: revision 1.218
sys/net/if_llatbl.c: revision 1.20
usr.sbin/arp/arp.c: revision 1.57
sys/net/rtsock.c: revision 1.219
sys/net/if_llatbl.c: revision 1.21
usr.sbin/arp/arp.c: revision 1.58
tests/net/net_common.sh: revision 1.19
sys/netinet6/nd6.h: revision 1.84
sys/netinet6/nd6.h: revision 1.85
tests/net/arp/t_arp.sh: revision 1.23
sys/netinet6/in6.c: revision 1.246
tests/net/arp/t_arp.sh: revision 1.24
sys/netinet6/in6.c: revision 1.247
tests/net/arp/t_arp.sh: revision 1.25
sys/netinet6/in6.c: revision 1.248
tests/net/arp/t_arp.sh: revision 1.26
usr.sbin/ndp/ndp.c: revision 1.49
tests/net/arp/t_arp.sh: revision 1.27
tests/net/ndp/t_ndp.sh: revision 1.20
tests/net/arp/t_arp.sh: revision 1.28
tests/net/ndp/t_ndp.sh: revision 1.21
tests/net/arp/t_arp.sh: revision 1.29
tests/net/ndp/t_ndp.sh: revision 1.22
tests/net/ndp/t_ndp.sh: revision 1.23
tests/net/route/t_flags6.sh: revision 1.13
tests/net/ndp/t_ndp.sh: revision 1.24
tests/net/route/t_flags6.sh: revision 1.14
tests/net/ndp/t_ndp.sh: revision 1.25
tests/net/route/t_flags6.sh: revision 1.15
tests/net/ndp/t_ndp.sh: revision 1.26
sbin/route/rtutil.c: revision 1.9
tests/net/ndp/t_ndp.sh: revision 1.27
tests/net/ndp/t_ndp.sh: revision 1.28
tests/net/net/t_ipv6address.sh: revision 1.14
tests/net/ndp/t_ra.sh: revision 1.28
tests/net/ndp/t_ndp.sh: revision 1.29
sys/net/route.h: revision 1.113
tests/net/ndp/t_ra.sh: revision 1.29
sys/net/rtsock.c: revision 1.220
sys/net/rtsock.c: revision 1.221
sys/net/rtsock.c: revision 1.222
sys/net/rtsock.c: revision 1.223
tests/net/route/t_route.sh: revision 1.13
sys/net/rtsock.c: revision 1.224
sys/net/route.c: revision 1.196
sys/net/if_llatbl.c: revision 1.19
sys/net/route.c: revision 1.197
sbin/route/route.c: revision 1.156
tests/net/route/t_flags.sh: revision 1.16
tests/net/route/t_flags.sh: revision 1.17
usr.sbin/ndp/ndp.c: revision 1.50
tests/net/route/t_flags.sh: revision 1.18
sys/netinet/in.c: revision 1.204
tests/net/route/t_flags.sh: revision 1.19
sys/netinet/in.c: revision 1.205
tests/net/arp/t_arp.sh: revision 1.30
tests/net/arp/t_arp.sh: revision 1.31
sys/net/if_llatbl.h: revision 1.11
tests/net/arp/t_arp.sh: revision 1.32
sys/net/if_llatbl.h: revision 1.12
tests/net/arp/t_arp.sh: revision 1.33
sys/netinet6/nd6.c: revision 1.233
sys/netinet6/nd6.c: revision 1.234
sys/netinet/if_arp.c: revision 1.251
sys/netinet6/nd6.c: revision 1.235
sys/netinet/if_arp.c: revision 1.252
sbin/route/route.8: revision 1.57
sys/net/rtsock.c: revision 1.214
sys/net/rtsock.c: revision 1.215
sys/net/rtsock.c: revision 1.216
sys/net/rtsock.c: revision 1.217
whitespace police
Simplify
We can assume that rt_ifp is always non-NULL.
Sending a routing message (RTM_ADD) on adding an llentry
A message used to be sent on adding a cloned route. Restore the
behavior for backward compatibility.
Requested by ryo@
Drop RTF_CONNECTED from a result of RTM_GET for ARP/NDP entries
ARP/NDP entries aren't connected routes.
Reported by ryo@
Support -c <count> option for route monitor
route command exits if it receives <count> routing messages where
<count> is a value specified by -c.
The option is useful to get only particular message(s) in a test script.
Test routing messages emitted on operations of ARP/NDP entries
Do netstat -a for an appropriate protocol
Add missing declarations for cleanup
Set net.inet.arp.keep only if it's required
Don't create a permanent L2 cache entry on adding an address to an interface
It was created to copy FreeBSD, however actually the cache isn't
necessary. Remove it to simplify the code and reduce the cost to
maintain it (e.g., keep a consistency with a corresponding local
route).
Fix typo
Fix in_lltable_match_prefix
The function has not been used but will be used soon.
Remove unused function (nd6_rem_ifa_lle)
Allow in6_lltable_free_entry to be called without holding the afdata lock of ifp as well as in_lltable_free_entry
This behavior is a bit odd and should be fixed in the future...
Purge ARP/NDP entries on an interface when the interface is down
Fix PR kern/51179
Purge all related L2 caches on removing a route
The change addresses situations similar to PR 51179.
Purge L2 caches on changing an interface of a route
The change addresses situations similar to PR 51179.
Test implicit removals of ARP/NDP entries
One test case reproudces PR 51179.
Fix build of kernels without both INET and INET6
Tweak lltable_sysctl_dumparp
- Rename lltable_sysctl_dumparp to lltable_sysctl_dump
because it's not only for ARP
- Enable it not only for INET but also for INET6
Fix usage of routing messages on arp -d and ndp -d
It didn't work as we expected; we should set RTA_GATEWAY not
RTA_IFP on RTM_GET to return an if_index and the kernel should
use it on RTM_DELETE.
Improve backward compatibility of (fake) routing messages on adding an ARP/NDP entry
A message originally included only DST and GATEWAY. Restore it.
Fix ifdef; care about a case w/ INET6 and w/o INET
Drop RTF_UP from a routing message of a deleted ARP/NDP entry
Check existence of ARP/NDP entries
Checking ARP/NDP entries is valid rather than checking routes.
Fix wrong comment
Drop RTF_LLINFO flag (now it's RTF_LLDATA) from local routes
They don't have llinfo anymore. And also the change fixes unexpected
behavior of ARP proxy.
Restore ARP/NDP entries to route show and netstat -r
Requested by dyoung@ some time ago
Enable to remove multiple ARP/NDP entries for one destination
The kernel can have multiple ARP/NDP entries which have an indentical
destination on different interfaces. This is normal and can be
reproduce easily by ping -I or ping6 -S. We should be able to remove
such entries.
arp -d <ip> and ndp -d <ip> are changed to fetch all ARP/NDP entries
and remove matched entries. So we can remove multiple entries
described above. This fetch all and selective removal behavior is
the same as arp <ip> and ndp <ip>; they also do fetch all entries
and show only matched entries.
Related to PR 51179
Check if ARP/NDP entries are purged when a related route is deleted
 1.60.6.1 10-Jun-2019  christos Sync with HEAD
 1.60.4.1 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.169 10-Apr-2022  andvar fix various typos in comments and output/log messages.
 1.168 02-Apr-2020  christos Add a prog_setsockopt (thanks kre@)
 1.167 14-Mar-2020  roy route: Enable receive error reporting on the routing socket
 1.166 22-Feb-2020  kamil Avoid undefined behavior

route.c:1523:20, left shift of 1073741824 by 1 places cannot be represented
in type 'int'
 1.165 22-Jan-2020  roy route: address flags are more useful than interface flags for address msgs
 1.164 22-Jan-2020  roy route: Decode the correct flags for interface address messages
 1.163 02-Sep-2019  roy route(8): Show addres for RTM_LOSING

While here, add /* FALLTHROUGH */.
 1.162 31-Aug-2019  roy route(8): show addrs for RTM_MISS
 1.161 22-Aug-2019  roy route(8): print RTM_CHANGE messages

XXX Pullup -9
 1.160 14-Aug-2018  roy branches: 1.160.2;
Resolve every route(4) message type before printing anything more about it
other than the type and length.

This solves the issue where RTM_ONEWADDR is received and it tries to
parse route information from it.
 1.159 23-Mar-2018  roy branches: 1.159.2;
Handle the routing socket overflowing gracefully.
 1.158 13-Dec-2017  christos branches: 1.158.2;
Use the definitions from the standard header files and replace homebrew
snprintb with the libutil one.
 1.157 13-Dec-2017  uwe Fix typo in flag name. We should probably just use IFFBITS string
that <net/if.h> defines.

PR bin/52815
 1.156 16-Jun-2017  ozaki-r Support -c <count> option for route monitor

route command exits if it receives <count> routing messages where
<count> is a value specified by -c.

The option is useful to get only particular message(s) in a test script.
 1.155 17-Mar-2017  roy branches: 1.155.4;
Report the PID for the process changing the address.
 1.154 04-Apr-2016  ozaki-r branches: 1.154.2; 1.154.4;
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.153 23-Jan-2016  christos no need for <sys/mbuf.h>
 1.152 17-Jan-2016  christos PR/50671: David Binderman: fix memory leak.
 1.151 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.150 26-Feb-2015  roy Teach route(8) about RTF_LOCAL.
 1.149 20-Dec-2014  prlw1 MKINET6=no build fixes

http://mail-index.netbsd.org/tech-net/2014/12/13/msg004898.html
 1.148 17-Dec-2014  roy Note that RTM_CHANGE can also change the gateway
 1.147 12-Nov-2014  christos PR/47704: Takahiro HAYASHI: Add -L flag
 1.146 07-Nov-2014  christos Now that the code can support tags and verbose route printing, enable them.
Also document previously undocumented flags.
 1.145 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.144 19-Oct-2013  christos branches: 1.144.4;
use correct function
 1.143 19-Oct-2013  christos use symbolic flags
 1.142 19-Oct-2013  christos use scopeid functions
 1.141 18-Oct-2013  christos avoid pointer gymnastics
 1.140 01-Mar-2013  joerg Retire OSI network stack. OK core@
 1.139 04-Oct-2012  uwe Fix fallout from 1.129 that converted sou::so_foo from unions to
pointers but missed (char *)&soup->so_foo => (char *)soup->so_foo in
mask_addr(). It worked by luck - unless it didn't: due to pointer
numerology on amd64 route add -net ClassC without explicit /24 prefix
length specification would result into /16 destination instead of /24.
 1.138 08-Aug-2012  christos branches: 1.138.2;
remove useless rump headers.
 1.137 17-Mar-2012  christos PR/42179: Christoph Badura: Be a little friendlier about missing args.
 1.136 26-Dec-2011  christos branches: 1.136.2;
Off by one and clarity improvement from Christian Biere
 1.135 24-Dec-2011  christos PR/45661: Henning Petersen: Overlapping buffer in route.c.
 1.134 11-Nov-2011  gdt 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.133 07-Oct-2011  joerg branches: 1.133.2;
Simplify.
 1.132 29-Aug-2011  joerg Use __dead
 1.131 01-Jul-2011  joerg Fix memset usage.
 1.130 22-Jun-2011  kefren don't compile tag functions if SMALL is defined. Should fix the build
 1.129 21-Jun-2011  kefren Alloc dynamically sockunions in sou.
Teach route(8) about multiple tags. E.G.: -tag 100,20,33
XXX: needs documentation
 1.128 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.127 13-Dec-2010  pooka branches: 1.127.2;
Convert from RUMP_ACTION to RUMPPRG.
 1.126 12-Nov-2010  roy Support the new RTM_IFINFO and RTM_CHGADDR messages.
 1.125 05-Nov-2010  pooka adapt to new rumpclient_init() signature
 1.124 04-Nov-2010  pooka #ifdef variable correctly
 1.123 04-Nov-2010  pooka be consistent in what to leave outside of SMALL
 1.122 04-Nov-2010  pooka Support RUMP_ACTION to compile a rump kernel client.
 1.121 26-Jun-2010  kefren add MPLS clue - mpls and tag keywords
 1.120 12-May-2010  christos PR/40455: Mihai Chelaru: Add noreject noblackhole options
 1.119 28-Dec-2008  christos parse unsigned long with strtoul not atoi
 1.118 10-Sep-2008  dyoung branches: 1.118.6;
Get the socket addresses for dst/gateway/netmask/interface/ifaddr
out of the global namespace.
 1.117 10-Sep-2008  dyoung Don't cast a sockunion * to sockaddr *. Instead, reference the
sockaddr inside of the sockunion.
 1.116 10-Sep-2008  dyoung Delete superfluous casts to void *.
 1.115 10-Sep-2008  dyoung Constify.
 1.114 10-Sep-2008  dyoung Constify.
 1.113 10-Sep-2008  dyoung Constify.

For clarity's sake, do not assign a new value to inet_makenetandmask()'s
argument, `inet'.
 1.112 09-Sep-2008  dyoung Extract subroutine extract_addrs() for reuse, later.

Replace the anonymous constant, 0, with AF_UNSPEC.
 1.111 09-Sep-2008  dyoung Constify.
 1.110 09-Sep-2008  dyoung Shorten a staircase. Remove superfluous parentheses from return
statements. Constify.
 1.109 09-Sep-2008  dyoung Use a union and sizeof() to avoid a cast and an anonymous constant
buffer length, respectively.
 1.108 09-Sep-2008  dyoung Use bool.
 1.107 20-Jul-2008  lukem Remove the \n and tabs from the __COPYRIGHT() strings.
(Tweak some to use a consistent format.)
 1.106 18-Feb-2007  hubertf branches: 1.106.12; 1.106.16;
TSEL() is const char* now
 1.105 11-Nov-2006  apb Fix a bug that caused 0.0.0.0/0 to be treated like 0.0.0.0/32.

foo << 32 is undefined per section 6.5.7 of the C99 standard
if foo is (or is promoted to) a 32-bit type.
 1.104 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.103 23-Sep-2006  dyoung Move the #ifndef SMALL code together.
 1.102 23-Sep-2006  dyoung Use the symbol AF_UNSPEC instead of 0 as appropriate.
 1.101 23-Sep-2006  dyoung Remove dead code.
 1.100 26-Aug-2006  matt Remove XNS and CCITT/X25 bits.
 1.99 06-Aug-2006  dyoung KNF err(3), errx(3) usage, indentation, braces.
 1.98 06-Aug-2006  dyoung Add route keywords -nocloned, -nocloning.
 1.97 29-Jan-2006  wiz Use default option order (AaBbCc...).
 1.96 26-Jan-2006  is Print the INET netmask if it is non-contiguous.
 1.95 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.94 25-Jan-2006  christos PR/32629: Yves-Emmanuel JUTARD: Type errors in sbin/route/route.c, another
u_char/char conflict.
 1.93 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.92 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.91 15-Aug-2005  ginsbach Make sure that a netmask socket address value prints appropriately when the
family is unset. Either the destination or interface address socket address
family value is used. This change prevents the following sort of output:

RTM_NEWADDR: address being added to iface: len 60, metric 0, flags:<UP>
sockaddrs: <NETMASK,IFA,BRD>
(0) 00.00.ff.00.00 127.0.0.1 127.0.0.1

With this change the last line becomes:

255.0.0.0 127.0.0.1 127.0.0.1

Also make sure that when using a generated inet netmask the address family
is set. With this change a generated netmask will print appropriately
when using the verbose (-v) option.
 1.90 12-Aug-2005  ginsbach Make sure the get command always exits non-zero on error. This makes things
like the following work as expected.

#!/bin/sh

if ! route -sn get default >/dev/null 2>&1; then
echo default gateway not set
exit 1
fi
echo default gateway set

Handle routing socket write(2) errors when they occur. This produces
better diagnostics by allowing for handling of the special route errno
values ESRCH, EBUSY, and ENOBUFS even with the quiet (-q) option or
when doing a get command.
 1.89 12-Aug-2005  ginsbach Trim the local domain name in routename() for INET6 lookups; similar to
INET lookups.
 1.88 10-Aug-2005  he Make this build for __GNUC__ <= 2 (i.e. for vax). The cast to
caddr_t removes a const qualifier. Instead, cast the first element
of the subtraction to "struct sockaddr *" to work around the problem.
 1.87 09-Aug-2005  ginsbach Accept protocol flags, i.e. -inet, -inet6, with the show command.
[From OpenBSD via DragonFly BSD]
 1.86 09-Aug-2005  ginsbach Fix the default case in sodump(). Printing the address of the "which"
string isn't really that useful. Instead print the string and the value
of sa_family.
 1.85 09-Aug-2005  ginsbach More style nits (KNF); casts and sizeof's are not followed by a space.
 1.84 20-Jul-2005  ginsbach switch is not a function, so add a space; sort switch elements
alphabetically (KNF).
 1.83 15-Jul-2005  ginsbach * Exit non-zero error code when flushroute() fails operating on the
routing socket, e.g. running route flush as non-root.

* When quiet (-q) don't append error string to a non-existent
diagnostic output (stdout). The error diagnostic is still written
to stderr. [from FreeBSD]

* Use warn(3) in place of perror(3).
 1.82 26-Jun-2005  christos const poisoning.
 1.81 25-Jun-2005  dyoung Teach route(8) to print the messages generated by net80211.
 1.80 19-May-2005  ginsbach Convert prefixlen() to ANSI function declaration. Missed by earlier
conversion.
 1.79 19-May-2005  ginsbach Due to a limitation in inet_addr(3) it was not possible to specify a
netmask value of 0xffffffff (INADDR_NONE). Fix by using inet_aton(3).
Note it was possible to specify the same mask as the dotted quad
255.255.255.255 because of a later call to gethostbyname(3).
[From FreeBSD]
 1.78 13-May-2005  ginsbach Fix botched prior commit. Additional debugging error messages mistakenly
committed.
 1.77 12-May-2005  ginsbach * Honor -net when using CIDR (net/mask) notation. This differs
from the default CIDR (host/mask) interpretation. As discussed on
tech-net.

* Use errx() in place of fprintf() and exit(). Make the error message
formats consistent.
 1.76 10-May-2005  ginsbach Fix macro NEXTADDR so that the names, like so_dst, are printed
rather than u. The preprocessor doesn't do replacement within
strings, so the # string creation operator must be used.
 1.75 05-Feb-2005  xtraeme Kill __P(), use ANSI function declarations.
 1.74 16-Nov-2004  itojun NI_WITHSCOPEID was not picked up by IETF standardization process.
 1.73 15-May-2004  itojun bump buffer size for any_ntoa(), for huge sa_len
 1.72 15-May-2004  itojun 2-byte read overrun for unknown sockaddr. from openbsd
XXX out[64], is it safe? what if sa_len > 23?
 1.71 05-Jan-2004  jmmv Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
 1.70 01-Oct-2003  itojun print prefixlen on -show
 1.69 16-Sep-2003  cube Remove a comment that referred to a non-committed part of the patch I
submitted for bin/17613. Ok'd by mrg@.
 1.68 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.67 19-Jul-2003  jrf This is an updated submitted patch originally written by Jim Rees
and sent in by Greg Hudson as seen in PR misc/3227. Basically what it
does is adds a flushall option which deletes all but localhost routes.
This is done by andoring in a flag called doall (1 means do all routes
including gateway, 0 means do a regular flush). I have seen some
platforms that do this. I tested it out on ipv4 only, it works as
advertised. Commit was approved by christos@.
 1.66 11-Jun-2003  christos PR/21856: Robert Elz: Changes to route(8) to allow /n instead of -prefixlen
for INET6
 1.65 03-Jun-2003  itojun permit foo/bar notation, like "route add 10.0.0.0/8 127.0.0.1".
originally by provos
 1.64 17-May-2003  itojun strlcpy [a few mistakes found]
 1.63 21-Apr-2003  jrf This addresses PR 17613 when certain methods of adding routes would
muck up the routing tables. The patch was submitted by Quentin Garnier
<netbsd@quatriemek.com> and tweaked a little after it was reviewed
by Christos Zoulas <christos@netbsd.org>. Final change/commit approved
by Christos.
 1.62 03-Apr-2003  jrf Made a note in the code about the -d and -d options brought up in
PR 18674. Thanks to Chris Jones for pointing it out.
 1.61 18-Oct-2002  itojun correct prefixlen handling for IPv4.
 1.60 18-Oct-2002  itojun Make prefixlen check to make sure its argument is present before deref
from openbsd
 1.59 20-Jul-2002  grant sweep of errx/warnx, remove unnecessary trailing \n
 1.58 10-Jun-2002  itojun permit DNS names to address portion. they will be considered as RTF_HOST
if specified as destination (as there's no getnetbyname in IPv6).
 1.57 05-Jun-2002  itojun if we're unsure about prefixlen, don't say "128".
 1.56 05-Jun-2002  itojun more correct ion to RTF_HOST handling.
 1.55 04-Jun-2002  itojun do not have -prefixlen 128 on RTF_HOST.
From: Dawid Szymanski <dawszy@arhea.net>
 1.54 20-May-2002  itojun branches: 1.54.2;
raise RTF_HOST if destination is a host (/128). from ume
 1.53 21-Feb-2002  christos PR/15672: Love: route monitor missing info
 1.52 15-Nov-2001  christos Make route exit with a non-zero error code when operations to the routing
socket fails. eg, running route add 1.2.3.4 5.6.7.8 as non root.
 1.51 02-Nov-2001  lukem fix -Wshadow warnings
 1.50 24-Oct-2001  atatat Provide a short output format for the get command that only prints the
address corresponding to RTA_GATEWAY, or nothing if it doesn't exist.
Modify the exit value of route depending on this, so that one can do
stuff like:

#!/bin/sh
gw=`route -sn get default 2>/dev/null`
if [ -z "$gw" ]; then
echo no default route
exit 1
fi
ping -w1 -c1 $gw >/dev/null 2>&1
if ! route -sn get $gw >/dev/null; then
echo default gateway not responding
exit 1
fi
echo default gateway is at $gw
 1.49 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.48 20-Jul-2001  itojun off-by-one error in -prefixlen arg validation (do not permit 129 on IPv6)
 1.47 20-Jul-2001  itojun make prefixlen work on IPv4 too
 1.46 16-Jul-2001  bad The way pmsg_addrs() is used requires that it always prints a newline and
flushes stdout before returning.

Previously the decoded output for a message was stuck in stdio buffers until
the next arrived.
 1.45 19-Feb-2001  cgd convert to use getprogname()
 1.44 04-Feb-2001  christos remove nested externs.
 1.43 27-Jan-2001  itojun support -cloned command line flag.
i don't think anyone ever going to use it.
 1.42 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.41 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.40 27-Jan-2001  itojun remove use of uninitialized route (struct ortentry).
it seems that the bug was born during 4.3reno -> 4.4Lite1 transition.
 1.39 10-Oct-2000  itojun on "route monitor", print RTM_IFANNOUNCE, RTM_IFINFO (new #), and others.
 1.38 04-May-2000  sommerfeld branches: 1.38.4;
Allow INET6 to be used with SMALL without undefined symbols
 1.37 20-Apr-2000  itojun use scoped notation for link-local multicast too.
 1.36 20-Apr-2000  itojun support extended scoped address notation (fe80::1%de0).
it hides implementation detail (embedded ifid) from the users.
 1.35 03-Dec-1999  itojun don't make "-prefixlen 64" a default in -inet6 case. the past behavior
was not compatible with past practice ("route get" did not work right).

sync with recent KAME.
 1.34 01-Nov-1999  sommerfeld Display local address associated with route (if any) in "route get".
 1.33 03-Sep-1999  itojun branches: 1.33.2;
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.32 06-Jul-1999  mjacob Incorrect integration. ctime takes a time_t value, not a long.
 1.31 02-Jul-1999  itojun IPv6-ready route command (-inet6 and -prefixlen are added)
 1.30 23-Oct-1998  lukem branches: 1.30.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.29 26-Jul-1998  mycroft const poisoning.
 1.28 01-Apr-1998  kleink Need <time.h> for time() prototype.
 1.27 05-Feb-1998  ross 64-bit sweep, "route -v show" was spinning forever.
 1.26 16-Nov-1997  christos Use {warn,err}{,x}(3) instead of printf's
 1.25 01-Oct-1997  enami Don't declare optind.
 1.24 16-Sep-1997  lukem resolve conflicts from lite-2 import
 1.23 15-Sep-1997  lukem * cleanup for WARNS=1
* use .Nm correctly
* deprecate register
* getopt returns -1 not EOF
 1.22 02-Sep-1997  thorpej Fix uninitialized pointer botch when attempting to flush an already
empty routing table. From Matthias Scheler <tron@lyssa.owl.de>, in
PR #4074.
 1.21 27-Apr-1997  thorpej Don't SEGV if a qualifier is passed without an argument. From
Geoff Wing <mason@primenet.com.au>, fixes PR #2700.
 1.20 21-Apr-1997  mrg KNF. be safe with buffers.
 1.19 03-Apr-1997  christos - Add netatalk bits
- Add prototypes
- Fix printf formats
 1.18 22-Feb-1997  carrel Remove uid checks since the kernel now handles this and route(1) is no
longer setuid.
Document the "Permission denied" msg in the man page since this is
_slightly_ less clear than route(1)'s old error msg.
 1.17 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.16 15-Apr-1996  cgd check returns of inet_addr() and inet_network() against INADDR_NONE,
not -1, per the manual page. on 64-bit systems like the alpha, -1 will
never equal (unsigned long)INADDR_NONE.
 1.15 07-Jan-1996  pk Produce less output on -q as promised by the man page (John Hawkinson; PR#998).
 1.14 20-Apr-1995  mycroft Interface-specific routes can be static.
 1.13 20-Apr-1995  mycroft Implement the document `-llinfo' flag.
 1.12 18-Apr-1995  mycroft Remove extra `break;'.
 1.11 18-Mar-1995  cgd convert to new RCS Id conventions; reduce my headache
 1.10 24-Dec-1994  cgd kill some extraneous equal signs.
 1.9 23-Sep-1994  mycroft Remove some more uses of obsolete functions.
 1.8 23-Sep-1994  mycroft Eliminate uses of some obsolete functions.
 1.7 13-May-1994  mycroft Clean up import.
 1.6 01-Aug-1993  mycroft Add RCS identifiers.
 1.5 25-Apr-1993  mycroft Compile X.25, OSI, and NS code.
 1.4 18-Apr-1993  mycroft Cleanup for GCC 2.
 1.3 23-Mar-1993  cgd changed "Id" to "Header" for rcsids
 1.2 22-Mar-1993  cgd added rcs ids to all files
 1.1 21-Mar-1993  cgd branches: 1.1.1;
Initial revision
 1.1.1.3 16-Sep-1997  lukem imported from lite-2
 1.1.1.2 14-Jun-1994  mycroft Import 4.4-Lite version.
 1.1.1.1 21-Mar-1993  cgd initial import of 386bsd-0.1 sources
 1.30.2.1 14-Jan-2002  he Pull up revision 1.46 (requested by bad):
Fix problem where an output message would be stuck in stdio buffers
until the next one arrived.
 1.33.2.1 27-Dec-1999  wrstuden Pull up to last week's -current.
 1.38.4.6 18-Oct-2002  itojun sbin/route/route.c 1.60-1.61 via patch

Correct prefixlen option handling.

(itojun)
 1.38.4.5 29-Jul-2001  he Pull up revision 1.46 (requested by bad):
Make sure decoded output from ``route monitor'' gets properly
flushed.
 1.38.4.4 05-Apr-2001  he Pull up revision 1.42 (requested by itojun):
Mark cloned routes with RTF_CLONED. Present it in ``netstat -r''
output by ``c''.
 1.38.4.3 05-Apr-2001  he Pull up revision 1.41 (requested by itojun):
Support RTF_BLACKHOLE routes.
 1.38.4.2 05-Apr-2001  he Pull up revision 1.40 (requested by itojun):
Remove use of uninitialized route (struct ortentry).
 1.38.4.1 17-Oct-2000  tv Pullup 1.39 [itojun]:
on "route monitor", print RTM_IFANNOUNCE, RTM_IFINFO (new #), and others.
 1.54.2.4 26-Jan-2003  jmc Pullup revisions 1.57-1.58 (requested by fredb in ticket #1080)
permit DNS names to address portion. they will be considered as
RTF_HOST if specified as destination (as there's no getnetbyname in
IPv6).
 1.54.2.3 21-Oct-2002  lukem Pull up revision 1.60 (requested by itojun in ticket #923):
Make prefixlen check to make sure its argument is present before deref
from openbsd
 1.54.2.2 06-Jun-2002  lukem Pull up revisions 1.56-1.57 (requested by itojun in ticket #185):
1.56:
more correct ion to RTF_HOST handling.
1.57:
if we're unsure about prefixlen, don't say "128".
 1.54.2.1 05-Jun-2002  lukem Pull up revision 1.55 (requested by itojun in ticket #160):
do not have -prefixlen 128 on RTF_HOST.
From: Dawid Szymanski <dawszy@arhea.net>
 1.106.16.2 24-Sep-2008  wrstuden Merge in changes between wrstuden-revivesa-base-2 and
wrstuden-revivesa-base-3.
 1.106.16.1 18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.106.12.2 17-Jan-2009  mjf Sync with HEAD.
 1.106.12.1 28-Sep-2008  mjf Sync with HEAD.
 1.118.6.1 11-May-2010  matt Fixup for u_quad_t change for route interface.
 1.127.2.1 08-Feb-2011  bouyer Sync with HEAD
 1.133.2.3 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.133.2.2 30-Oct-2012  yamt sync with head
 1.133.2.1 17-Apr-2012  yamt sync with head
 1.136.2.1 17-Oct-2012  riz Pull up following revision(s) (requested by uwe in ticket #592):
sbin/route/route.c: revision 1.139
Fix fallout from 1.129 that converted sou::so_foo from unions to
pointers but missed (char *)&soup->so_foo => (char *)soup->so_foo in
mask_addr(). It worked by luck - unless it didn't: due to pointer
numerology on amd64 route add -net ClassC without explicit /24 prefix
length specification would result into /16 destination instead of /24.
 1.138.2.3 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.138.2.2 23-Jun-2013  tls resync from head
 1.138.2.1 20-Nov-2012  tls Resync to 2012-11-19 00:00:00 UTC
 1.144.4.3 03-Jan-2018  snj Pull up following revision(s) (requested by uwe in ticket #1542):
sbin/route/route.c: revision 1.157
Fix typo in flag name. We should probably just use IFFBITS string
that <net/if.h> defines.
PR bin/52815
 1.144.4.2 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.144.4.1 29-Dec-2014  martin Pull up following revision(s) (requested by prlw1 in ticket #358):
sbin/route/route.c: revision 1.149
external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c: revision 1.7
external/bsd/ipf/dist/lib/printhost.c: revision 1.3
usr.sbin/lpr/common_source/common.c: revision 1.43
usr.sbin/lpr/common_source/Makefile: revision 1.12
external/bsd/ipf/dist/lib/printhostmask.c: revision 1.3
external/bsd/ipf/dist/lib/save_v1trap.c: revision 1.2
external/bsd/dhcpcd/dist/dhcpcd.c: revision 1.21
external/bsd/tcpdump/bin/Makefile: revision 1.12
external/bsd/ipf/dist/lib/save_v2trap.c: revision 1.2
external/bsd/ipf/dist/tools/lexer.c: revision 1.2
external/bsd/ppp/usr.sbin/pppd/sys-bsd.c: revision 1.3
external/bsd/ipf/dist/lib/printipfexpr.c: revision 1.2
MKINET6=no build fixes
http://mail-index.netbsd.org/tech-net/2014/12/13/msg004898.html
 1.154.4.1 21-Apr-2017  bouyer Sync with HEAD
 1.154.2.1 20-Mar-2017  pgoyette Sync with HEAD
 1.155.4.4 25-Aug-2018  martin Pull up following revision(s) (requested by roy in ticket #976):

sbin/route/route.c: revision 1.160

Resolve every route(4) message type before printing anything more about it
other than the type and length.

This solves the issue where RTM_ONEWADDR is received and it tries to
parse route information from it.
 1.155.4.3 09-Apr-2018  bouyer Pull up following revision(s) (requested by roy in ticket #724):
tests/net/icmp/t_ping.c: revision 1.19
sys/netinet6/raw_ip6.c: revision 1.166
sys/netinet6/ip6_input.c: revision 1.195
sys/net/raw_usrreq.c: revision 1.59
sys/sys/socketvar.h: revision 1.151
sys/kern/uipc_socket2.c: revision 1.128
tests/lib/libc/sys/t_recvmmsg.c: revision 1.2
lib/libc/sys/recv.2: revision 1.38
sys/net/rtsock.c: revision 1.239
sys/netinet/udp_usrreq.c: revision 1.246
sys/netinet6/icmp6.c: revision 1.224
tests/net/icmp/t_ping.c: revision 1.20
sys/netipsec/keysock.c: revision 1.63
sys/netinet/raw_ip.c: revision 1.172
sys/kern/uipc_socket.c: revision 1.260
tests/net/icmp/t_ping.c: revision 1.22
sys/kern/uipc_socket.c: revision 1.261
tests/net/icmp/t_ping.c: revision 1.23
sys/netinet/ip_mroute.c: revision 1.155
sbin/route/route.c: revision 1.159
sys/netinet6/ip6_mroute.c: revision 1.123
sys/netatalk/ddp_input.c: revision 1.31
sys/netcan/can.c: revision 1.3
sys/kern/uipc_usrreq.c: revision 1.184
sys/netinet6/udp6_usrreq.c: revision 1.138
tests/net/icmp/t_ping.c: revision 1.18
socket: report receive buffer overflows
Add soroverflow() which increments the overflow counter, sets so_error
to ENOBUFS and wakes the receive socket up.
Replace all code that manually increments this counter with soroverflow().
Add soroverflow() to raw_input().
This allows userland to detect route(4) overflows so it can re-sync
with the current state.
socket: clear error even when peeking
The error has already been reported and it's pointless requiring another
recv(2) call just to clear it.
socket: remove now incorrect comment that so_error is only udp
As it can be affected by route(4) sockets which are raw.
rtsock: log dropped messages that we cannot report to userland
Handle ENOBUFS when receiving messages.
Don't send messages if the receiver has died.
Sprinkle more soroverflow().
Handle ENOBUFS in recv
Handle ENOBUFS in sendto
Note value received. Harden another sendto for ENOBUFS.
Handle the routing socket overflowing gracefully.
Allow a valid sendto .... duh
Handle errors better.
Fix test for checking we sent all the data we asked to.
 1.155.4.2 21-Dec-2017  snj Pull up following revision(s) (requested by uwe in ticket #448):
sbin/route/route.c: revision 1.157
Fix typo in flag name. We should probably just use IFFBITS string
that <net/if.h> defines.
PR bin/52815
 1.155.4.1 07-Jul-2017  martin Pull up following revision(s) (requested by ozaki-r in ticket #107):
usr.sbin/arp/arp.c: revision 1.56
sys/net/rtsock.c: revision 1.218
sys/net/if_llatbl.c: revision 1.20
usr.sbin/arp/arp.c: revision 1.57
sys/net/rtsock.c: revision 1.219
sys/net/if_llatbl.c: revision 1.21
usr.sbin/arp/arp.c: revision 1.58
tests/net/net_common.sh: revision 1.19
sys/netinet6/nd6.h: revision 1.84
sys/netinet6/nd6.h: revision 1.85
tests/net/arp/t_arp.sh: revision 1.23
sys/netinet6/in6.c: revision 1.246
tests/net/arp/t_arp.sh: revision 1.24
sys/netinet6/in6.c: revision 1.247
tests/net/arp/t_arp.sh: revision 1.25
sys/netinet6/in6.c: revision 1.248
tests/net/arp/t_arp.sh: revision 1.26
usr.sbin/ndp/ndp.c: revision 1.49
tests/net/arp/t_arp.sh: revision 1.27
tests/net/ndp/t_ndp.sh: revision 1.20
tests/net/arp/t_arp.sh: revision 1.28
tests/net/ndp/t_ndp.sh: revision 1.21
tests/net/arp/t_arp.sh: revision 1.29
tests/net/ndp/t_ndp.sh: revision 1.22
tests/net/ndp/t_ndp.sh: revision 1.23
tests/net/route/t_flags6.sh: revision 1.13
tests/net/ndp/t_ndp.sh: revision 1.24
tests/net/route/t_flags6.sh: revision 1.14
tests/net/ndp/t_ndp.sh: revision 1.25
tests/net/route/t_flags6.sh: revision 1.15
tests/net/ndp/t_ndp.sh: revision 1.26
sbin/route/rtutil.c: revision 1.9
tests/net/ndp/t_ndp.sh: revision 1.27
tests/net/ndp/t_ndp.sh: revision 1.28
tests/net/net/t_ipv6address.sh: revision 1.14
tests/net/ndp/t_ra.sh: revision 1.28
tests/net/ndp/t_ndp.sh: revision 1.29
sys/net/route.h: revision 1.113
tests/net/ndp/t_ra.sh: revision 1.29
sys/net/rtsock.c: revision 1.220
sys/net/rtsock.c: revision 1.221
sys/net/rtsock.c: revision 1.222
sys/net/rtsock.c: revision 1.223
tests/net/route/t_route.sh: revision 1.13
sys/net/rtsock.c: revision 1.224
sys/net/route.c: revision 1.196
sys/net/if_llatbl.c: revision 1.19
sys/net/route.c: revision 1.197
sbin/route/route.c: revision 1.156
tests/net/route/t_flags.sh: revision 1.16
tests/net/route/t_flags.sh: revision 1.17
usr.sbin/ndp/ndp.c: revision 1.50
tests/net/route/t_flags.sh: revision 1.18
sys/netinet/in.c: revision 1.204
tests/net/route/t_flags.sh: revision 1.19
sys/netinet/in.c: revision 1.205
tests/net/arp/t_arp.sh: revision 1.30
tests/net/arp/t_arp.sh: revision 1.31
sys/net/if_llatbl.h: revision 1.11
tests/net/arp/t_arp.sh: revision 1.32
sys/net/if_llatbl.h: revision 1.12
tests/net/arp/t_arp.sh: revision 1.33
sys/netinet6/nd6.c: revision 1.233
sys/netinet6/nd6.c: revision 1.234
sys/netinet/if_arp.c: revision 1.251
sys/netinet6/nd6.c: revision 1.235
sys/netinet/if_arp.c: revision 1.252
sbin/route/route.8: revision 1.57
sys/net/rtsock.c: revision 1.214
sys/net/rtsock.c: revision 1.215
sys/net/rtsock.c: revision 1.216
sys/net/rtsock.c: revision 1.217
whitespace police
Simplify
We can assume that rt_ifp is always non-NULL.
Sending a routing message (RTM_ADD) on adding an llentry
A message used to be sent on adding a cloned route. Restore the
behavior for backward compatibility.
Requested by ryo@
Drop RTF_CONNECTED from a result of RTM_GET for ARP/NDP entries
ARP/NDP entries aren't connected routes.
Reported by ryo@
Support -c <count> option for route monitor
route command exits if it receives <count> routing messages where
<count> is a value specified by -c.
The option is useful to get only particular message(s) in a test script.
Test routing messages emitted on operations of ARP/NDP entries
Do netstat -a for an appropriate protocol
Add missing declarations for cleanup
Set net.inet.arp.keep only if it's required
Don't create a permanent L2 cache entry on adding an address to an interface
It was created to copy FreeBSD, however actually the cache isn't
necessary. Remove it to simplify the code and reduce the cost to
maintain it (e.g., keep a consistency with a corresponding local
route).
Fix typo
Fix in_lltable_match_prefix
The function has not been used but will be used soon.
Remove unused function (nd6_rem_ifa_lle)
Allow in6_lltable_free_entry to be called without holding the afdata lock of ifp as well as in_lltable_free_entry
This behavior is a bit odd and should be fixed in the future...
Purge ARP/NDP entries on an interface when the interface is down
Fix PR kern/51179
Purge all related L2 caches on removing a route
The change addresses situations similar to PR 51179.
Purge L2 caches on changing an interface of a route
The change addresses situations similar to PR 51179.
Test implicit removals of ARP/NDP entries
One test case reproudces PR 51179.
Fix build of kernels without both INET and INET6
Tweak lltable_sysctl_dumparp
- Rename lltable_sysctl_dumparp to lltable_sysctl_dump
because it's not only for ARP
- Enable it not only for INET but also for INET6
Fix usage of routing messages on arp -d and ndp -d
It didn't work as we expected; we should set RTA_GATEWAY not
RTA_IFP on RTM_GET to return an if_index and the kernel should
use it on RTM_DELETE.
Improve backward compatibility of (fake) routing messages on adding an ARP/NDP entry
A message originally included only DST and GATEWAY. Restore it.
Fix ifdef; care about a case w/ INET6 and w/o INET
Drop RTF_UP from a routing message of a deleted ARP/NDP entry
Check existence of ARP/NDP entries
Checking ARP/NDP entries is valid rather than checking routes.
Fix wrong comment
Drop RTF_LLINFO flag (now it's RTF_LLDATA) from local routes
They don't have llinfo anymore. And also the change fixes unexpected
behavior of ARP proxy.
Restore ARP/NDP entries to route show and netstat -r
Requested by dyoung@ some time ago
Enable to remove multiple ARP/NDP entries for one destination
The kernel can have multiple ARP/NDP entries which have an indentical
destination on different interfaces. This is normal and can be
reproduce easily by ping -I or ping6 -S. We should be able to remove
such entries.
arp -d <ip> and ndp -d <ip> are changed to fetch all ARP/NDP entries
and remove matched entries. So we can remove multiple entries
described above. This fetch all and selective removal behavior is
the same as arp <ip> and ndp <ip>; they also do fetch all entries
and show only matched entries.
Related to PR 51179
Check if ARP/NDP entries are purged when a related route is deleted
 1.158.2.2 06-Sep-2018  pgoyette Sync with HEAD

Resolve a couple of conflicts (result of the uimin/uimax changes)
 1.158.2.1 30-Mar-2018  pgoyette Resolve conflicts between branch and HEAD
 1.159.2.3 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.159.2.2 08-Apr-2020  martin Merge changes from current as of 20200406
 1.159.2.1 10-Jun-2019  christos Sync with HEAD
 1.160.2.4 24-Jan-2020  martin Pull up following revision(s) (requested by roy in ticket #646):

sbin/route/route.c: revision 1.164
sbin/route/route.c: revision 1.165

route: Decode the correct flags for interface address messages
route: address flags are more useful than interface flags for address msgs
 1.160.2.3 05-Sep-2019  martin Pull up following revision(s) (requested by roy in ticket #172):

sbin/route/route.c: revision 1.163

route(8): Show addres for RTM_LOSING
While here, add /* FALLTHROUGH */.
 1.160.2.2 01-Sep-2019  martin Pull up following revision(s) (requested by roy in ticket #150):

sbin/route/route.c: revision 1.162

route(8): show addrs for RTM_MISS
 1.160.2.1 26-Aug-2019  martin Pull up following revision(s) (requested by roy in ticket #108):

sbin/route/route.c: revision 1.161

route(8): print RTM_CHANGE messages
XXX Pullup -9
 1.3 03-Apr-2020  martin Make route and netstat share the same struct progops (and initialization
code)
 1.2 02-Apr-2020  christos Add a prog_setsockopt (thanks kre@)
 1.1 13-Dec-2010  pooka branches: 1.1.46;
Convert from RUMP_ACTION to RUMPPRG.
 1.1.46.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.4 31-Oct-2022  andvar fix various typos in comments and one output message.
 1.3 03-Apr-2020  martin Make route and netstat share the same struct progops (and initialization
code)
 1.2 02-Apr-2020  christos Add a prog_setsockopt (thanks kre@)
 1.1 13-Dec-2010  pooka branches: 1.1.46;
Convert from RUMP_ACTION to RUMPPRG.
 1.1.46.1 08-Apr-2020  martin Merge changes from current as of 20200406
 1.11 29-Aug-2020  christos Instead of defining RTF_LLINFO, use RTF_LLDATA
 1.10 13-Jul-2017  manu Fix route and netstat -r output when built with -DSMALL

A missing \n caused the routing table to be printed all in one line
if -DSMALL was used.
 1.9 28-Jun-2017  ozaki-r Restore ARP/NDP entries to route show and netstat -r

Requested by dyoung@ some time ago
 1.8 04-Apr-2016  ozaki-r branches: 1.8.8;
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.7 23-Jan-2016  christos no need for <sys/mbuf.h>
 1.6 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.5 26-Feb-2015  roy Teach route(8) about RTF_LOCAL.
 1.4 07-Jan-2015  christos branches: 1.4.2;
make netname4 match the netname6 signature avoiding a NULL pointer.
 1.3 12-Nov-2014  christos PR/47704: Takahiro HAYASHI: Add -L flag
 1.2 08-Nov-2014  christos give a little more space
 1.1 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.4.2.4 26-Jul-2017  snj Pull up following revision(s) (requested by manu in ticket #1454):
sbin/route/rtutil.c: revision 1.10
Fix route and netstat -r output when built with -DSMALL
A missing \n caused the routing table to be printed all in one line
if -DSMALL was used.
 1.4.2.3 08-Jan-2015  martin Pull up following revision(s) (requested by prlw1 in ticket #395):
sbin/route/rtutil.c: revision 1.4
sbin/route/rtutil.h: revision 1.3
usr.bin/netstat/if.c: revision 1.81
make netname4 match the netname6 signature avoiding a NULL pointer.
adjust to the netname4 prototype.
 1.4.2.2 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.4.2.1 07-Jan-2015  martin file rtutil.c was added on branch netbsd-7 on 2015-01-08 11:01:01 +0000
 1.8.8.2 25-Jul-2017  snj Pull up following revision(s) (requested by manu in ticket #131):
sbin/route/rtutil.c: revision 1.10
Fix route and netstat -r output when built with -DSMALL
A missing \n caused the routing table to be printed all in one line
if -DSMALL was used.
 1.8.8.1 07-Jul-2017  martin Pull up following revision(s) (requested by ozaki-r in ticket #107):
usr.sbin/arp/arp.c: revision 1.56
sys/net/rtsock.c: revision 1.218
sys/net/if_llatbl.c: revision 1.20
usr.sbin/arp/arp.c: revision 1.57
sys/net/rtsock.c: revision 1.219
sys/net/if_llatbl.c: revision 1.21
usr.sbin/arp/arp.c: revision 1.58
tests/net/net_common.sh: revision 1.19
sys/netinet6/nd6.h: revision 1.84
sys/netinet6/nd6.h: revision 1.85
tests/net/arp/t_arp.sh: revision 1.23
sys/netinet6/in6.c: revision 1.246
tests/net/arp/t_arp.sh: revision 1.24
sys/netinet6/in6.c: revision 1.247
tests/net/arp/t_arp.sh: revision 1.25
sys/netinet6/in6.c: revision 1.248
tests/net/arp/t_arp.sh: revision 1.26
usr.sbin/ndp/ndp.c: revision 1.49
tests/net/arp/t_arp.sh: revision 1.27
tests/net/ndp/t_ndp.sh: revision 1.20
tests/net/arp/t_arp.sh: revision 1.28
tests/net/ndp/t_ndp.sh: revision 1.21
tests/net/arp/t_arp.sh: revision 1.29
tests/net/ndp/t_ndp.sh: revision 1.22
tests/net/ndp/t_ndp.sh: revision 1.23
tests/net/route/t_flags6.sh: revision 1.13
tests/net/ndp/t_ndp.sh: revision 1.24
tests/net/route/t_flags6.sh: revision 1.14
tests/net/ndp/t_ndp.sh: revision 1.25
tests/net/route/t_flags6.sh: revision 1.15
tests/net/ndp/t_ndp.sh: revision 1.26
sbin/route/rtutil.c: revision 1.9
tests/net/ndp/t_ndp.sh: revision 1.27
tests/net/ndp/t_ndp.sh: revision 1.28
tests/net/net/t_ipv6address.sh: revision 1.14
tests/net/ndp/t_ra.sh: revision 1.28
tests/net/ndp/t_ndp.sh: revision 1.29
sys/net/route.h: revision 1.113
tests/net/ndp/t_ra.sh: revision 1.29
sys/net/rtsock.c: revision 1.220
sys/net/rtsock.c: revision 1.221
sys/net/rtsock.c: revision 1.222
sys/net/rtsock.c: revision 1.223
tests/net/route/t_route.sh: revision 1.13
sys/net/rtsock.c: revision 1.224
sys/net/route.c: revision 1.196
sys/net/if_llatbl.c: revision 1.19
sys/net/route.c: revision 1.197
sbin/route/route.c: revision 1.156
tests/net/route/t_flags.sh: revision 1.16
tests/net/route/t_flags.sh: revision 1.17
usr.sbin/ndp/ndp.c: revision 1.50
tests/net/route/t_flags.sh: revision 1.18
sys/netinet/in.c: revision 1.204
tests/net/route/t_flags.sh: revision 1.19
sys/netinet/in.c: revision 1.205
tests/net/arp/t_arp.sh: revision 1.30
tests/net/arp/t_arp.sh: revision 1.31
sys/net/if_llatbl.h: revision 1.11
tests/net/arp/t_arp.sh: revision 1.32
sys/net/if_llatbl.h: revision 1.12
tests/net/arp/t_arp.sh: revision 1.33
sys/netinet6/nd6.c: revision 1.233
sys/netinet6/nd6.c: revision 1.234
sys/netinet/if_arp.c: revision 1.251
sys/netinet6/nd6.c: revision 1.235
sys/netinet/if_arp.c: revision 1.252
sbin/route/route.8: revision 1.57
sys/net/rtsock.c: revision 1.214
sys/net/rtsock.c: revision 1.215
sys/net/rtsock.c: revision 1.216
sys/net/rtsock.c: revision 1.217
whitespace police
Simplify
We can assume that rt_ifp is always non-NULL.
Sending a routing message (RTM_ADD) on adding an llentry
A message used to be sent on adding a cloned route. Restore the
behavior for backward compatibility.
Requested by ryo@
Drop RTF_CONNECTED from a result of RTM_GET for ARP/NDP entries
ARP/NDP entries aren't connected routes.
Reported by ryo@
Support -c <count> option for route monitor
route command exits if it receives <count> routing messages where
<count> is a value specified by -c.
The option is useful to get only particular message(s) in a test script.
Test routing messages emitted on operations of ARP/NDP entries
Do netstat -a for an appropriate protocol
Add missing declarations for cleanup
Set net.inet.arp.keep only if it's required
Don't create a permanent L2 cache entry on adding an address to an interface
It was created to copy FreeBSD, however actually the cache isn't
necessary. Remove it to simplify the code and reduce the cost to
maintain it (e.g., keep a consistency with a corresponding local
route).
Fix typo
Fix in_lltable_match_prefix
The function has not been used but will be used soon.
Remove unused function (nd6_rem_ifa_lle)
Allow in6_lltable_free_entry to be called without holding the afdata lock of ifp as well as in_lltable_free_entry
This behavior is a bit odd and should be fixed in the future...
Purge ARP/NDP entries on an interface when the interface is down
Fix PR kern/51179
Purge all related L2 caches on removing a route
The change addresses situations similar to PR 51179.
Purge L2 caches on changing an interface of a route
The change addresses situations similar to PR 51179.
Test implicit removals of ARP/NDP entries
One test case reproudces PR 51179.
Fix build of kernels without both INET and INET6
Tweak lltable_sysctl_dumparp
- Rename lltable_sysctl_dumparp to lltable_sysctl_dump
because it's not only for ARP
- Enable it not only for INET but also for INET6
Fix usage of routing messages on arp -d and ndp -d
It didn't work as we expected; we should set RTA_GATEWAY not
RTA_IFP on RTM_GET to return an if_index and the kernel should
use it on RTM_DELETE.
Improve backward compatibility of (fake) routing messages on adding an ARP/NDP entry
A message originally included only DST and GATEWAY. Restore it.
Fix ifdef; care about a case w/ INET6 and w/o INET
Drop RTF_UP from a routing message of a deleted ARP/NDP entry
Check existence of ARP/NDP entries
Checking ARP/NDP entries is valid rather than checking routes.
Fix wrong comment
Drop RTF_LLINFO flag (now it's RTF_LLDATA) from local routes
They don't have llinfo anymore. And also the change fixes unexpected
behavior of ARP proxy.
Restore ARP/NDP entries to route show and netstat -r
Requested by dyoung@ some time ago
Enable to remove multiple ARP/NDP entries for one destination
The kernel can have multiple ARP/NDP entries which have an indentical
destination on different interfaces. This is normal and can be
reproduce easily by ping -I or ping6 -S. We should be able to remove
such entries.
arp -d <ip> and ndp -d <ip> are changed to fetch all ARP/NDP entries
and remove matched entries. So we can remove multiple entries
described above. This fetch all and selective removal behavior is
the same as arp <ip> and ndp <ip>; they also do fetch all entries
and show only matched entries.
Related to PR 51179
Check if ARP/NDP entries are purged when a related route is deleted
 1.4 30-Jun-2019  sevan Add rcsid
 1.3 07-Jan-2015  christos branches: 1.3.2; 1.3.18;
make netname4 match the netname6 signature avoiding a NULL pointer.
 1.2 12-Nov-2014  christos PR/47704: Takahiro HAYASHI: Add -L flag
 1.1 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.3.18.1 13-Apr-2020  martin Mostly merge changes from HEAD upto 20200411
 1.3.2.3 08-Jan-2015  martin Pull up following revision(s) (requested by prlw1 in ticket #395):
sbin/route/rtutil.c: revision 1.4
sbin/route/rtutil.h: revision 1.3
usr.bin/netstat/if.c: revision 1.81
make netname4 match the netname6 signature avoiding a NULL pointer.
adjust to the netname4 prototype.
 1.3.2.2 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.3.2.1 07-Jan-2015  martin file rtutil.h was added on branch netbsd-7 on 2015-01-08 11:01:01 +0000
 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