Download raw body.
sysctl.2: NET_RT_DUMP uses the current rtable
On Wed, Oct 09, 2024 at 04:47:46PM +0000, Lucas Gabriel Vuotto wrote:
> I got confused by the manpage, as it states that rtable 0 is used. My
> understanding of /sys/net/rtsock.c:sysctl_rtable is that the current
> rtable is used instead:
>
> 2187 if (namelen == 4) {
> 2188 tableid = name[3];
> 2189 if (!rtable_exists(tableid))
> 2190 return (ENOENT);
> 2191 } else
> 2192 tableid = curproc->p_p->ps_rtableid;
>
> The misunderstanding prompted me to hunt for NET_RT_DUMP usage in ports
> and prepare useless patches for 7 ports. :')
Yes, this is correct the default changed in rev 1.110 of rtsock.c 14 years
ago. We missed to update the manpage then. Before that (up to rev 1.62)
the default was indeed 0 (since the process had no ps_rtableid).
> diff /usr/src
> commit - 352e6c5d7c95cf0c08d3c38de0fb23cb51af1fce
> path + /usr/src
> blob - 78c69ff581350ca2587f400bd58916a6dbfd0d16
> file + lib/libc/sys/sysctl.2
> --- lib/libc/sys/sysctl.2
> +++ lib/libc/sys/sysctl.2
> @@ -1322,7 +1322,7 @@ priority value.
> .Pp
> An optional seventh level name can be provided to select the routing table
> on which to run the operation.
> -If not provided, the table with ID 0 is used.
> +If not provided, the current routing table is used.
> .It Dv PF_INET
> Get or set various global information about IPv4
> .Pq Internet Protocol version 4 .
>
OK claudio@
--
:wq Claudio
sysctl.2: NET_RT_DUMP uses the current rtable