Technical data

Gateway Routing Daemon (GATED) Configuration Reference
A.16 The Kernel Statement
A.16.2.2 Updating the Forwarding Table with the Routing Socket Interface
The routing socket interface to the kernel forwarding table was introduced in
BSD 4.3 Reno, widely distributed in BSD 4.3 Net/2 and improved in BSD 4.4.
This interface is simply a socket, similar to a UDP socket, on which the kernel
and GATED exchange messages. It has several advatages over the
ioctl( )
interface:
Variable subnet masks
The network mask is passed to the kernel explicitly. This allows different
masks to be used on subnets of the same network. It also allows routes
with masks that are more general than the natural mask to be used. This is
known as classless routing.
Two way interface
Not only is GATED able to change the kernel forwarding table with this
interface, but the kernel can also report changes to the forwarding table to
GATED. The most interesting of these is an indication that a redirect has
modified the kernel forwarding table; this means that GATED no longer
needs to monitor ICMP messages to learn about redirects. Plus, there is an
indication of whether the kernel processed the redirect, GATED can safely
ignore redirect messages that the kernel did not process.
Updates visible
Changes to the routing table by other processes, including the route command
are received via the routing socket. This allows GATED to insure that the
kernel forwarding table is synchronized with the routing table. Also, it
allows the system administrator to perform some operations with the ROUTE
command while GATED is running.
Changes supported
There is a functioning change message that allows routes in the kernel to be
atomically changed. Some early verions of the routing socket code had bugs in
the change message processing. There are compilation time and configuration
time options that cause delete and add sequences to be used instead of change
messages.
Expandable
New levels of kernel and GATED communications may be added by adding
new message types.
A.16.3 Reading the Forwarding Table
When GATED starts up it reads the kernel forwarding table and installs
corresponding routes in the routing table. These routes are called remnants
and are timed out after a configured interval (which defaults to 3 minutes), or as
soon as a more attractive route is learned. This allows forwarding to occur during
the time it takes the routing protocols to start learning routes.
There are three main methods for reading the forwarding table from the kernel:
Reading forwarding table with KMEM
On many systems, especially those based on BSD 4.3, GATED must have
knowledge of the kernel’s data structures to read the current state of
forwarding table. This method is slow and subject to error if the kernel
forwarding table is updated while GATED is reading it. This can happen if
the system administrator uses the ROUTE command, or an ICMP redirect
message is received while GATED is starting up.
Gateway Routing Daemon (GATED) Configuration Reference A–25