Index | Thread | Search

From:
Vitor Fernandes <rqm@uvxi.org>
Subject:
sysctl(2): improve PF_ROUTE manual page section
To:
tech@openbsd.org
Date:
Sat, 11 Apr 2026 17:01:55 +0200

Download raw body.

Thread
  • Vitor Fernandes:

    sysctl(2): improve PF_ROUTE manual page section

Hello tech@

While studying the routing table code, I noticed the PF_ROUTE section of
the sysctl(2) manual page is somewhat inaccurate and missing some stuff.
The patch below tries to improve it.

The specifics of what I tried to improve are:

1. First paragraph reads as if all the fifth level names return the same
   type of data which is not true.
2. Most of the fifth level names are not described. NET_RT_SOURCE is
   implemented but not documented.

Please critique the language and let me know if anything can be improved
or if it's not clear enough.

Index: lib/libc/sys/sysctl.2
===================================================================
RCS file: /cvs/src/lib/libc/sys/sysctl.2,v
diff -u -p -u -p -r1.72 sysctl.2
--- lib/libc/sys/sysctl.2	4 Apr 2026 19:26:32 -0000	1.72
+++ lib/libc/sys/sysctl.2	11 Apr 2026 14:55:17 -0000
@@ -1298,31 +1298,77 @@ privileges may change the value.
 .El
 .Bl -tag -width "123456"
 .It Dv PF_ROUTE
-Return the entire routing table or a subset of it.
-The data is returned as a sequence of routing messages (see
+Get information on the routing table.
+See
 .Xr route 4
-for the header file, format, and meaning).
-The length of each message is contained in the message header.
+for information about the structures and their meaning.
 .Pp
 The third level name is a protocol number, which is currently always 0.
 The fourth level name is an address family, which may be set to 0 to
 select all address families.
 The fifth and sixth level names are as follows:
-.Bl -column "Fifth level name" "Sixth level is:" -offset indent
-.It Sy "Fifth level name" Ta Sy "Sixth level is:"
-.It Dv NET_RT_DUMP Ta "priority"
-.It Dv NET_RT_FLAGS Ta "rtflags"
-.It Dv NET_RT_IFLIST Ta "None"
-.It Dv NET_RT_IFNAMES Ta "None"
-.It Dv NET_RT_STATS Ta "None"
-.It Dv NET_RT_TABLE Ta "rtableid"
+.Bl -column "Fifth level name" "struct if_nameindex_msg" "Sixth level is:" -offset indent
+.It Sy "Fifth level name" Ta Sy "Type" Ta Sy "Sixth level is:"
+.It Dv NET_RT_DUMP Ta "struct rt_msghdr" Ta "priority"
+.It Dv NET_RT_FLAGS Ta "struct rt_msghdr" Ta "rtflags"
+.It Dv NET_RT_IFLIST Ta "struct if_msghdr" Ta "ifindex"
+.It Dv NET_RT_IFNAMES Ta "struct if_nameindex_msg" Ta "ifindex"
+.It Dv NET_RT_STATS Ta "struct rtstat" Ta "None"
+.It Dv NET_RT_TABLE Ta "struct rt_tableinfo" Ta "rtableid"
+.It Dv NET_RT_SOURCE Ta "struct sockaddr" Ta "rtableid"
 .El
+.Pp
+The variables are as follows:
 .Bl -tag -width "123456"
 .It Dv NET_RT_DUMP
-If set to 0, show all routes.
-If set to any number, show all routes with that number priority.
-If set to a negative number, show routes that do not have the positive
+An array of
+.Vt struct rt_msghdr
+is returned, containing all the routes that match priority.
+If priority is set to 0, return all routes.
+If set to any number, return all routes with that number priority.
+If set to a negative number, return routes that do not have the positive
 priority value.
+.It Dv NET_RT_FLAGS
+An array of
+.Vt struct rt_msghdr
+is returned, containing all the routes with the flags rtflags set.
+.It Dv NET_RT_IFLIST
+An array of interface messages is returned, containing information on
+the network interfaces.
+If ifindex is set to 0, return all interfaces.
+If set to any number, return the interface with that index.
+The interface messages format consists of a
+.Vt struct if_msghdr
+followed by a number of
+.Vt struct ifa_msghdr ,
+one for each interface address associated with the interface.
+.It Dv NET_RT_IFNAMES
+An array of
+.Vt struct if_nameindex_msg
+is returned, containing the name of the interfaces.
+If ifindex is set to 0, return all interfaces.
+If set to any number, return the interface with that index.
+.It NET_RT_STATS
+A
+.Vt struct rtstat
+is returned, containing statistics about the current routing table.
+.It NET_RT_TABLE
+A
+.Vt struct rt_tableinfo
+is returned, containing the routing domain associated with the routing
+table rtableid.
+.It NET_RT_SOURCE
+An array of
+.Vt sockaddr
+structures is returned, containing the sources of the routing table rtableid.
+An entry in the array is either a
+.Vt struct sockaddr_in
+if the family is
+.Dv AF_INET
+or
+.Vt struct sockaddr_in6
+if it is
+.Dv AF_INET6 .
 .El
 .Pp
 An optional seventh level name can be provided to select the routing table