History log of /openbsd-current/usr.bin/netstat/show.c
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.60 09-Nov-2022 kn

ndp, route, netstat: adjust ipv6 address width

It has been annoying me for too long that fully specififed GUAs
(2001:0db8:3333:4444:5555:6666:7777:8888) mess up alignment.

systat(1)'s netstat is the only view that has a big enough limit and thus
never misaligns.

Unify ndp(8), route(8) and netstat(1) views to always align nicely.

Feedback OK claudio


Revision tags: OPENBSD_7_2_BASE
# 1.59 19-Jun-2022 claudio

There is no reason to print the RTF_DONE bit in the routing table output.
It is now set on all routes (and before it was never set).
OK tb@ anton@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.58 24-Jan-2021 florian

Add missing __KAME__ markers.
OK claudio


# 1.57 16-Jan-2021 claudio

Unle recover the scope_id from a possible embedded scope if the scope_id
is not initalized. Do not reset the scope_id if it was already set.
OK bluhm@ florian@


Revision tags: OPENBSD_6_8_BASE
# 1.56 15-Sep-2020 pamela

"Route show" and "netstat -r" provide formatting for routing tables with
sufficient space to display v4 addresses cleanly, but which truncate v6
addresses. The -n flag on each already provides additional column width
for IPv6 addresses. Make this formatting the default.

OK phessler kn


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.55 31-Aug-2018 yasuoka

Dont print "default" for "0.0.0.0" if it is a host route.
diff from asou at soum.co.jp

ok claudio kn


# 1.54 04-Jun-2018 kn

Zap unused sockaddr.

OK bluhm deraadt jca


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.53 21-Jan-2017 guenther

The POSIX APIs that that sockaddrs all ignore the s*_len field in the
incoming socket, so userspace doesn't need to set it unless it has its
own reasons for tracking the size along with the sockaddr.

ok phessler@ deraadt@ florian@


# 1.52 03-Sep-2016 phessler

Add userland parts for BFD. Can't work if you don't have it enabled in
the kernel.

OK claudio@, henning@


# 1.51 01-Sep-2016 bluhm

Display all route flags in "route get", "route show" and "netstat -r"
output. Sort them according to the RTF_... defines in route.h.
OK claudio@ mpi@


Revision tags: OPENBSD_6_0_BASE
# 1.50 13-Jul-2016 mpi

Introduce RTF_MULTICAST and flag corresponding IPv6 routes as such
instead of abusing RTF_CLONING.

Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@


Revision tags: OPENBSD_5_9_BASE
# 1.49 11-Sep-2015 mpi

Remove XRESOLVE support.

dlg@ is sad because we won't be able to implement arpd(8) the way
people intended it in the 80s.


Revision tags: OPENBSD_5_8_BASE
# 1.48 27-Apr-2015 benno

sync with rev 1.99 of sbin/route/show.c
requested by claudio@ and mpi@


Revision tags: OPENBSD_5_7_BASE
# 1.47 12-Feb-2015 claudio

Free the buffers used for the sysctl. OK sthen@


# 1.46 09-Feb-2015 claudio

Get rid of another KVM reader and convert the multicast output to use
the new sysctls. Looks good deraadt@


# 1.45 06-Feb-2015 reyk

Remove route/netstat -f encap in favor of ipsecctl -s flow.

OK deraadt@


# 1.44 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.43 23-Oct-2014 schwarze

Remove networks(5) support.
In particular, do not call getnetbyaddr(3), use gethostbyaddr(3) only.
Do not call setnetent(3) and the dummy sethostent(3).
OK henning@; and deraadt@ agrees with the general direction.


Revision tags: OPENBSD_5_6_BASE
# 1.42 08-May-2014 mpi

Introduce two new route flags: RTF_LOCAL and RTF_BROADCAST.

Nothing use them for the moment, but here is the plan:

Since a route lookup is always necessary to output a packet it makes
sense to store all the information regarding how the packet should be
sent in the routing entry. This will save us some expensive lookups
on address lists.

But once we have all the information about our addresses in the routing
table, we can even use it in the input path with the hope that the number
of lookups in the forwarding case can be reduce to one.

ok henning@, chris@


# 1.41 17-Apr-2014 claudio

Sync show.c with the route version. Make the two files more similar but
still not identical. OK sthen@ mpi@ jca@


Revision tags: OPENBSD_5_5_BASE
# 1.40 21-Nov-2013 mikeb

split kernel parts of the if.h into a separate header file if_var.h
which allows us to modify ifnet structure in a relatively safe way;
discussed with deraadt, ok mpi


# 1.39 13-Nov-2013 deraadt

handle lack of proto


Revision tags: OPENBSD_5_4_BASE
# 1.38 20-Mar-2013 deraadt

As non-root, whenever netstat is about to print out a kernel pointer...
print 0x0 instead. Hides a lot stuff people don't need to see.


Revision tags: OPENBSD_5_3_BASE
# 1.37 16-Jan-2013 deraadt

sys/mbuf.h not needed


Revision tags: OPENBSD_5_2_BASE
# 1.36 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.35 01-Nov-2011 mikeb

Do some cleanup and improve the manpage. From Andreas Bartelt; ok henning, jmc


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.34 11-Oct-2010 claudio

Do similar changes to netstat as done to route(8). Try to show the
most expected rtable when doing a netstat -rn.
OK henning@


Revision tags: OPENBSD_4_8_BASE
# 1.33 30-Jul-2010 bluhm

Do not print "Label" caption for "netstat -rvA".
ok markus@


# 1.32 29-Jul-2010 bluhm

Print a column with the routing label if "netstat -vr" or "route
-v show" are called with the -v switch.
ok markus@


# 1.31 19-May-2010 chl

remove unused variables

ok claudio@ michele@


# 1.30 23-Mar-2010 claudio

Sync with show.c of route(8). OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.29 14-Jan-2010 claudio

Similar fix for default route printing as done in netstat. Make sure mask
is 0 when sa_len is 0.


# 1.28 11-Jan-2010 dlg

"default" routes need a mask of 0 too.

from and ok claudio@


# 1.27 07-Aug-2009 martynas

if buffers overlap; result will be undefined. ok claudio@, michele@


# 1.26 05-Aug-2009 deraadt

missing break


Revision tags: OPENBSD_4_6_BASE
# 1.25 27-Jun-2009 michele

Mark MPLS routes with T (tagged) in route output.

suggested by dlg@, ok claudio@, laurent@, blambert@


# 1.24 31-May-2009 claudio

There is no need to mask priority with RTP_MASK because it is already done
by the kernel.


# 1.23 23-May-2009 chris

typo


# 1.22 23-May-2009 chris

missed rtm_hdrlen conversion in two places

ok claudio@


# 1.21 28-Apr-2009 michele

Sync with kernel changes.
Add support to route(8) for a new dummy operation to allow packets coming in
with a particular label to leave the MPLS cloud and join ipv4/ipv6 stack.

ok claudio@ laurent@


Revision tags: OPENBSD_4_5_BASE
# 1.20 06-Feb-2009 chl

remove unused variables.

ok henning@ michele@


# 1.19 03-Feb-2009 michele

Reflect MPLS kernel changes. Operations are stored now in rt_mpls field.

ok claudio@ laurent@


# 1.18 26-Jan-2009 claudio

Again use P to mark multipath routes in route output. OK henning@


# 1.17 08-Jan-2009 michele

Reflect MPLS kernel changes.

ok claudio@


# 1.16 15-Dec-2008 michele

Unbreak netstat, reflecting kernel changes.
Now it shows MPLS informations correctly.

OK claudio@


# 1.15 15-Dec-2008 deraadt

work around tree breakage by mpls people


# 1.14 15-Sep-2008 claudio

Similar to route(8) change mask rtm->rtm_priority with RTP_MASK to show
correct values. OK henning@


Revision tags: OPENBSD_4_4_BASE
# 1.13 08-May-2008 claudio

Sync netstat show.c with route show.c to gain mpls support and to show the
routing priority. hai norby@


Revision tags: OPENBSD_4_3_BASE
# 1.12 14-Dec-2007 deraadt

remove 21 nlist variables, and instead use sysctl to query the kernel
turn on INET6 the default (remove the #ifdef's)
ok claudio reyk


# 1.11 05-Sep-2007 claudio

Correct the format strings after the recent rt_metrics changes.
rmx_pksent is not u_int64_t all others are just u_int.


Revision tags: OPENBSD_4_2_BASE
# 1.10 25-Jul-2007 claudio

Make it possible to show alternate routing tables in netstat. This mostly
comes from route(8) which already had the -T option. OK henning@


# 1.9 24-Jul-2007 claudio

Bring back a few things from route/show.c which I like better.


# 1.8 21-Jul-2007 claudio

Similar to sbin/route/show.c:
Check the rtm_version before trying to print an entry. If the rtmsg has a
different version skip it and don't try to print it. Solves a SIGSEGV I have
triggered with one of my scarier diffs. OK henning@


# 1.7 19-Jun-2007 ray

Remove unused variable.


# 1.6 04-Jun-2007 henning

remove IPX support, agreed by many


# 1.5 23-Mar-2007 pyr

Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.4 29-Dec-2006 claudio

Netstat has the same issue problem as route when printing a default inet6
route. Need to typecast the sizeof() to int so that the compare works.
Having a negativ lim is OK. Reported by Bj�rn Ketelaars. OK deraadt@


# 1.3 17-Nov-2006 itojun

change semantics of ff01::/16 to interface local multicast
(to sync up with more recent IPv6 spec)

ok from: deraadt mcbride


Revision tags: OPENBSD_4_0_BASE
# 1.2 30-May-2006 todd

this fixes a crash observed by Naddy on amd64, and permits the src/dst ip's to
be visible .. when IPv6 sa flows are present
ok claudio@


# 1.1 27-May-2006 claudio

Moving netstat from kvm snooping to retrieving the routing tables via
sysctl. Most code is stolen from route -- which was stolen from netstat.
kvm snooping code is still in and useable. Put it in deraadt@ henning@


# 1.59 19-Jun-2022 claudio

There is no reason to print the RTF_DONE bit in the routing table output.
It is now set on all routes (and before it was never set).
OK tb@ anton@


Revision tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE OPENBSD_7_1_BASE
# 1.58 24-Jan-2021 florian

Add missing __KAME__ markers.
OK claudio


# 1.57 16-Jan-2021 claudio

Unle recover the scope_id from a possible embedded scope if the scope_id
is not initalized. Do not reset the scope_id if it was already set.
OK bluhm@ florian@


Revision tags: OPENBSD_6_8_BASE
# 1.56 15-Sep-2020 pamela

"Route show" and "netstat -r" provide formatting for routing tables with
sufficient space to display v4 addresses cleanly, but which truncate v6
addresses. The -n flag on each already provides additional column width
for IPv6 addresses. Make this formatting the default.

OK phessler kn


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.55 31-Aug-2018 yasuoka

Dont print "default" for "0.0.0.0" if it is a host route.
diff from asou at soum.co.jp

ok claudio kn


# 1.54 04-Jun-2018 kn

Zap unused sockaddr.

OK bluhm deraadt jca


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.53 21-Jan-2017 guenther

The POSIX APIs that that sockaddrs all ignore the s*_len field in the
incoming socket, so userspace doesn't need to set it unless it has its
own reasons for tracking the size along with the sockaddr.

ok phessler@ deraadt@ florian@


# 1.52 03-Sep-2016 phessler

Add userland parts for BFD. Can't work if you don't have it enabled in
the kernel.

OK claudio@, henning@


# 1.51 01-Sep-2016 bluhm

Display all route flags in "route get", "route show" and "netstat -r"
output. Sort them according to the RTF_... defines in route.h.
OK claudio@ mpi@


Revision tags: OPENBSD_6_0_BASE
# 1.50 13-Jul-2016 mpi

Introduce RTF_MULTICAST and flag corresponding IPv6 routes as such
instead of abusing RTF_CLONING.

Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@


Revision tags: OPENBSD_5_9_BASE
# 1.49 11-Sep-2015 mpi

Remove XRESOLVE support.

dlg@ is sad because we won't be able to implement arpd(8) the way
people intended it in the 80s.


Revision tags: OPENBSD_5_8_BASE
# 1.48 27-Apr-2015 benno

sync with rev 1.99 of sbin/route/show.c
requested by claudio@ and mpi@


Revision tags: OPENBSD_5_7_BASE
# 1.47 12-Feb-2015 claudio

Free the buffers used for the sysctl. OK sthen@


# 1.46 09-Feb-2015 claudio

Get rid of another KVM reader and convert the multicast output to use
the new sysctls. Looks good deraadt@


# 1.45 06-Feb-2015 reyk

Remove route/netstat -f encap in favor of ipsecctl -s flow.

OK deraadt@


# 1.44 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.43 23-Oct-2014 schwarze

Remove networks(5) support.
In particular, do not call getnetbyaddr(3), use gethostbyaddr(3) only.
Do not call setnetent(3) and the dummy sethostent(3).
OK henning@; and deraadt@ agrees with the general direction.


Revision tags: OPENBSD_5_6_BASE
# 1.42 08-May-2014 mpi

Introduce two new route flags: RTF_LOCAL and RTF_BROADCAST.

Nothing use them for the moment, but here is the plan:

Since a route lookup is always necessary to output a packet it makes
sense to store all the information regarding how the packet should be
sent in the routing entry. This will save us some expensive lookups
on address lists.

But once we have all the information about our addresses in the routing
table, we can even use it in the input path with the hope that the number
of lookups in the forwarding case can be reduce to one.

ok henning@, chris@


# 1.41 17-Apr-2014 claudio

Sync show.c with the route version. Make the two files more similar but
still not identical. OK sthen@ mpi@ jca@


Revision tags: OPENBSD_5_5_BASE
# 1.40 21-Nov-2013 mikeb

split kernel parts of the if.h into a separate header file if_var.h
which allows us to modify ifnet structure in a relatively safe way;
discussed with deraadt, ok mpi


# 1.39 13-Nov-2013 deraadt

handle lack of proto


Revision tags: OPENBSD_5_4_BASE
# 1.38 20-Mar-2013 deraadt

As non-root, whenever netstat is about to print out a kernel pointer...
print 0x0 instead. Hides a lot stuff people don't need to see.


Revision tags: OPENBSD_5_3_BASE
# 1.37 16-Jan-2013 deraadt

sys/mbuf.h not needed


Revision tags: OPENBSD_5_2_BASE
# 1.36 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.35 01-Nov-2011 mikeb

Do some cleanup and improve the manpage. From Andreas Bartelt; ok henning, jmc


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.34 11-Oct-2010 claudio

Do similar changes to netstat as done to route(8). Try to show the
most expected rtable when doing a netstat -rn.
OK henning@


Revision tags: OPENBSD_4_8_BASE
# 1.33 30-Jul-2010 bluhm

Do not print "Label" caption for "netstat -rvA".
ok markus@


# 1.32 29-Jul-2010 bluhm

Print a column with the routing label if "netstat -vr" or "route
-v show" are called with the -v switch.
ok markus@


# 1.31 19-May-2010 chl

remove unused variables

ok claudio@ michele@


# 1.30 23-Mar-2010 claudio

Sync with show.c of route(8). OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.29 14-Jan-2010 claudio

Similar fix for default route printing as done in netstat. Make sure mask
is 0 when sa_len is 0.


# 1.28 11-Jan-2010 dlg

"default" routes need a mask of 0 too.

from and ok claudio@


# 1.27 07-Aug-2009 martynas

if buffers overlap; result will be undefined. ok claudio@, michele@


# 1.26 05-Aug-2009 deraadt

missing break


Revision tags: OPENBSD_4_6_BASE
# 1.25 27-Jun-2009 michele

Mark MPLS routes with T (tagged) in route output.

suggested by dlg@, ok claudio@, laurent@, blambert@


# 1.24 31-May-2009 claudio

There is no need to mask priority with RTP_MASK because it is already done
by the kernel.


# 1.23 23-May-2009 chris

typo


# 1.22 23-May-2009 chris

missed rtm_hdrlen conversion in two places

ok claudio@


# 1.21 28-Apr-2009 michele

Sync with kernel changes.
Add support to route(8) for a new dummy operation to allow packets coming in
with a particular label to leave the MPLS cloud and join ipv4/ipv6 stack.

ok claudio@ laurent@


Revision tags: OPENBSD_4_5_BASE
# 1.20 06-Feb-2009 chl

remove unused variables.

ok henning@ michele@


# 1.19 03-Feb-2009 michele

Reflect MPLS kernel changes. Operations are stored now in rt_mpls field.

ok claudio@ laurent@


# 1.18 26-Jan-2009 claudio

Again use P to mark multipath routes in route output. OK henning@


# 1.17 08-Jan-2009 michele

Reflect MPLS kernel changes.

ok claudio@


# 1.16 15-Dec-2008 michele

Unbreak netstat, reflecting kernel changes.
Now it shows MPLS informations correctly.

OK claudio@


# 1.15 15-Dec-2008 deraadt

work around tree breakage by mpls people


# 1.14 15-Sep-2008 claudio

Similar to route(8) change mask rtm->rtm_priority with RTP_MASK to show
correct values. OK henning@


Revision tags: OPENBSD_4_4_BASE
# 1.13 08-May-2008 claudio

Sync netstat show.c with route show.c to gain mpls support and to show the
routing priority. hai norby@


Revision tags: OPENBSD_4_3_BASE
# 1.12 14-Dec-2007 deraadt

remove 21 nlist variables, and instead use sysctl to query the kernel
turn on INET6 the default (remove the #ifdef's)
ok claudio reyk


# 1.11 05-Sep-2007 claudio

Correct the format strings after the recent rt_metrics changes.
rmx_pksent is not u_int64_t all others are just u_int.


Revision tags: OPENBSD_4_2_BASE
# 1.10 25-Jul-2007 claudio

Make it possible to show alternate routing tables in netstat. This mostly
comes from route(8) which already had the -T option. OK henning@


# 1.9 24-Jul-2007 claudio

Bring back a few things from route/show.c which I like better.


# 1.8 21-Jul-2007 claudio

Similar to sbin/route/show.c:
Check the rtm_version before trying to print an entry. If the rtmsg has a
different version skip it and don't try to print it. Solves a SIGSEGV I have
triggered with one of my scarier diffs. OK henning@


# 1.7 19-Jun-2007 ray

Remove unused variable.


# 1.6 04-Jun-2007 henning

remove IPX support, agreed by many


# 1.5 23-Mar-2007 pyr

Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.4 29-Dec-2006 claudio

Netstat has the same issue problem as route when printing a default inet6
route. Need to typecast the sizeof() to int so that the compare works.
Having a negativ lim is OK. Reported by Bj�rn Ketelaars. OK deraadt@


# 1.3 17-Nov-2006 itojun

change semantics of ff01::/16 to interface local multicast
(to sync up with more recent IPv6 spec)

ok from: deraadt mcbride


Revision tags: OPENBSD_4_0_BASE
# 1.2 30-May-2006 todd

this fixes a crash observed by Naddy on amd64, and permits the src/dst ip's to
be visible .. when IPv6 sa flows are present
ok claudio@


# 1.1 27-May-2006 claudio

Moving netstat from kvm snooping to retrieving the routing tables via
sysctl. Most code is stolen from route -- which was stolen from netstat.
kvm snooping code is still in and useable. Put it in deraadt@ henning@


# 1.58 24-Jan-2021 florian

Add missing __KAME__ markers.
OK claudio


# 1.57 16-Jan-2021 claudio

Unle recover the scope_id from a possible embedded scope if the scope_id
is not initalized. Do not reset the scope_id if it was already set.
OK bluhm@ florian@


Revision tags: OPENBSD_6_8_BASE
# 1.56 15-Sep-2020 pamela

"Route show" and "netstat -r" provide formatting for routing tables with
sufficient space to display v4 addresses cleanly, but which truncate v6
addresses. The -n flag on each already provides additional column width
for IPv6 addresses. Make this formatting the default.

OK phessler kn


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.55 31-Aug-2018 yasuoka

Dont print "default" for "0.0.0.0" if it is a host route.
diff from asou at soum.co.jp

ok claudio kn


# 1.54 04-Jun-2018 kn

Zap unused sockaddr.

OK bluhm deraadt jca


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.53 21-Jan-2017 guenther

The POSIX APIs that that sockaddrs all ignore the s*_len field in the
incoming socket, so userspace doesn't need to set it unless it has its
own reasons for tracking the size along with the sockaddr.

ok phessler@ deraadt@ florian@


# 1.52 03-Sep-2016 phessler

Add userland parts for BFD. Can't work if you don't have it enabled in
the kernel.

OK claudio@, henning@


# 1.51 01-Sep-2016 bluhm

Display all route flags in "route get", "route show" and "netstat -r"
output. Sort them according to the RTF_... defines in route.h.
OK claudio@ mpi@


Revision tags: OPENBSD_6_0_BASE
# 1.50 13-Jul-2016 mpi

Introduce RTF_MULTICAST and flag corresponding IPv6 routes as such
instead of abusing RTF_CLONING.

Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@


Revision tags: OPENBSD_5_9_BASE
# 1.49 11-Sep-2015 mpi

Remove XRESOLVE support.

dlg@ is sad because we won't be able to implement arpd(8) the way
people intended it in the 80s.


Revision tags: OPENBSD_5_8_BASE
# 1.48 27-Apr-2015 benno

sync with rev 1.99 of sbin/route/show.c
requested by claudio@ and mpi@


Revision tags: OPENBSD_5_7_BASE
# 1.47 12-Feb-2015 claudio

Free the buffers used for the sysctl. OK sthen@


# 1.46 09-Feb-2015 claudio

Get rid of another KVM reader and convert the multicast output to use
the new sysctls. Looks good deraadt@


# 1.45 06-Feb-2015 reyk

Remove route/netstat -f encap in favor of ipsecctl -s flow.

OK deraadt@


# 1.44 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.43 23-Oct-2014 schwarze

Remove networks(5) support.
In particular, do not call getnetbyaddr(3), use gethostbyaddr(3) only.
Do not call setnetent(3) and the dummy sethostent(3).
OK henning@; and deraadt@ agrees with the general direction.


Revision tags: OPENBSD_5_6_BASE
# 1.42 08-May-2014 mpi

Introduce two new route flags: RTF_LOCAL and RTF_BROADCAST.

Nothing use them for the moment, but here is the plan:

Since a route lookup is always necessary to output a packet it makes
sense to store all the information regarding how the packet should be
sent in the routing entry. This will save us some expensive lookups
on address lists.

But once we have all the information about our addresses in the routing
table, we can even use it in the input path with the hope that the number
of lookups in the forwarding case can be reduce to one.

ok henning@, chris@


# 1.41 17-Apr-2014 claudio

Sync show.c with the route version. Make the two files more similar but
still not identical. OK sthen@ mpi@ jca@


Revision tags: OPENBSD_5_5_BASE
# 1.40 21-Nov-2013 mikeb

split kernel parts of the if.h into a separate header file if_var.h
which allows us to modify ifnet structure in a relatively safe way;
discussed with deraadt, ok mpi


# 1.39 13-Nov-2013 deraadt

handle lack of proto


Revision tags: OPENBSD_5_4_BASE
# 1.38 20-Mar-2013 deraadt

As non-root, whenever netstat is about to print out a kernel pointer...
print 0x0 instead. Hides a lot stuff people don't need to see.


Revision tags: OPENBSD_5_3_BASE
# 1.37 16-Jan-2013 deraadt

sys/mbuf.h not needed


Revision tags: OPENBSD_5_2_BASE
# 1.36 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.35 01-Nov-2011 mikeb

Do some cleanup and improve the manpage. From Andreas Bartelt; ok henning, jmc


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.34 11-Oct-2010 claudio

Do similar changes to netstat as done to route(8). Try to show the
most expected rtable when doing a netstat -rn.
OK henning@


Revision tags: OPENBSD_4_8_BASE
# 1.33 30-Jul-2010 bluhm

Do not print "Label" caption for "netstat -rvA".
ok markus@


# 1.32 29-Jul-2010 bluhm

Print a column with the routing label if "netstat -vr" or "route
-v show" are called with the -v switch.
ok markus@


# 1.31 19-May-2010 chl

remove unused variables

ok claudio@ michele@


# 1.30 23-Mar-2010 claudio

Sync with show.c of route(8). OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.29 14-Jan-2010 claudio

Similar fix for default route printing as done in netstat. Make sure mask
is 0 when sa_len is 0.


# 1.28 11-Jan-2010 dlg

"default" routes need a mask of 0 too.

from and ok claudio@


# 1.27 07-Aug-2009 martynas

if buffers overlap; result will be undefined. ok claudio@, michele@


# 1.26 05-Aug-2009 deraadt

missing break


Revision tags: OPENBSD_4_6_BASE
# 1.25 27-Jun-2009 michele

Mark MPLS routes with T (tagged) in route output.

suggested by dlg@, ok claudio@, laurent@, blambert@


# 1.24 31-May-2009 claudio

There is no need to mask priority with RTP_MASK because it is already done
by the kernel.


# 1.23 23-May-2009 chris

typo


# 1.22 23-May-2009 chris

missed rtm_hdrlen conversion in two places

ok claudio@


# 1.21 28-Apr-2009 michele

Sync with kernel changes.
Add support to route(8) for a new dummy operation to allow packets coming in
with a particular label to leave the MPLS cloud and join ipv4/ipv6 stack.

ok claudio@ laurent@


Revision tags: OPENBSD_4_5_BASE
# 1.20 06-Feb-2009 chl

remove unused variables.

ok henning@ michele@


# 1.19 03-Feb-2009 michele

Reflect MPLS kernel changes. Operations are stored now in rt_mpls field.

ok claudio@ laurent@


# 1.18 26-Jan-2009 claudio

Again use P to mark multipath routes in route output. OK henning@


# 1.17 08-Jan-2009 michele

Reflect MPLS kernel changes.

ok claudio@


# 1.16 15-Dec-2008 michele

Unbreak netstat, reflecting kernel changes.
Now it shows MPLS informations correctly.

OK claudio@


# 1.15 15-Dec-2008 deraadt

work around tree breakage by mpls people


# 1.14 15-Sep-2008 claudio

Similar to route(8) change mask rtm->rtm_priority with RTP_MASK to show
correct values. OK henning@


Revision tags: OPENBSD_4_4_BASE
# 1.13 08-May-2008 claudio

Sync netstat show.c with route show.c to gain mpls support and to show the
routing priority. hai norby@


Revision tags: OPENBSD_4_3_BASE
# 1.12 14-Dec-2007 deraadt

remove 21 nlist variables, and instead use sysctl to query the kernel
turn on INET6 the default (remove the #ifdef's)
ok claudio reyk


# 1.11 05-Sep-2007 claudio

Correct the format strings after the recent rt_metrics changes.
rmx_pksent is not u_int64_t all others are just u_int.


Revision tags: OPENBSD_4_2_BASE
# 1.10 25-Jul-2007 claudio

Make it possible to show alternate routing tables in netstat. This mostly
comes from route(8) which already had the -T option. OK henning@


# 1.9 24-Jul-2007 claudio

Bring back a few things from route/show.c which I like better.


# 1.8 21-Jul-2007 claudio

Similar to sbin/route/show.c:
Check the rtm_version before trying to print an entry. If the rtmsg has a
different version skip it and don't try to print it. Solves a SIGSEGV I have
triggered with one of my scarier diffs. OK henning@


# 1.7 19-Jun-2007 ray

Remove unused variable.


# 1.6 04-Jun-2007 henning

remove IPX support, agreed by many


# 1.5 23-Mar-2007 pyr

Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.4 29-Dec-2006 claudio

Netstat has the same issue problem as route when printing a default inet6
route. Need to typecast the sizeof() to int so that the compare works.
Having a negativ lim is OK. Reported by Bj�rn Ketelaars. OK deraadt@


# 1.3 17-Nov-2006 itojun

change semantics of ff01::/16 to interface local multicast
(to sync up with more recent IPv6 spec)

ok from: deraadt mcbride


Revision tags: OPENBSD_4_0_BASE
# 1.2 30-May-2006 todd

this fixes a crash observed by Naddy on amd64, and permits the src/dst ip's to
be visible .. when IPv6 sa flows are present
ok claudio@


# 1.1 27-May-2006 claudio

Moving netstat from kvm snooping to retrieving the routing tables via
sysctl. Most code is stolen from route -- which was stolen from netstat.
kvm snooping code is still in and useable. Put it in deraadt@ henning@


# 1.57 16-Jan-2021 claudio

Unle recover the scope_id from a possible embedded scope if the scope_id
is not initalized. Do not reset the scope_id if it was already set.
OK bluhm@ florian@


Revision tags: OPENBSD_6_8_BASE
# 1.56 15-Sep-2020 pamela

"Route show" and "netstat -r" provide formatting for routing tables with
sufficient space to display v4 addresses cleanly, but which truncate v6
addresses. The -n flag on each already provides additional column width
for IPv6 addresses. Make this formatting the default.

OK phessler kn


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.55 31-Aug-2018 yasuoka

Dont print "default" for "0.0.0.0" if it is a host route.
diff from asou at soum.co.jp

ok claudio kn


# 1.54 04-Jun-2018 kn

Zap unused sockaddr.

OK bluhm deraadt jca


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.53 21-Jan-2017 guenther

The POSIX APIs that that sockaddrs all ignore the s*_len field in the
incoming socket, so userspace doesn't need to set it unless it has its
own reasons for tracking the size along with the sockaddr.

ok phessler@ deraadt@ florian@


# 1.52 03-Sep-2016 phessler

Add userland parts for BFD. Can't work if you don't have it enabled in
the kernel.

OK claudio@, henning@


# 1.51 01-Sep-2016 bluhm

Display all route flags in "route get", "route show" and "netstat -r"
output. Sort them according to the RTF_... defines in route.h.
OK claudio@ mpi@


Revision tags: OPENBSD_6_0_BASE
# 1.50 13-Jul-2016 mpi

Introduce RTF_MULTICAST and flag corresponding IPv6 routes as such
instead of abusing RTF_CLONING.

Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@


Revision tags: OPENBSD_5_9_BASE
# 1.49 11-Sep-2015 mpi

Remove XRESOLVE support.

dlg@ is sad because we won't be able to implement arpd(8) the way
people intended it in the 80s.


Revision tags: OPENBSD_5_8_BASE
# 1.48 27-Apr-2015 benno

sync with rev 1.99 of sbin/route/show.c
requested by claudio@ and mpi@


Revision tags: OPENBSD_5_7_BASE
# 1.47 12-Feb-2015 claudio

Free the buffers used for the sysctl. OK sthen@


# 1.46 09-Feb-2015 claudio

Get rid of another KVM reader and convert the multicast output to use
the new sysctls. Looks good deraadt@


# 1.45 06-Feb-2015 reyk

Remove route/netstat -f encap in favor of ipsecctl -s flow.

OK deraadt@


# 1.44 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.43 23-Oct-2014 schwarze

Remove networks(5) support.
In particular, do not call getnetbyaddr(3), use gethostbyaddr(3) only.
Do not call setnetent(3) and the dummy sethostent(3).
OK henning@; and deraadt@ agrees with the general direction.


Revision tags: OPENBSD_5_6_BASE
# 1.42 08-May-2014 mpi

Introduce two new route flags: RTF_LOCAL and RTF_BROADCAST.

Nothing use them for the moment, but here is the plan:

Since a route lookup is always necessary to output a packet it makes
sense to store all the information regarding how the packet should be
sent in the routing entry. This will save us some expensive lookups
on address lists.

But once we have all the information about our addresses in the routing
table, we can even use it in the input path with the hope that the number
of lookups in the forwarding case can be reduce to one.

ok henning@, chris@


# 1.41 17-Apr-2014 claudio

Sync show.c with the route version. Make the two files more similar but
still not identical. OK sthen@ mpi@ jca@


Revision tags: OPENBSD_5_5_BASE
# 1.40 21-Nov-2013 mikeb

split kernel parts of the if.h into a separate header file if_var.h
which allows us to modify ifnet structure in a relatively safe way;
discussed with deraadt, ok mpi


# 1.39 13-Nov-2013 deraadt

handle lack of proto


Revision tags: OPENBSD_5_4_BASE
# 1.38 20-Mar-2013 deraadt

As non-root, whenever netstat is about to print out a kernel pointer...
print 0x0 instead. Hides a lot stuff people don't need to see.


Revision tags: OPENBSD_5_3_BASE
# 1.37 16-Jan-2013 deraadt

sys/mbuf.h not needed


Revision tags: OPENBSD_5_2_BASE
# 1.36 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.35 01-Nov-2011 mikeb

Do some cleanup and improve the manpage. From Andreas Bartelt; ok henning, jmc


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.34 11-Oct-2010 claudio

Do similar changes to netstat as done to route(8). Try to show the
most expected rtable when doing a netstat -rn.
OK henning@


Revision tags: OPENBSD_4_8_BASE
# 1.33 30-Jul-2010 bluhm

Do not print "Label" caption for "netstat -rvA".
ok markus@


# 1.32 29-Jul-2010 bluhm

Print a column with the routing label if "netstat -vr" or "route
-v show" are called with the -v switch.
ok markus@


# 1.31 19-May-2010 chl

remove unused variables

ok claudio@ michele@


# 1.30 23-Mar-2010 claudio

Sync with show.c of route(8). OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.29 14-Jan-2010 claudio

Similar fix for default route printing as done in netstat. Make sure mask
is 0 when sa_len is 0.


# 1.28 11-Jan-2010 dlg

"default" routes need a mask of 0 too.

from and ok claudio@


# 1.27 07-Aug-2009 martynas

if buffers overlap; result will be undefined. ok claudio@, michele@


# 1.26 05-Aug-2009 deraadt

missing break


Revision tags: OPENBSD_4_6_BASE
# 1.25 27-Jun-2009 michele

Mark MPLS routes with T (tagged) in route output.

suggested by dlg@, ok claudio@, laurent@, blambert@


# 1.24 31-May-2009 claudio

There is no need to mask priority with RTP_MASK because it is already done
by the kernel.


# 1.23 23-May-2009 chris

typo


# 1.22 23-May-2009 chris

missed rtm_hdrlen conversion in two places

ok claudio@


# 1.21 28-Apr-2009 michele

Sync with kernel changes.
Add support to route(8) for a new dummy operation to allow packets coming in
with a particular label to leave the MPLS cloud and join ipv4/ipv6 stack.

ok claudio@ laurent@


Revision tags: OPENBSD_4_5_BASE
# 1.20 06-Feb-2009 chl

remove unused variables.

ok henning@ michele@


# 1.19 03-Feb-2009 michele

Reflect MPLS kernel changes. Operations are stored now in rt_mpls field.

ok claudio@ laurent@


# 1.18 26-Jan-2009 claudio

Again use P to mark multipath routes in route output. OK henning@


# 1.17 08-Jan-2009 michele

Reflect MPLS kernel changes.

ok claudio@


# 1.16 15-Dec-2008 michele

Unbreak netstat, reflecting kernel changes.
Now it shows MPLS informations correctly.

OK claudio@


# 1.15 15-Dec-2008 deraadt

work around tree breakage by mpls people


# 1.14 15-Sep-2008 claudio

Similar to route(8) change mask rtm->rtm_priority with RTP_MASK to show
correct values. OK henning@


Revision tags: OPENBSD_4_4_BASE
# 1.13 08-May-2008 claudio

Sync netstat show.c with route show.c to gain mpls support and to show the
routing priority. hai norby@


Revision tags: OPENBSD_4_3_BASE
# 1.12 14-Dec-2007 deraadt

remove 21 nlist variables, and instead use sysctl to query the kernel
turn on INET6 the default (remove the #ifdef's)
ok claudio reyk


# 1.11 05-Sep-2007 claudio

Correct the format strings after the recent rt_metrics changes.
rmx_pksent is not u_int64_t all others are just u_int.


Revision tags: OPENBSD_4_2_BASE
# 1.10 25-Jul-2007 claudio

Make it possible to show alternate routing tables in netstat. This mostly
comes from route(8) which already had the -T option. OK henning@


# 1.9 24-Jul-2007 claudio

Bring back a few things from route/show.c which I like better.


# 1.8 21-Jul-2007 claudio

Similar to sbin/route/show.c:
Check the rtm_version before trying to print an entry. If the rtmsg has a
different version skip it and don't try to print it. Solves a SIGSEGV I have
triggered with one of my scarier diffs. OK henning@


# 1.7 19-Jun-2007 ray

Remove unused variable.


# 1.6 04-Jun-2007 henning

remove IPX support, agreed by many


# 1.5 23-Mar-2007 pyr

Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.4 29-Dec-2006 claudio

Netstat has the same issue problem as route when printing a default inet6
route. Need to typecast the sizeof() to int so that the compare works.
Having a negativ lim is OK. Reported by Bj�rn Ketelaars. OK deraadt@


# 1.3 17-Nov-2006 itojun

change semantics of ff01::/16 to interface local multicast
(to sync up with more recent IPv6 spec)

ok from: deraadt mcbride


Revision tags: OPENBSD_4_0_BASE
# 1.2 30-May-2006 todd

this fixes a crash observed by Naddy on amd64, and permits the src/dst ip's to
be visible .. when IPv6 sa flows are present
ok claudio@


# 1.1 27-May-2006 claudio

Moving netstat from kvm snooping to retrieving the routing tables via
sysctl. Most code is stolen from route -- which was stolen from netstat.
kvm snooping code is still in and useable. Put it in deraadt@ henning@


# 1.56 15-Sep-2020 pamela

"Route show" and "netstat -r" provide formatting for routing tables with
sufficient space to display v4 addresses cleanly, but which truncate v6
addresses. The -n flag on each already provides additional column width
for IPv6 addresses. Make this formatting the default.

OK phessler kn


Revision tags: OPENBSD_6_4_BASE OPENBSD_6_5_BASE OPENBSD_6_6_BASE OPENBSD_6_7_BASE
# 1.55 31-Aug-2018 yasuoka

Dont print "default" for "0.0.0.0" if it is a host route.
diff from asou at soum.co.jp

ok claudio kn


# 1.54 04-Jun-2018 kn

Zap unused sockaddr.

OK bluhm deraadt jca


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.53 21-Jan-2017 guenther

The POSIX APIs that that sockaddrs all ignore the s*_len field in the
incoming socket, so userspace doesn't need to set it unless it has its
own reasons for tracking the size along with the sockaddr.

ok phessler@ deraadt@ florian@


# 1.52 03-Sep-2016 phessler

Add userland parts for BFD. Can't work if you don't have it enabled in
the kernel.

OK claudio@, henning@


# 1.51 01-Sep-2016 bluhm

Display all route flags in "route get", "route show" and "netstat -r"
output. Sort them according to the RTF_... defines in route.h.
OK claudio@ mpi@


Revision tags: OPENBSD_6_0_BASE
# 1.50 13-Jul-2016 mpi

Introduce RTF_MULTICAST and flag corresponding IPv6 routes as such
instead of abusing RTF_CLONING.

Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@


Revision tags: OPENBSD_5_9_BASE
# 1.49 11-Sep-2015 mpi

Remove XRESOLVE support.

dlg@ is sad because we won't be able to implement arpd(8) the way
people intended it in the 80s.


Revision tags: OPENBSD_5_8_BASE
# 1.48 27-Apr-2015 benno

sync with rev 1.99 of sbin/route/show.c
requested by claudio@ and mpi@


Revision tags: OPENBSD_5_7_BASE
# 1.47 12-Feb-2015 claudio

Free the buffers used for the sysctl. OK sthen@


# 1.46 09-Feb-2015 claudio

Get rid of another KVM reader and convert the multicast output to use
the new sysctls. Looks good deraadt@


# 1.45 06-Feb-2015 reyk

Remove route/netstat -f encap in favor of ipsecctl -s flow.

OK deraadt@


# 1.44 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.43 23-Oct-2014 schwarze

Remove networks(5) support.
In particular, do not call getnetbyaddr(3), use gethostbyaddr(3) only.
Do not call setnetent(3) and the dummy sethostent(3).
OK henning@; and deraadt@ agrees with the general direction.


Revision tags: OPENBSD_5_6_BASE
# 1.42 08-May-2014 mpi

Introduce two new route flags: RTF_LOCAL and RTF_BROADCAST.

Nothing use them for the moment, but here is the plan:

Since a route lookup is always necessary to output a packet it makes
sense to store all the information regarding how the packet should be
sent in the routing entry. This will save us some expensive lookups
on address lists.

But once we have all the information about our addresses in the routing
table, we can even use it in the input path with the hope that the number
of lookups in the forwarding case can be reduce to one.

ok henning@, chris@


# 1.41 17-Apr-2014 claudio

Sync show.c with the route version. Make the two files more similar but
still not identical. OK sthen@ mpi@ jca@


Revision tags: OPENBSD_5_5_BASE
# 1.40 21-Nov-2013 mikeb

split kernel parts of the if.h into a separate header file if_var.h
which allows us to modify ifnet structure in a relatively safe way;
discussed with deraadt, ok mpi


# 1.39 13-Nov-2013 deraadt

handle lack of proto


Revision tags: OPENBSD_5_4_BASE
# 1.38 20-Mar-2013 deraadt

As non-root, whenever netstat is about to print out a kernel pointer...
print 0x0 instead. Hides a lot stuff people don't need to see.


Revision tags: OPENBSD_5_3_BASE
# 1.37 16-Jan-2013 deraadt

sys/mbuf.h not needed


Revision tags: OPENBSD_5_2_BASE
# 1.36 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.35 01-Nov-2011 mikeb

Do some cleanup and improve the manpage. From Andreas Bartelt; ok henning, jmc


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.34 11-Oct-2010 claudio

Do similar changes to netstat as done to route(8). Try to show the
most expected rtable when doing a netstat -rn.
OK henning@


Revision tags: OPENBSD_4_8_BASE
# 1.33 30-Jul-2010 bluhm

Do not print "Label" caption for "netstat -rvA".
ok markus@


# 1.32 29-Jul-2010 bluhm

Print a column with the routing label if "netstat -vr" or "route
-v show" are called with the -v switch.
ok markus@


# 1.31 19-May-2010 chl

remove unused variables

ok claudio@ michele@


# 1.30 23-Mar-2010 claudio

Sync with show.c of route(8). OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.29 14-Jan-2010 claudio

Similar fix for default route printing as done in netstat. Make sure mask
is 0 when sa_len is 0.


# 1.28 11-Jan-2010 dlg

"default" routes need a mask of 0 too.

from and ok claudio@


# 1.27 07-Aug-2009 martynas

if buffers overlap; result will be undefined. ok claudio@, michele@


# 1.26 05-Aug-2009 deraadt

missing break


Revision tags: OPENBSD_4_6_BASE
# 1.25 27-Jun-2009 michele

Mark MPLS routes with T (tagged) in route output.

suggested by dlg@, ok claudio@, laurent@, blambert@


# 1.24 31-May-2009 claudio

There is no need to mask priority with RTP_MASK because it is already done
by the kernel.


# 1.23 23-May-2009 chris

typo


# 1.22 23-May-2009 chris

missed rtm_hdrlen conversion in two places

ok claudio@


# 1.21 28-Apr-2009 michele

Sync with kernel changes.
Add support to route(8) for a new dummy operation to allow packets coming in
with a particular label to leave the MPLS cloud and join ipv4/ipv6 stack.

ok claudio@ laurent@


Revision tags: OPENBSD_4_5_BASE
# 1.20 06-Feb-2009 chl

remove unused variables.

ok henning@ michele@


# 1.19 03-Feb-2009 michele

Reflect MPLS kernel changes. Operations are stored now in rt_mpls field.

ok claudio@ laurent@


# 1.18 26-Jan-2009 claudio

Again use P to mark multipath routes in route output. OK henning@


# 1.17 08-Jan-2009 michele

Reflect MPLS kernel changes.

ok claudio@


# 1.16 15-Dec-2008 michele

Unbreak netstat, reflecting kernel changes.
Now it shows MPLS informations correctly.

OK claudio@


# 1.15 15-Dec-2008 deraadt

work around tree breakage by mpls people


# 1.14 15-Sep-2008 claudio

Similar to route(8) change mask rtm->rtm_priority with RTP_MASK to show
correct values. OK henning@


Revision tags: OPENBSD_4_4_BASE
# 1.13 08-May-2008 claudio

Sync netstat show.c with route show.c to gain mpls support and to show the
routing priority. hai norby@


Revision tags: OPENBSD_4_3_BASE
# 1.12 14-Dec-2007 deraadt

remove 21 nlist variables, and instead use sysctl to query the kernel
turn on INET6 the default (remove the #ifdef's)
ok claudio reyk


# 1.11 05-Sep-2007 claudio

Correct the format strings after the recent rt_metrics changes.
rmx_pksent is not u_int64_t all others are just u_int.


Revision tags: OPENBSD_4_2_BASE
# 1.10 25-Jul-2007 claudio

Make it possible to show alternate routing tables in netstat. This mostly
comes from route(8) which already had the -T option. OK henning@


# 1.9 24-Jul-2007 claudio

Bring back a few things from route/show.c which I like better.


# 1.8 21-Jul-2007 claudio

Similar to sbin/route/show.c:
Check the rtm_version before trying to print an entry. If the rtmsg has a
different version skip it and don't try to print it. Solves a SIGSEGV I have
triggered with one of my scarier diffs. OK henning@


# 1.7 19-Jun-2007 ray

Remove unused variable.


# 1.6 04-Jun-2007 henning

remove IPX support, agreed by many


# 1.5 23-Mar-2007 pyr

Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.4 29-Dec-2006 claudio

Netstat has the same issue problem as route when printing a default inet6
route. Need to typecast the sizeof() to int so that the compare works.
Having a negativ lim is OK. Reported by Bj�rn Ketelaars. OK deraadt@


# 1.3 17-Nov-2006 itojun

change semantics of ff01::/16 to interface local multicast
(to sync up with more recent IPv6 spec)

ok from: deraadt mcbride


Revision tags: OPENBSD_4_0_BASE
# 1.2 30-May-2006 todd

this fixes a crash observed by Naddy on amd64, and permits the src/dst ip's to
be visible .. when IPv6 sa flows are present
ok claudio@


# 1.1 27-May-2006 claudio

Moving netstat from kvm snooping to retrieving the routing tables via
sysctl. Most code is stolen from route -- which was stolen from netstat.
kvm snooping code is still in and useable. Put it in deraadt@ henning@


# 1.55 31-Aug-2018 yasuoka

Dont print "default" for "0.0.0.0" if it is a host route.
diff from asou at soum.co.jp

ok claudio kn


# 1.54 04-Jun-2018 kn

Zap unused sockaddr.

OK bluhm deraadt jca


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.53 21-Jan-2017 guenther

The POSIX APIs that that sockaddrs all ignore the s*_len field in the
incoming socket, so userspace doesn't need to set it unless it has its
own reasons for tracking the size along with the sockaddr.

ok phessler@ deraadt@ florian@


# 1.52 03-Sep-2016 phessler

Add userland parts for BFD. Can't work if you don't have it enabled in
the kernel.

OK claudio@, henning@


# 1.51 01-Sep-2016 bluhm

Display all route flags in "route get", "route show" and "netstat -r"
output. Sort them according to the RTF_... defines in route.h.
OK claudio@ mpi@


Revision tags: OPENBSD_6_0_BASE
# 1.50 13-Jul-2016 mpi

Introduce RTF_MULTICAST and flag corresponding IPv6 routes as such
instead of abusing RTF_CLONING.

Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@


Revision tags: OPENBSD_5_9_BASE
# 1.49 11-Sep-2015 mpi

Remove XRESOLVE support.

dlg@ is sad because we won't be able to implement arpd(8) the way
people intended it in the 80s.


Revision tags: OPENBSD_5_8_BASE
# 1.48 27-Apr-2015 benno

sync with rev 1.99 of sbin/route/show.c
requested by claudio@ and mpi@


Revision tags: OPENBSD_5_7_BASE
# 1.47 12-Feb-2015 claudio

Free the buffers used for the sysctl. OK sthen@


# 1.46 09-Feb-2015 claudio

Get rid of another KVM reader and convert the multicast output to use
the new sysctls. Looks good deraadt@


# 1.45 06-Feb-2015 reyk

Remove route/netstat -f encap in favor of ipsecctl -s flow.

OK deraadt@


# 1.44 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.43 23-Oct-2014 schwarze

Remove networks(5) support.
In particular, do not call getnetbyaddr(3), use gethostbyaddr(3) only.
Do not call setnetent(3) and the dummy sethostent(3).
OK henning@; and deraadt@ agrees with the general direction.


Revision tags: OPENBSD_5_6_BASE
# 1.42 08-May-2014 mpi

Introduce two new route flags: RTF_LOCAL and RTF_BROADCAST.

Nothing use them for the moment, but here is the plan:

Since a route lookup is always necessary to output a packet it makes
sense to store all the information regarding how the packet should be
sent in the routing entry. This will save us some expensive lookups
on address lists.

But once we have all the information about our addresses in the routing
table, we can even use it in the input path with the hope that the number
of lookups in the forwarding case can be reduce to one.

ok henning@, chris@


# 1.41 17-Apr-2014 claudio

Sync show.c with the route version. Make the two files more similar but
still not identical. OK sthen@ mpi@ jca@


Revision tags: OPENBSD_5_5_BASE
# 1.40 21-Nov-2013 mikeb

split kernel parts of the if.h into a separate header file if_var.h
which allows us to modify ifnet structure in a relatively safe way;
discussed with deraadt, ok mpi


# 1.39 13-Nov-2013 deraadt

handle lack of proto


Revision tags: OPENBSD_5_4_BASE
# 1.38 20-Mar-2013 deraadt

As non-root, whenever netstat is about to print out a kernel pointer...
print 0x0 instead. Hides a lot stuff people don't need to see.


Revision tags: OPENBSD_5_3_BASE
# 1.37 16-Jan-2013 deraadt

sys/mbuf.h not needed


Revision tags: OPENBSD_5_2_BASE
# 1.36 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.35 01-Nov-2011 mikeb

Do some cleanup and improve the manpage. From Andreas Bartelt; ok henning, jmc


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.34 11-Oct-2010 claudio

Do similar changes to netstat as done to route(8). Try to show the
most expected rtable when doing a netstat -rn.
OK henning@


Revision tags: OPENBSD_4_8_BASE
# 1.33 30-Jul-2010 bluhm

Do not print "Label" caption for "netstat -rvA".
ok markus@


# 1.32 29-Jul-2010 bluhm

Print a column with the routing label if "netstat -vr" or "route
-v show" are called with the -v switch.
ok markus@


# 1.31 19-May-2010 chl

remove unused variables

ok claudio@ michele@


# 1.30 23-Mar-2010 claudio

Sync with show.c of route(8). OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.29 14-Jan-2010 claudio

Similar fix for default route printing as done in netstat. Make sure mask
is 0 when sa_len is 0.


# 1.28 11-Jan-2010 dlg

"default" routes need a mask of 0 too.

from and ok claudio@


# 1.27 07-Aug-2009 martynas

if buffers overlap; result will be undefined. ok claudio@, michele@


# 1.26 05-Aug-2009 deraadt

missing break


Revision tags: OPENBSD_4_6_BASE
# 1.25 27-Jun-2009 michele

Mark MPLS routes with T (tagged) in route output.

suggested by dlg@, ok claudio@, laurent@, blambert@


# 1.24 31-May-2009 claudio

There is no need to mask priority with RTP_MASK because it is already done
by the kernel.


# 1.23 23-May-2009 chris

typo


# 1.22 23-May-2009 chris

missed rtm_hdrlen conversion in two places

ok claudio@


# 1.21 28-Apr-2009 michele

Sync with kernel changes.
Add support to route(8) for a new dummy operation to allow packets coming in
with a particular label to leave the MPLS cloud and join ipv4/ipv6 stack.

ok claudio@ laurent@


Revision tags: OPENBSD_4_5_BASE
# 1.20 06-Feb-2009 chl

remove unused variables.

ok henning@ michele@


# 1.19 03-Feb-2009 michele

Reflect MPLS kernel changes. Operations are stored now in rt_mpls field.

ok claudio@ laurent@


# 1.18 26-Jan-2009 claudio

Again use P to mark multipath routes in route output. OK henning@


# 1.17 08-Jan-2009 michele

Reflect MPLS kernel changes.

ok claudio@


# 1.16 15-Dec-2008 michele

Unbreak netstat, reflecting kernel changes.
Now it shows MPLS informations correctly.

OK claudio@


# 1.15 15-Dec-2008 deraadt

work around tree breakage by mpls people


# 1.14 15-Sep-2008 claudio

Similar to route(8) change mask rtm->rtm_priority with RTP_MASK to show
correct values. OK henning@


Revision tags: OPENBSD_4_4_BASE
# 1.13 08-May-2008 claudio

Sync netstat show.c with route show.c to gain mpls support and to show the
routing priority. hai norby@


Revision tags: OPENBSD_4_3_BASE
# 1.12 14-Dec-2007 deraadt

remove 21 nlist variables, and instead use sysctl to query the kernel
turn on INET6 the default (remove the #ifdef's)
ok claudio reyk


# 1.11 05-Sep-2007 claudio

Correct the format strings after the recent rt_metrics changes.
rmx_pksent is not u_int64_t all others are just u_int.


Revision tags: OPENBSD_4_2_BASE
# 1.10 25-Jul-2007 claudio

Make it possible to show alternate routing tables in netstat. This mostly
comes from route(8) which already had the -T option. OK henning@


# 1.9 24-Jul-2007 claudio

Bring back a few things from route/show.c which I like better.


# 1.8 21-Jul-2007 claudio

Similar to sbin/route/show.c:
Check the rtm_version before trying to print an entry. If the rtmsg has a
different version skip it and don't try to print it. Solves a SIGSEGV I have
triggered with one of my scarier diffs. OK henning@


# 1.7 19-Jun-2007 ray

Remove unused variable.


# 1.6 04-Jun-2007 henning

remove IPX support, agreed by many


# 1.5 23-Mar-2007 pyr

Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.4 29-Dec-2006 claudio

Netstat has the same issue problem as route when printing a default inet6
route. Need to typecast the sizeof() to int so that the compare works.
Having a negativ lim is OK. Reported by Bj�rn Ketelaars. OK deraadt@


# 1.3 17-Nov-2006 itojun

change semantics of ff01::/16 to interface local multicast
(to sync up with more recent IPv6 spec)

ok from: deraadt mcbride


Revision tags: OPENBSD_4_0_BASE
# 1.2 30-May-2006 todd

this fixes a crash observed by Naddy on amd64, and permits the src/dst ip's to
be visible .. when IPv6 sa flows are present
ok claudio@


# 1.1 27-May-2006 claudio

Moving netstat from kvm snooping to retrieving the routing tables via
sysctl. Most code is stolen from route -- which was stolen from netstat.
kvm snooping code is still in and useable. Put it in deraadt@ henning@


# 1.54 04-Jun-2018 kn

Zap unused sockaddr.

OK bluhm deraadt jca


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE
# 1.53 21-Jan-2017 guenther

The POSIX APIs that that sockaddrs all ignore the s*_len field in the
incoming socket, so userspace doesn't need to set it unless it has its
own reasons for tracking the size along with the sockaddr.

ok phessler@ deraadt@ florian@


# 1.52 03-Sep-2016 phessler

Add userland parts for BFD. Can't work if you don't have it enabled in
the kernel.

OK claudio@, henning@


# 1.51 01-Sep-2016 bluhm

Display all route flags in "route get", "route show" and "netstat -r"
output. Sort them according to the RTF_... defines in route.h.
OK claudio@ mpi@


Revision tags: OPENBSD_6_0_BASE
# 1.50 13-Jul-2016 mpi

Introduce RTF_MULTICAST and flag corresponding IPv6 routes as such
instead of abusing RTF_CLONING.

Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@


Revision tags: OPENBSD_5_9_BASE
# 1.49 11-Sep-2015 mpi

Remove XRESOLVE support.

dlg@ is sad because we won't be able to implement arpd(8) the way
people intended it in the 80s.


Revision tags: OPENBSD_5_8_BASE
# 1.48 27-Apr-2015 benno

sync with rev 1.99 of sbin/route/show.c
requested by claudio@ and mpi@


Revision tags: OPENBSD_5_7_BASE
# 1.47 12-Feb-2015 claudio

Free the buffers used for the sysctl. OK sthen@


# 1.46 09-Feb-2015 claudio

Get rid of another KVM reader and convert the multicast output to use
the new sysctls. Looks good deraadt@


# 1.45 06-Feb-2015 reyk

Remove route/netstat -f encap in favor of ipsecctl -s flow.

OK deraadt@


# 1.44 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.43 23-Oct-2014 schwarze

Remove networks(5) support.
In particular, do not call getnetbyaddr(3), use gethostbyaddr(3) only.
Do not call setnetent(3) and the dummy sethostent(3).
OK henning@; and deraadt@ agrees with the general direction.


Revision tags: OPENBSD_5_6_BASE
# 1.42 08-May-2014 mpi

Introduce two new route flags: RTF_LOCAL and RTF_BROADCAST.

Nothing use them for the moment, but here is the plan:

Since a route lookup is always necessary to output a packet it makes
sense to store all the information regarding how the packet should be
sent in the routing entry. This will save us some expensive lookups
on address lists.

But once we have all the information about our addresses in the routing
table, we can even use it in the input path with the hope that the number
of lookups in the forwarding case can be reduce to one.

ok henning@, chris@


# 1.41 17-Apr-2014 claudio

Sync show.c with the route version. Make the two files more similar but
still not identical. OK sthen@ mpi@ jca@


Revision tags: OPENBSD_5_5_BASE
# 1.40 21-Nov-2013 mikeb

split kernel parts of the if.h into a separate header file if_var.h
which allows us to modify ifnet structure in a relatively safe way;
discussed with deraadt, ok mpi


# 1.39 13-Nov-2013 deraadt

handle lack of proto


Revision tags: OPENBSD_5_4_BASE
# 1.38 20-Mar-2013 deraadt

As non-root, whenever netstat is about to print out a kernel pointer...
print 0x0 instead. Hides a lot stuff people don't need to see.


Revision tags: OPENBSD_5_3_BASE
# 1.37 16-Jan-2013 deraadt

sys/mbuf.h not needed


Revision tags: OPENBSD_5_2_BASE
# 1.36 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.35 01-Nov-2011 mikeb

Do some cleanup and improve the manpage. From Andreas Bartelt; ok henning, jmc


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.34 11-Oct-2010 claudio

Do similar changes to netstat as done to route(8). Try to show the
most expected rtable when doing a netstat -rn.
OK henning@


Revision tags: OPENBSD_4_8_BASE
# 1.33 30-Jul-2010 bluhm

Do not print "Label" caption for "netstat -rvA".
ok markus@


# 1.32 29-Jul-2010 bluhm

Print a column with the routing label if "netstat -vr" or "route
-v show" are called with the -v switch.
ok markus@


# 1.31 19-May-2010 chl

remove unused variables

ok claudio@ michele@


# 1.30 23-Mar-2010 claudio

Sync with show.c of route(8). OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.29 14-Jan-2010 claudio

Similar fix for default route printing as done in netstat. Make sure mask
is 0 when sa_len is 0.


# 1.28 11-Jan-2010 dlg

"default" routes need a mask of 0 too.

from and ok claudio@


# 1.27 07-Aug-2009 martynas

if buffers overlap; result will be undefined. ok claudio@, michele@


# 1.26 05-Aug-2009 deraadt

missing break


Revision tags: OPENBSD_4_6_BASE
# 1.25 27-Jun-2009 michele

Mark MPLS routes with T (tagged) in route output.

suggested by dlg@, ok claudio@, laurent@, blambert@


# 1.24 31-May-2009 claudio

There is no need to mask priority with RTP_MASK because it is already done
by the kernel.


# 1.23 23-May-2009 chris

typo


# 1.22 23-May-2009 chris

missed rtm_hdrlen conversion in two places

ok claudio@


# 1.21 28-Apr-2009 michele

Sync with kernel changes.
Add support to route(8) for a new dummy operation to allow packets coming in
with a particular label to leave the MPLS cloud and join ipv4/ipv6 stack.

ok claudio@ laurent@


Revision tags: OPENBSD_4_5_BASE
# 1.20 06-Feb-2009 chl

remove unused variables.

ok henning@ michele@


# 1.19 03-Feb-2009 michele

Reflect MPLS kernel changes. Operations are stored now in rt_mpls field.

ok claudio@ laurent@


# 1.18 26-Jan-2009 claudio

Again use P to mark multipath routes in route output. OK henning@


# 1.17 08-Jan-2009 michele

Reflect MPLS kernel changes.

ok claudio@


# 1.16 15-Dec-2008 michele

Unbreak netstat, reflecting kernel changes.
Now it shows MPLS informations correctly.

OK claudio@


# 1.15 15-Dec-2008 deraadt

work around tree breakage by mpls people


# 1.14 15-Sep-2008 claudio

Similar to route(8) change mask rtm->rtm_priority with RTP_MASK to show
correct values. OK henning@


Revision tags: OPENBSD_4_4_BASE
# 1.13 08-May-2008 claudio

Sync netstat show.c with route show.c to gain mpls support and to show the
routing priority. hai norby@


Revision tags: OPENBSD_4_3_BASE
# 1.12 14-Dec-2007 deraadt

remove 21 nlist variables, and instead use sysctl to query the kernel
turn on INET6 the default (remove the #ifdef's)
ok claudio reyk


# 1.11 05-Sep-2007 claudio

Correct the format strings after the recent rt_metrics changes.
rmx_pksent is not u_int64_t all others are just u_int.


Revision tags: OPENBSD_4_2_BASE
# 1.10 25-Jul-2007 claudio

Make it possible to show alternate routing tables in netstat. This mostly
comes from route(8) which already had the -T option. OK henning@


# 1.9 24-Jul-2007 claudio

Bring back a few things from route/show.c which I like better.


# 1.8 21-Jul-2007 claudio

Similar to sbin/route/show.c:
Check the rtm_version before trying to print an entry. If the rtmsg has a
different version skip it and don't try to print it. Solves a SIGSEGV I have
triggered with one of my scarier diffs. OK henning@


# 1.7 19-Jun-2007 ray

Remove unused variable.


# 1.6 04-Jun-2007 henning

remove IPX support, agreed by many


# 1.5 23-Mar-2007 pyr

Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.4 29-Dec-2006 claudio

Netstat has the same issue problem as route when printing a default inet6
route. Need to typecast the sizeof() to int so that the compare works.
Having a negativ lim is OK. Reported by Bj�rn Ketelaars. OK deraadt@


# 1.3 17-Nov-2006 itojun

change semantics of ff01::/16 to interface local multicast
(to sync up with more recent IPv6 spec)

ok from: deraadt mcbride


Revision tags: OPENBSD_4_0_BASE
# 1.2 30-May-2006 todd

this fixes a crash observed by Naddy on amd64, and permits the src/dst ip's to
be visible .. when IPv6 sa flows are present
ok claudio@


# 1.1 27-May-2006 claudio

Moving netstat from kvm snooping to retrieving the routing tables via
sysctl. Most code is stolen from route -- which was stolen from netstat.
kvm snooping code is still in and useable. Put it in deraadt@ henning@


Revision tags: OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.53 21-Jan-2017 guenther

The POSIX APIs that that sockaddrs all ignore the s*_len field in the
incoming socket, so userspace doesn't need to set it unless it has its
own reasons for tracking the size along with the sockaddr.

ok phessler@ deraadt@ florian@


# 1.52 03-Sep-2016 phessler

Add userland parts for BFD. Can't work if you don't have it enabled in
the kernel.

OK claudio@, henning@


# 1.51 01-Sep-2016 bluhm

Display all route flags in "route get", "route show" and "netstat -r"
output. Sort them according to the RTF_... defines in route.h.
OK claudio@ mpi@


Revision tags: OPENBSD_6_0_BASE
# 1.50 13-Jul-2016 mpi

Introduce RTF_MULTICAST and flag corresponding IPv6 routes as such
instead of abusing RTF_CLONING.

Fix a leak reporeted by Aaron Riekenberg on misc@, ok sthen@


Revision tags: OPENBSD_5_9_BASE
# 1.49 11-Sep-2015 mpi

Remove XRESOLVE support.

dlg@ is sad because we won't be able to implement arpd(8) the way
people intended it in the 80s.


Revision tags: OPENBSD_5_8_BASE
# 1.48 27-Apr-2015 benno

sync with rev 1.99 of sbin/route/show.c
requested by claudio@ and mpi@


Revision tags: OPENBSD_5_7_BASE
# 1.47 12-Feb-2015 claudio

Free the buffers used for the sysctl. OK sthen@


# 1.46 09-Feb-2015 claudio

Get rid of another KVM reader and convert the multicast output to use
the new sysctls. Looks good deraadt@


# 1.45 06-Feb-2015 reyk

Remove route/netstat -f encap in favor of ipsecctl -s flow.

OK deraadt@


# 1.44 16-Jan-2015 deraadt

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible. Annotate <sys/param.h> lines with their current reasons. Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc. Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution. These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)


# 1.43 23-Oct-2014 schwarze

Remove networks(5) support.
In particular, do not call getnetbyaddr(3), use gethostbyaddr(3) only.
Do not call setnetent(3) and the dummy sethostent(3).
OK henning@; and deraadt@ agrees with the general direction.


Revision tags: OPENBSD_5_6_BASE
# 1.42 08-May-2014 mpi

Introduce two new route flags: RTF_LOCAL and RTF_BROADCAST.

Nothing use them for the moment, but here is the plan:

Since a route lookup is always necessary to output a packet it makes
sense to store all the information regarding how the packet should be
sent in the routing entry. This will save us some expensive lookups
on address lists.

But once we have all the information about our addresses in the routing
table, we can even use it in the input path with the hope that the number
of lookups in the forwarding case can be reduce to one.

ok henning@, chris@


# 1.41 17-Apr-2014 claudio

Sync show.c with the route version. Make the two files more similar but
still not identical. OK sthen@ mpi@ jca@


Revision tags: OPENBSD_5_5_BASE
# 1.40 21-Nov-2013 mikeb

split kernel parts of the if.h into a separate header file if_var.h
which allows us to modify ifnet structure in a relatively safe way;
discussed with deraadt, ok mpi


# 1.39 13-Nov-2013 deraadt

handle lack of proto


Revision tags: OPENBSD_5_4_BASE
# 1.38 20-Mar-2013 deraadt

As non-root, whenever netstat is about to print out a kernel pointer...
print 0x0 instead. Hides a lot stuff people don't need to see.


Revision tags: OPENBSD_5_3_BASE
# 1.37 16-Jan-2013 deraadt

sys/mbuf.h not needed


Revision tags: OPENBSD_5_2_BASE
# 1.36 17-Mar-2012 dlg

remove IP_JUMBO, SO_JUMBO, and RTF_JUMBO.

no objection from mcbride@ krw@ markus@ deraadt@


Revision tags: OPENBSD_5_1_BASE
# 1.35 01-Nov-2011 mikeb

Do some cleanup and improve the manpage. From Andreas Bartelt; ok henning, jmc


Revision tags: OPENBSD_4_9_BASE OPENBSD_5_0_BASE
# 1.34 11-Oct-2010 claudio

Do similar changes to netstat as done to route(8). Try to show the
most expected rtable when doing a netstat -rn.
OK henning@


Revision tags: OPENBSD_4_8_BASE
# 1.33 30-Jul-2010 bluhm

Do not print "Label" caption for "netstat -rvA".
ok markus@


# 1.32 29-Jul-2010 bluhm

Print a column with the routing label if "netstat -vr" or "route
-v show" are called with the -v switch.
ok markus@


# 1.31 19-May-2010 chl

remove unused variables

ok claudio@ michele@


# 1.30 23-Mar-2010 claudio

Sync with show.c of route(8). OK michele@


Revision tags: OPENBSD_4_7_BASE
# 1.29 14-Jan-2010 claudio

Similar fix for default route printing as done in netstat. Make sure mask
is 0 when sa_len is 0.


# 1.28 11-Jan-2010 dlg

"default" routes need a mask of 0 too.

from and ok claudio@


# 1.27 07-Aug-2009 martynas

if buffers overlap; result will be undefined. ok claudio@, michele@


# 1.26 05-Aug-2009 deraadt

missing break


Revision tags: OPENBSD_4_6_BASE
# 1.25 27-Jun-2009 michele

Mark MPLS routes with T (tagged) in route output.

suggested by dlg@, ok claudio@, laurent@, blambert@


# 1.24 31-May-2009 claudio

There is no need to mask priority with RTP_MASK because it is already done
by the kernel.


# 1.23 23-May-2009 chris

typo


# 1.22 23-May-2009 chris

missed rtm_hdrlen conversion in two places

ok claudio@


# 1.21 28-Apr-2009 michele

Sync with kernel changes.
Add support to route(8) for a new dummy operation to allow packets coming in
with a particular label to leave the MPLS cloud and join ipv4/ipv6 stack.

ok claudio@ laurent@


Revision tags: OPENBSD_4_5_BASE
# 1.20 06-Feb-2009 chl

remove unused variables.

ok henning@ michele@


# 1.19 03-Feb-2009 michele

Reflect MPLS kernel changes. Operations are stored now in rt_mpls field.

ok claudio@ laurent@


# 1.18 26-Jan-2009 claudio

Again use P to mark multipath routes in route output. OK henning@


# 1.17 08-Jan-2009 michele

Reflect MPLS kernel changes.

ok claudio@


# 1.16 15-Dec-2008 michele

Unbreak netstat, reflecting kernel changes.
Now it shows MPLS informations correctly.

OK claudio@


# 1.15 15-Dec-2008 deraadt

work around tree breakage by mpls people


# 1.14 15-Sep-2008 claudio

Similar to route(8) change mask rtm->rtm_priority with RTP_MASK to show
correct values. OK henning@


Revision tags: OPENBSD_4_4_BASE
# 1.13 08-May-2008 claudio

Sync netstat show.c with route show.c to gain mpls support and to show the
routing priority. hai norby@


Revision tags: OPENBSD_4_3_BASE
# 1.12 14-Dec-2007 deraadt

remove 21 nlist variables, and instead use sysctl to query the kernel
turn on INET6 the default (remove the #ifdef's)
ok claudio reyk


# 1.11 05-Sep-2007 claudio

Correct the format strings after the recent rt_metrics changes.
rmx_pksent is not u_int64_t all others are just u_int.


Revision tags: OPENBSD_4_2_BASE
# 1.10 25-Jul-2007 claudio

Make it possible to show alternate routing tables in netstat. This mostly
comes from route(8) which already had the -T option. OK henning@


# 1.9 24-Jul-2007 claudio

Bring back a few things from route/show.c which I like better.


# 1.8 21-Jul-2007 claudio

Similar to sbin/route/show.c:
Check the rtm_version before trying to print an entry. If the rtmsg has a
different version skip it and don't try to print it. Solves a SIGSEGV I have
triggered with one of my scarier diffs. OK henning@


# 1.7 19-Jun-2007 ray

Remove unused variable.


# 1.6 04-Jun-2007 henning

remove IPX support, agreed by many


# 1.5 23-Mar-2007 pyr

Add a new flag -F to netstat restricting route display in conjuction
with -r to routes in the same address family as the destination.
ok henning@, claudio@


Revision tags: OPENBSD_4_1_BASE
# 1.4 29-Dec-2006 claudio

Netstat has the same issue problem as route when printing a default inet6
route. Need to typecast the sizeof() to int so that the compare works.
Having a negativ lim is OK. Reported by Bj�rn Ketelaars. OK deraadt@


# 1.3 17-Nov-2006 itojun

change semantics of ff01::/16 to interface local multicast
(to sync up with more recent IPv6 spec)

ok from: deraadt mcbride


Revision tags: OPENBSD_4_0_BASE
# 1.2 30-May-2006 todd

this fixes a crash observed by Naddy on amd64, and permits the src/dst ip's to
be visible .. when IPv6 sa flows are present
ok claudio@


# 1.1 27-May-2006 claudio

Moving netstat from kvm snooping to retrieving the routing tables via
sysctl. Most code is stolen from route -- which was stolen from netstat.
kvm snooping code is still in and useable. Put it in deraadt@ henning@