2 .\" Copyright 1996 Massachusetts Institute of Technology
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
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
38 .Nd look up a route in the kernel routing table
44 .Fn rtalloc "struct route *ro"
46 .Fn rtalloc_ign "struct route *ro" "u_long flags"
47 .Ft "struct rtentry *"
48 .Fn rtalloc1 "struct sockaddr *sa" "int report" "u_long flags"
50 .Fn rtfree "struct rt_entry *rt"
51 .Fn RTFREE "struct rt_entry *rt"
52 .Fn RT_LOCK "struct rt_entry *rt"
53 .Fn RT_UNLOCK "struct rt_entry *rt"
54 .Fn RT_ADDREF "struct rt_entry *rt"
55 .Fn RT_REMREF "struct rt_entry *rt"
57 The kernel uses a radix tree structure to manage routes for the
61 family of routines is used by protocols to query this structure for a
62 route corresponding to a particular end-node address, and to cause
63 certain protocol\- and interface-specific actions to take place.
64 .\" XXX - -mdoc should contain a standard request for getting em and
67 When a route with the flag
69 is retrieved, and the action of this flag is not masked, the
71 facility automatically generates a new route using information in the
72 old route as a template, and
75 message to the appropriate interface-address route-management routine
76 .Pq Fn ifa->ifa_rtrequest .
77 This generated route is called
83 flag is obsolete and thus ignored by facility.
88 message is sent instead on the
90 socket interface, requesting that an external program resolve the
91 address in question and modify the route appropriately.
93 The default interface is
98 .Dq Li "struct route" ,
99 which is defined as follows:
100 .Bd -literal -offset indent
102 struct sockaddr ro_dst;
103 struct rtentry *ro_rt;
107 Thus, this function can only be used for address families which are
108 smaller than the default
109 .Dq Li "struct sockaddr" .
112 for the first time, callers should ensure that unused bits of the
113 structure are set to zero.
116 returns without performing a lookup if
120 flag is set in the route's
126 interface can be used when the default actions of
128 in the presence of the
133 argument is the same as
135 but there is additionally a
137 argument, which lists the flags in the route which are to be
139 (in most cases this is
146 functions return a pointer to an unlocked
147 .Vt "struct rtentry" .
151 function is the most general form of
153 (and both of the other forms are implemented as calls to rtalloc1).
155 .Dq Li "struct route" ,
156 and is therefore suitable for address families which require more
157 space than is in a traditional
158 .Dq Li "struct sockaddr" .
160 .Dq Li "struct sockaddr *"
168 requests are sent to the lower layers when an
173 Ordinarily a value of one should be passed, except
174 in the processing of those lower layers which use the cloning
178 is a set of flags to ignore, as in
182 function returns a pointer to a locked
183 .Vt "struct rtentry" .
187 function frees a locked route entry, e.g., a previously allocated by
192 macro is used to free unlocked route entries, previously allocated by
198 macro decrements the reference count on the routing table entry (see below),
199 and frees it if the reference count has reached zero.
201 The preferred usage is allocating a route using
210 macro is used to lock a routing table entry.
213 macro is used to unlock a routing table entry.
217 macro increments the reference count on a previously locked route entry.
220 macro decrements the reference count on a previously locked route entry.
227 functions do not return a value.
230 function returns a pointer to a routing-table entry if it succeeds,
231 otherwise a null pointer.
232 Lack of a route should in most cases be
243 facility first appeared in
245 although with much different internals.
254 Routing table locking was introduced in
257 This manual page was written by
258 .An Garrett Wollman ,
259 as were the changes to implement