xref: /freebsd/share/man/man9/rtentry.9 (revision df7f5d4de4592a8948a25ce01e5bddfbb7ce39dc)
1.\"
2.\" Copyright 1996 Massachusetts Institute of Technology
3.\"
4.\" Permission to use, copy, modify, and distribute this software and
5.\" its documentation for any purpose and without fee is hereby
6.\" granted, provided that both the above copyright notice and this
7.\" permission notice appear in all copies, that both the above
8.\" copyright notice and this permission notice appear in all
9.\" supporting documentation, and that the name of M.I.T. not be used
10.\" in advertising or publicity pertaining to distribution of the
11.\" software without specific, written prior permission.  M.I.T. makes
12.\" no representations about the suitability of this software for any
13.\" purpose.  It is provided "as is" without express or implied
14.\" warranty.
15.\"
16.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''.  M.I.T. DISCLAIMS
17.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
18.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
20.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
23.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
25.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27.\" SUCH DAMAGE.
28.\"
29.\"	$Id$
30.Dd October 8, 1996
31.Os
32.Dt RTENTRY 9
33.Sh NAME
34.Nm rtentry
35.Nd structure of an entry in the kernel routing table
36.Sh SYNOPSIS
37.Fd #include <sys/socket.h>
38.Fd #include <net/route.h>
39.Sh DESCRIPTION
40The kernel provides a common mechanism by which all protocols can store
41and retrieve entries from a central table of routes.  Parts of this
42mechanism are also used to interact with user-level processes by means
43of a socket in the
44.Xr route 4
45pseudo-protocol family.
46The
47.Aq Pa net/route.h
48header file defines the structures and manifest constants used in this
49facility.
50.Pp
51The basic structure a route is defined by
52.Dq Li struct rtentry ,
53which includes the following fields:
54.Bl -tag -offset indent -width 6n
55.It Li "struct radix_node rt_nodes[2];"
56Glue used by the radix-tree routines.  These members also include in
57their substructure the key (i.e., destination address) and mask used
58when the route was created.  The
59.Fn rt_key \&rt
60and
61.Fn rt_mask \&rt
62macros can be used to extract this information (in the form of a
63.Dq Li "struct sockaddr *" )
64given a
65.Li "struct rtentry *" .
66.It Li "struct sockaddr *rt_gateway;"
67The
68.Dq target
69of the route, which can either represent a destination in its own
70right (some protocols will put a link-layer address here), or some
71intermediate stop on the way to that destination (if the
72.Dv RTF_GATEWAY
73flag is set).
74.It Li "short rt_refcnt;"
75Route entries are reference-counted; this field indicates the number
76of external (to the radix tree) references.  If the
77.Dv RTF_UP
78flag is not present, the
79.Fn rtfree
80function will delete the route from the radix tree when the last
81reference drops.
82.It Li "u_long rt_flags;"
83See below.
84.It Li "struct ifnet *rt_ifp;"
85.It Li "struct ifaddr *rt_ifa;"
86These two fields represent the
87.Dq answer ,
88as it were, to the question posed by a route lookup; that is, they
89name the interface and interface address to be used in sending a
90packet to the destination or set of destinations which this route
91represents.
92.It Li "struct sockaddr *rt_genmask;"
93When the
94.Fn rtalloc
95family of functions performs a cloning operation as requested by the
96.Dv RTF_CLONING
97or
98.Dv RTF_PRCLONING
99flag, this field is used as the mask for the new route which is
100inserted into the table.  If this field is a null pointer, then a host
101route is generated.
102.It Li "caddr_t rt_llinfo;"
103When the
104.Dv RTF_LLINFO
105flag is set, this field contains information specific to the link
106layer represented by the named interface address.  (It is normally
107managed by the
108.Fn rt_ifa->ifa_rtrequest
109routine.)  Protocols such as
110.Xr arp 4
111use this field to reference per-destination state internal to that
112protocol.
113.It Li "struct rt_metrics rt_rmx;"
114See below.
115.It Li "struct rtentry *rt_gwroute;"
116This member is a reference to a route whose destination is
117.Li rt_gateway .
118It is only used for
119.Dv RTF_GATEWAY
120routes.
121.\" .It Dv "int (*rt_output)();"
122.\" See below.
123.It Dv "struct rtentry *rt_parent;"
124A reference to the route from which this route was cloned, or a null
125pointer if this route was not generated by cloning.  See also the
126.Dv RTF_WASCLONED
127flag.
128.El
129.Pp
130The following flag bits are defined:
131.Bl -tag -offset indent -width RTF_CHAINDELETE -compact
132.It Dv RTF_UP
133The route is not deleted.
134.It Dv RTF_GATEWAY
135The route points to an intermediate destination and not the ultimate
136recipient; the
137.Li rt_gateway
138and
139.Li rt_gwroute
140fields name that destination.
141.It Dv RTF_HOST
142This is a host route.
143.It Dv RTF_REJECT
144The destination is presently unreachable.  This should result in an
145.Er EHOSTUNREACH
146error from output routines.
147.It Dv RTF_DYNAMIC
148This route was created dynamically by
149.Fn rtredirect .
150.It Dv RTF_MODIFIED
151This route was modified by
152.Fn rtredirect .
153.It Dv RTF_DONE
154Used only in the
155.Xr route 4
156protocol, indicating that the request was executed.
157.It Dv RTF_CLONING
158When this route is returned as a result of a lookup, automatically
159create a new route using this one as a template and
160.Li rt_genmask
161(if present) as a mask.
162.It Dv RTF_XRESOLVE
163When this route is returned as a result of a lookup, send a report on
164the
165.Xr route 4
166interface requesting that an external process perform resolution for
167this route.  (Used in conjunction with
168.Dv RTF_CLONING . )
169.It Dv RTF_LLINFO
170Indicates that this route represents information being managed by a
171link layer's adaptation layer (e.g.,
172.Tn ARP ) .
173.It Dv RTF_STATIC
174Indicates that this route was manually added by means of the
175.Xr route 8
176command.
177.It Dv RTF_BLACKHOLE
178Requests that output sent via this route be discarded.
179.It Dv RTF_PROTO1
180.It Dv RTF_PROTO2
181.It Dv RTF_PROTO3
182Protocol-specific.
183.It Dv RTF_PRCLONING
184Like
185.Dv RTF_CLONING ,
186only managed by an entire protocol.  (E.g.,
187.Tn IP
188uses this flag to manage a per-host cache integrated with the routing
189table, for those destinations which do not have a link layer
190performing this function.)
191.It Dv RTF_WASCLONED
192Indicates that this route was generated as a result of cloning
193requested by the
194.Dv RTF_CLONING
195or
196.Dv RTF_PRCLONING
197flag.  When set, the
198.Li rt_parent
199field indicates the route from which this one was generated.
200.It Dv RTF_PINNED
201(Reserved for future use to indicate routes which are not to be
202modified by a routing protocol.)
203.It Dv RTF_LOCAL
204Indicates that the destination of this route is an address configured
205as belonging to this system.
206.It Dv RTF_BROADCAST
207Indicates that the destination is a broadcast address.
208.It Dv RTF_MULTICAST
209Indicates that the destination is a multicast address.
210.El
211.Pp
212Every route has associated with it a set of metrics, defined by
213.Li struct rt_metrics :
214.Bl -tag -offset indent -width 6n
215.It Li "u_long rmx_locks;"
216Flag bits indicating which metrics the kernel is not permitted to
217dynamically modify.
218.It Li "u_long rmx_mtu;"
219MTU for this path.
220.It Li "u_long rmx_hopcount;"
221Number of intermediate systems on the path to this destination.
222.It Li "u_long rmx_expire;"
223The time
224(\*(aga la
225.Xr time 2 )
226at which this route should expire, or zero if it should never expire.
227It is the responsibility of individual protocol suites to ensure that routes
228are actually deleted once they expire.
229.It Li "u_long rmx_recvpipe;"
230Nominally, the bandwidth-delay product for the path
231.Em from
232the destination
233.Em to
234this system.  In practice, this value is used to set the size of the
235receive buffer (and thus the window in sliding-window protocols like
236.Tn TCP ) .
237.It Li "u_long rmx_sendpipe;"
238As before, but in the opposite direction.
239.It Li "u_long rmx_ssthresh;"
240The slow-start threshold used in
241.Tn TCP
242congestion-avoidance.
243.It Li "u_long rmx_rtt;"
244The round-trip time to this destination, in units of
245.Dv RMX_RTTUNIT
246per second.
247.It Li "u_long rmx_rttvar;"
248The average deviation of the round-type time to this destination, in
249units of
250.Dv RMX_RTTUNIT
251per second.
252.It Li "u_long rmx_pksent;"
253A count of packets successfully sent via this route.
254.It Li "u_long rmx_filler[4];"
255.\" XXX badly named
256Empty space available for protocol-specific information.
257.El
258.Sh SEE ALSO
259.Xr route 4 ,
260.Xr route 8 ,
261.Xr rtalloc 9
262.Sh HISTORY
263The
264.Nm rtentry
265structure first appeared in
266.Bx 4.2 .
267The radix-tree representation of the routing table and the
268.Nm rt_metrics structure first appeared in
269.Bx 4.3 reno .
270The
271.Nm RTF_PRCLONING
272mechanism first appeared in
273.Fx 2.0 .
274.Sh BUGS
275There are a number of historical relics remaining in this interface.
276The
277.Li rt_gateway
278and
279.Li rmx_filler
280fields could be named better.
281.Pp
282There is some disagreement over whether it is legitimate for
283.Dv RTF_LLINFO
284to be set by any process other than
285.Fn rt_ifa->ifa_rtrequest .
286.Sh AUTHOR
287This manual page was written by Garrett Wollman.
288