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