RTENTRY(9) BSD Kernel Developer's Manual RTENTRY(9)NAMErtentry — structure of an entry in the kernel routing table
The kernel provides a common mechanism by which all protocols can store
and retrieve entries from a central table of routes. Parts of this mech‐
anism are also used to interact with user-level processes by means of a
socket in the route(4) pseudo-protocol family. The <net/route.h> header
file defines the structures and manifest constants used in this facility.
The basic structure of a route is defined by struct rtentry, which
includes the following fields:
struct radix_node rt_nodes;
Glue used by the radix-tree routines. These members also
include in their substructure the key (i.e., destination
address) and mask used when the route was created. The
rt_key(rt) and rt_mask(rt) macros can be used to extract
this information (in the form of a struct sockaddr *) given
a struct rtentry *.
struct sockaddr *rt_gateway;
The “target” of the route, which can either represent a
destination in its own right (some protocols will put a
link-layer address here), or some intermediate stop on the
way to that destination (if the RTF_GATEWAY flag is set).
Route entries are reference-counted; this field indicates
the number of external (to the radix tree) references.
struct ifnet *rt_ifp;
struct ifaddr *rt_ifa;
These two fields represent the “answer”, as it were, to the
question posed by a route lookup; that is, they name the
interface and interface address to be used in sending a
packet to the destination or set of destinations which this
struct rt_metrics_lite rt_rmx;
See below. If the RTF_UP flag is not present, the rtfree()
function will delete the route from the radix tree when the
last reference drops.
struct rtentry *rt_gwroute;
This member is a reference to a route whose destination is
rt_gateway. It is only used for RTF_GATEWAY routes.
struct mtx rt_mtx;
Mutex to lock this routing entry.
The following flag bits are defined:
RTF_UP The route is not deleted.
RTF_GATEWAY The route points to an intermediate destination and
not the ultimate recipient; the rt_gateway and
rt_gwroute fields name that destination.
RTF_HOST This is a host route.
RTF_REJECT The destination is presently unreachable. This
should result in an EHOSTUNREACH error from output
RTF_DYNAMIC This route was created dynamically by rtredirect().
RTF_MODIFIED This route was modified by rtredirect().
RTF_DONE Used only in the route(4) protocol, indicating that
the request was executed.
RTF_XRESOLVE When this route is returned as a result of a lookup,
send a report on the route(4) interface requesting
that an external process perform resolution for this
RTF_STATIC Indicates that this route was manually added by
means of the route(8) command.
RTF_BLACKHOLE Requests that output sent via this route be dis‐
RTF_PRCLONING This flag is obsolete and simply ignored by facil‐
RTF_PINNED (Reserved for future use to indicate routes which
are not to be modified by a routing protocol.)
RTF_LOCAL Indicates that the destination of this route is an
address configured as belonging to this system.
RTF_BROADCAST Indicates that the destination is a broadcast
RTF_MULTICAST Indicates that the destination is a multicast
Every route has associated with it a set of metrics, stored in struct
rt_metrics_lite. Metrics are supplied in struct rt_metrics passed with
routing control messages via route(4) API. Currently only rmx_mtu,
rmx_expire, and rmx_pksent metrics are used in struct rt_metrics_lite.
All others are ignored.
The following metrics are defined by struct rt_metrics:
Flag bits indicating which metrics the kernel is not per‐
mitted to dynamically modify.
MTU for this path.
Number of intermediate systems on the path to this destina‐
The time (a la time(3)) at which this route should expire,
or zero if it should never expire. It is the responsibil‐
ity of individual protocol suites to ensure that routes are
actually deleted once they expire.
Nominally, the bandwidth-delay product for the path from
the destination to this system. In practice, this value is
used to set the size of the receive buffer (and thus the
window in sliding-window protocols like TCP).
As before, but in the opposite direction.
The slow-start threshold used in TCP congestion-avoidance.
The round-trip time to this destination, in units of
RMX_RTTUNIT per second.
The average deviation of the round-trip time to this desti‐
nation, in units of RMX_RTTUNIT per second.
A count of packets successfully sent via this route.
Empty space available for protocol-specific information.
SEE ALSOroute(4), route(8), rtalloc(9)HISTORY
The rtentry structure first appeared in 4.2BSD. The radix-tree represen‐
tation of the routing table and the rt_metrics structure first appeared
This manual page was written by Garrett Wollman.
There are a number of historical relics remaining in this interface. The
rt_gateway and rmx_filler fields could be named better.
BSD December 11, 2008 BSD