rtentry(9)
NAME
rtentry - structure of an entry in the kernel routing table
SYNOPSIS
#include <sys/types.h> #include <sys/socket.h> #include <net/route.h>
DESCRIPTION
- The kernel provides a common mechanism by which all proto
- cols can store and retrieve entries from a central table of routes. Parts
- of this mechanism are also used to interact with user-level processes by
- means of a socket in the route(4) pseudo-protocol family. The #include <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[2];
Glue used by the radix-tree routines. Thesemembers 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 usedto extract this information (in the form of a structsockaddr *) 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).
- u_long rt_flags;
- See below.
- 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 destina
- tions which this route represents.
- struct rt_metrics_lite rt_rmx;
- See below.
- long rt_refcnt;
- Route entries are reference-counted; this
- field indicates the number of external (to the radix tree)
- references. 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 sockaddr *rt_genmask;
- When the rtalloc() family of functions per
- forms a cloning operation as requested by the RTF_CLONING
- flag, this field is used as the mask for the new route which is
- inserted into the table. If this field is a null
- pointer, then a host route is generated.
- caddr_t rt_llinfo;
- When the RTF_LLINFO flag is set, this field
- contains information specific to the link layer represented
- by the named interface address. (It is normally managed by
- the rt_ifa->ifa_rtrequest routine.) Protocols
- such as arp(4) use this field to reference per-destination
- state internal to that protocol.
- 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 rtentry *rt_parent;
- A reference to the route from which this route
- was cloned, or a null pointer if this route was not gener
- ated by cloning. See also the RTF_WASCLONED flag.
- 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; thert_gateway and rt_gwroute fields name thatdestination.
- RTF_HOST This is a host route. RTF_REJECT The destination is presently un
- reachable. This
should result in an EHOSTUNREACHerror from output routines.
- 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_CLONING When this route is returned as a
- result of a
lookup, automatically create a newroute using this one as a template andrt_genmask (if present) as a mask.
- RTF_XRESOLVE When this route is returned as a
- result of a
lookup, send a report on theroute(4) interface requesting that an external processperform resolution for this route. (Used inconjunction with RTF_CLONING.)
- RTF_LLINFO Indicates that this route repre
- sents information
being managed by a link layer'sadaptation layer (e.g., ARP).
- RTF_STATIC Indicates that this route was manu
- ally added by
means of the route(8) command.
- RTF_BLACKHOLE Requests that output sent via this
- route be dis
carded.
- RTF_PROTO1 RTF_PROTO2 RTF_PROTO3 Protocol-specific. RTF_PRCLONING This flag is obsolete and simply
- ignored by
facility.
- RTF_WASCLONED Indicates that this route was gen
- erated as a
result of cloning requested by theRTF_CLONING flag. When set, the rt_parentfield indicates the route from which this one wasgenerated.
- RTF_PINNED (Reserved for future use to indi
- cate routes
which are not to be modified by arouting protocol.)
- RTF_LOCAL Indicates that the destination of
- this route is
an address configured as belongingto this system.
- RTF_BROADCAST Indicates that the destination is a
- broadcast
address.
- RTF_MULTICAST Indicates that the destination is a
- multicast
address.
- 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:
- u_long rmx_locks;
Flag bits indicating which metrics the kernelis not permitted to dynamically modify.
- u_long rmx_mtu;
- MTU for this path.
- u_long rmx_hopcount;
- Number of intermediate systems on the path to
- this destination.
- u_long rmx_expire;
- The time (a la time(3)) at which this route
- should expire, or zero if it should never expire. It is the
- responsibility of individual protocol suites to ensure
- that routes are actually deleted once they expire.
- u_long rmx_recvpipe;
- 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).
- u_long rmx_sendpipe;
- As before, but in the opposite direction.
- u_long rmx_ssthresh;
- The slow-start threshold used in TCP conges
- tion-avoidance.
- u_long rmx_rtt;
- The round-trip time to this destination, in
- units of RMX_RTTUNIT per second.
- u_long rmx_rttvar;
- The average deviation of the round-type time
- to this destination, in units of RMX_RTTUNIT per second.
- u_long rmx_pksent;
- A count of packets successfully sent via this
- route.
- u_long rmx_filler[4];
- Empty space available for protocol-specific
- information.
SEE ALSO
route(4), route(8), rtalloc(9)
HISTORY
- The rtentry structure first appeared in 4.2BSD. The radix
- tree representation of the routing table and the rt_metrics structure
- first appeared in 4.3BSD-Reno.
AUTHORS
This manual page was written by Garrett Wollman.
BUGS
- There are a number of historical relics remaining in this
- interface. The rt_gateway and rmx_filler fields could be named better.
- There is some disagreement over whether it is legitimate for
- RTF_LLINFO to be set by any process other than rt_ifa->ifa_rtrequest.
- BSD October 7, 2004