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