xref: /freebsd/share/man/man9/rtentry.9 (revision 2357939bc239bd5334a169b62313806178dd8f30)
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.\" $FreeBSD$
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.In sys/types.h
38.In sys/socket.h
39.In net/route.h
40.Sh DESCRIPTION
41The kernel provides a common mechanism by which all protocols can store
42and retrieve entries from a central table of routes.
43Parts of this
44mechanism are also used to interact with user-level processes by means
45of a socket in the
46.Xr route 4
47pseudo-protocol family.
48The
49.In net/route.h
50header file defines the structures and manifest constants used in this
51facility.
52.Pp
53The basic structure of a route is defined by
54.Dq Li struct rtentry ,
55which includes the following fields:
56.Bl -tag -offset indent -width 6n
57.It Xo
58.Vt "struct radix_node rt_nodes[2]" ;
59.Xc
60Glue used by the radix-tree routines.
61These members also include in
62their substructure the key (i.e., destination address) and mask used
63when the route was created.
64The
65.Vt rt_key \&rt
66and
67.Vt rt_mask \&rt
68macros can be used to extract this information (in the form of a
69.Dq Li "struct sockaddr *" )
70given a
71.Li "struct rtentry *" .
72.It Xo
73.Vt "struct sockaddr *rt_gateway" ;
74.Xc
75The
76.Dq target
77of the route, which can either represent a destination in its own
78right (some protocols will put a link-layer address here), or some
79intermediate stop on the way to that destination (if the
80.Dv RTF_GATEWAY
81flag is set).
82.It Xo
83.Vt "long rt_refcnt" ;
84.Xc
85Route entries are reference-counted; this field indicates the number
86of external (to the radix tree) references.
87If the
88.Dv RTF_UP
89flag is not present, the
90.Fn rtfree
91function will delete the route from the radix tree when the last
92reference drops.
93.It Xo
94.Vt "u_long rt_flags" ;
95.Xc
96See below.
97.It Xo
98.Vt "struct ifnet *rt_ifp" ;
99.Xc
100.It Xo
101.Vt "struct ifaddr *rt_ifa" ;
102.Xc
103These two fields represent the
104.Dq answer ,
105as it were, to the question posed by a route lookup; that is, they
106name the interface and interface address to be used in sending a
107packet to the destination or set of destinations which this route
108represents.
109.It Xo
110.Vt "struct sockaddr *rt_genmask" ;
111.Xc
112When the
113.Fn rtalloc
114family of functions performs a cloning operation as requested by the
115.Dv RTF_CLONING
116or
117.Dv RTF_PRCLONING
118flag, this field is used as the mask for the new route which is
119inserted into the table.
120If this field is a null pointer, then a host
121route is generated.
122.It Xo
123.Vt "caddr_t rt_llinfo" ;
124.Xc
125When the
126.Dv RTF_LLINFO
127flag is set, this field contains information specific to the link
128layer represented by the named interface address.
129.Po
130It is normally managed by the
131.Vt rt_ifa->ifa_rtrequest
132routine.
133.Pc
134Protocols such as
135.Xr arp 4
136use this field to reference per-destination state internal to that
137protocol.
138.It Xo
139.Vt "struct rt_metrics rt_rmx" ;
140.Xc
141See below.
142.It Xo
143.Vt "struct rtentry *rt_gwroute" ;
144.Xc
145This member is a reference to a route whose destination is
146.Li rt_gateway .
147It is only used for
148.Dv RTF_GATEWAY
149routes.
150.\" .It Dv "int (*rt_output)();"
151.\" See below.
152.It Xo
153.Vt "struct rtentry *rt_parent" ;
154.Xc
155A reference to the route from which this route was cloned, or a null
156pointer if this route was not generated by cloning.
157See also the
158.Dv RTF_WASCLONED
159flag.
160.El
161.Pp
162The following flag bits are defined:
163.Bl -tag -offset indent -width RTF_CHAINDELETE -compact
164.It Dv RTF_UP
165The route is not deleted.
166.It Dv RTF_GATEWAY
167The route points to an intermediate destination and not the ultimate
168recipient; the
169.Li rt_gateway
170and
171.Li rt_gwroute
172fields name that destination.
173.It Dv RTF_HOST
174This is a host route.
175.It Dv RTF_REJECT
176The destination is presently unreachable.
177This should result in an
178.Er EHOSTUNREACH
179error from output routines.
180.It Dv RTF_DYNAMIC
181This route was created dynamically by
182.Fn rtredirect .
183.It Dv RTF_MODIFIED
184This route was modified by
185.Fn rtredirect .
186.It Dv RTF_DONE
187Used only in the
188.Xr route 4
189protocol, indicating that the request was executed.
190.It Dv RTF_CLONING
191When this route is returned as a result of a lookup, automatically
192create a new route using this one as a template and
193.Li rt_genmask
194(if present) as a mask.
195.It Dv RTF_XRESOLVE
196When this route is returned as a result of a lookup, send a report on
197the
198.Xr route 4
199interface requesting that an external process perform resolution for
200this route.
201.Po
202Used in conjunction with
203.Dv RTF_CLONING .
204.Pc
205.It Dv RTF_LLINFO
206Indicates that this route represents information being managed by a
207link layer's adaptation layer (e.g.,
208.Tn ARP ) .
209.It Dv RTF_STATIC
210Indicates that this route was manually added by means of the
211.Xr route 8
212command.
213.It Dv RTF_BLACKHOLE
214Requests that output sent via this route be discarded.
215.It Dv RTF_PROTO1
216.It Dv RTF_PROTO2
217.It Dv RTF_PROTO3
218Protocol-specific.
219.It Dv RTF_PRCLONING
220Like
221.Dv RTF_CLONING ,
222only managed by an entire protocol.
223.Po
224E.g.,
225.Tn IP
226uses this flag to manage a per-host cache integrated with the routing
227table, for those destinations which do not have a link layer
228performing this function.
229.Pc
230.It Dv RTF_WASCLONED
231Indicates that this route was generated as a result of cloning
232requested by the
233.Dv RTF_CLONING
234or
235.Dv RTF_PRCLONING
236flag.
237When set, the
238.Li rt_parent
239field indicates the route from which this one was generated.
240.It Dv RTF_PINNED
241(Reserved for future use to indicate routes which are not to be
242modified by a routing protocol.)
243.It Dv RTF_LOCAL
244Indicates that the destination of this route is an address configured
245as belonging to this system.
246.It Dv RTF_BROADCAST
247Indicates that the destination is a broadcast address.
248.It Dv RTF_MULTICAST
249Indicates that the destination is a multicast address.
250.El
251.Pp
252Every route has associated with it a set of metrics, defined by
253.Li struct rt_metrics :
254.Bl -tag -offset indent -width 6n
255.It Xo
256.Vt "u_long rmx_locks" ;
257.Xc
258Flag bits indicating which metrics the kernel is not permitted to
259dynamically modify.
260.It Xo
261.Vt "u_long rmx_mtu" ;
262.Xc
263MTU for this path.
264.It Xo
265.Vt "u_long rmx_hopcount" ;
266.Xc
267Number of intermediate systems on the path to this destination.
268.It Xo
269.Vt "u_long rmx_expire" ;
270.Xc
271The time
272(a la
273.Xr time 3 )
274at which this route should expire, or zero if it should never expire.
275It is the responsibility of individual protocol suites to ensure that routes
276are actually deleted once they expire.
277.It Xo
278.Vt "u_long rmx_recvpipe" ;
279.Xc
280Nominally, the bandwidth-delay product for the path
281.Em from
282the destination
283.Em to
284this system.
285In practice, this value is used to set the size of the
286receive buffer (and thus the window in sliding-window protocols like
287.Tn TCP ) .
288.It Xo
289.Vt "u_long rmx_sendpipe" ;
290.Xc
291As before, but in the opposite direction.
292.It Xo
293.Vt "u_long rmx_ssthresh" ;
294.Xc
295The slow-start threshold used in
296.Tn TCP
297congestion-avoidance.
298.It Xo
299.Vt "u_long rmx_rtt" ;
300.Xc
301The round-trip time to this destination, in units of
302.Dv RMX_RTTUNIT
303per second.
304.It Xo
305.Vt "u_long rmx_rttvar" ;
306.Xc
307The average deviation of the round-type time to this destination, in
308units of
309.Dv RMX_RTTUNIT
310per second.
311.It Xo
312.Vt "u_long rmx_pksent" ;
313.Xc
314A count of packets successfully sent via this route.
315.It Xo
316.Vt "u_long rmx_filler[4]" ;
317.Xc
318.\" XXX badly named
319Empty space available for protocol-specific information.
320.El
321.Sh SEE ALSO
322.Xr route 4 ,
323.Xr route 8 ,
324.Xr rtalloc 9
325.Sh HISTORY
326The
327.Nm
328structure first appeared in
329.Bx 4.2 .
330The radix-tree representation of the routing table and the
331.Nm rt_metrics
332structure first appeared in
333.Bx 4.3 reno .
334The
335.Nm RTF_PRCLONING
336mechanism first appeared in
337.Fx 2.0 .
338.Sh BUGS
339There are a number of historical relics remaining in this interface.
340The
341.Li rt_gateway
342and
343.Li rmx_filler
344fields could be named better.
345.Pp
346There is some disagreement over whether it is legitimate for
347.Dv RTF_LLINFO
348to be set by any process other than
349.Vt rt_ifa->ifa_rtrequest .
350.Sh AUTHORS
351This manual page was written by
352.An Garrett Wollman .
353