1502 Remove conversion cruft from manpages
[unleashed.git] / usr / src / man / man7p / route.7p
blob0209e580ad4d6fc6cb435824c80f077052171e07
1 '\" te
2 .\" Copyright (c) 1990, 1991, 1993 The Regents of the University of California. All rights reserved.
3 .\" Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
4 .\" 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. All advertising materials mentioning features or use of this software must display
5 .\" the following acknowledgement: This product includes software developed by the University of California, Berkeley and its contributors. 4. Neither the name of the University nor the names of its contributors may be used to endorse or promote products derived from this software without
6 .\" specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS
7 .\" OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
8 .\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9 .\" Portions Copyright (c) 2009, Sun Microsystems, Inc. All Rights Reserved.
10 .TH ROUTE 7P "Feb 5, 2009"
11 .SH NAME
12 route \- kernel packet forwarding database
13 .SH SYNOPSIS
14 .LP
15 .nf
16 #include <sys/types.h>
17 #include <sys/socket.h>
18 #include <net/if.h>
19 #include <net/route.h>
21 \fBint\fR \fBsocket\fR(\fB\fR\fIPF_ROUTE\fR, \fB\fR\fISOCK_RAW\fR, \fBint\fR \fIprotocol\fR);
22 .fi
24 .SH DESCRIPTION
25 .sp
26 .LP
27 UNIX provides some packet routing facilities. The kernel maintains a routing
28 information database, which is used in selecting the appropriate network
29 interface when transmitting packets.
30 .sp
31 .LP
32 A user process (or possibly multiple co-operating processes) maintains this
33 database by sending messages over a special kind of socket. This supplants
34 fixed size \fBioctl\fR(2)'s specified in \fBrouting\fR(7P). Routing table
35 changes can only be carried out by the superuser.
36 .sp
37 .LP
38 The operating system might spontaneously emit routing messages in response to
39 external events, such as receipt of a re-direct, or failure to locate a
40 suitable route for a request. The message types are described in greater detail
41 below.
42 .sp
43 .LP
44 Routing database entries come in two flavors: entries for a specific host, or
45 entries for all hosts on a generic subnetwork (as specified by a bit mask and
46 value under the mask). The effect of wildcard or default route can be achieved
47 by using a mask of all zeros, and there can be hierarchical routes.
48 .sp
49 .LP
50 When the system is booted and addresses are assigned to the network interfaces,
51 the internet protocol family installs a routing table entry for each interface
52 when it is ready for traffic. Normally the protocol specifies the route through
53 each interface as a \fIdirect\fR connection to the destination host or network.
54 If the route is direct, the transport layer of a protocol family usually
55 requests the packet be sent to the same host specified in the packet.
56 Otherwise, the interface is requested to address the packet to the gateway
57 listed in the routing entry, that is, the packet is forwarded.
58 .sp
59 .LP
60 When routing a packet, the kernel attempts to find the most specific route
61 matching the destination. If no entry is found, the destination is declared to
62 be unreachable, and a routing-miss message is generated if there are any
63 listeners on the routing control socket (described below). If there are two
64 different mask and value-under-the-mask pairs that match, the more specific is
65 the one with more bits in the mask. A route to a host is regarded as being
66 supplied with a mask of as many ones as there are bits in the destination.
67 .sp
68 .LP
69 A wildcard routing entry is specified with a zero destination address value,
70 and a mask of all zeroes. Wildcard routes are used when the system fails to
71 find other routes matching the destination. The combination of wildcard routes
72 and routing redirects can provide an economical mechanism for routing traffic.
73 .sp
74 .LP
75 One opens the channel for passing routing control messages by using the socket
76 call. There can be more than one routing socket open per system.
77 .sp
78 .LP
79 Messages are formed by a header followed by a small number of \fBsockaddrs\fR,
80 whose length depend on the address family. \fBsockaddrs\fR are interpreted by
81 position. An example of a type of message with three addresses might be a
82 \fBCIDR\fR prefix route: Destination, Netmask, and Gateway. The interpretation
83 of which addresses are present is given by a bit mask within the header, and
84 the sequence is least significant to most significant bit within the vector.
85 .sp
86 .LP
87 Any messages sent to the kernel are returned, and copies are sent to all
88 interested listeners. The kernel provides the process \fBID\fR of the sender,
89 and the sender can use an additional sequence field to distinguish between
90 outstanding messages. However, message replies can be lost when kernel buffers
91 are exhausted.
92 .sp
93 .LP
94 The \fIprotocol\fR parameter specifies which messages an application listening
95 on the routing socket is interested in seeing, based on the the address family
96 of the \fBsockaddrs\fR present. Currently, you can specify \fBAF_INET\fR and
97 \fBAF_INET6\fR to filter the messages seen by the listener, or alternatively,
98 you can specify \fBAF_UNSPEC\fR to indicate that the listener is interested in
99 all routing messages.
102 The kernel might reject certain messages, and indicates this by filling in the
103 \fBrtm_errno\fR field of the \fBrt_msghdr\fR struct (see below). The following
104 codes are returned:
106 .ne 2
108 \fB\fBEEXIST\fR\fR
110 .RS 11n
111 If requested to duplicate an existing entry
115 .ne 2
117 \fB\fBESRCH\fR\fR
119 .RS 11n
120 If requested to delete a non-existent entry
124 .ne 2
126 \fB\fBENOBUFS\fR\fR
128 .RS 11n
129 If insufficient resources were available to install a new route.
133 .ne 2
135 \fB\fBEPERM\fR\fR
137 .RS 11n
138 If the calling process does not have appropriate privileges to alter the
139 routing table.
144 In the current implementation, all routing processes run locally, and the
145 values for \fBrtm_errno\fR are available through the normal \fBerrno\fR
146 mechanism, even if the routing reply message is lost.
149 A process can avoid the expense of reading replies to its own messages by
150 issuing a \fBsetsockopt\fR(3SOCKET) call indicating that the
151 \fBSO_USELOOPBACK\fR option at the \fBSOL_SOCKET\fR level is to be turned off.
152 A process can ignore all messages from the routing socket by doing a
153 \fBshutdown\fR(3SOCKET) system call for further input.
156 By default, underlying IP interfaces in an IPMP group are not visible to
157 routing sockets. As such, routing sockets do not receive events related to
158 underlying IP interface in an IPMP group. For consistency, when an IP interface
159 is placed into an IPMP group, \fBRTM_DELADDR\fR messages are generated for each
160 \fBIFF_UP\fR address that is not migrated to the corresponding IPMP IP
161 interface and an \fBRTM_IFINFO\fR message is sent indicating the interface is
162 down. Similarly, when an underlying interface is removed from an IPMP group, an
163 \fBRTM_IFINFO\fR message is sent indicating the interface is again up and
164 \fBRTM_NEWADDR\fR messages are generated for each \fBIFF_UP\fR address found on
165 the interface.
168 The \fBRT_AWARE\fR socket option at the \fBSOL_ROUTE\fR level allows an
169 application to indicate its awareness of certain features, which control
170 routing socket behavior. The supported values are:
172 .ne 2
174 \fB\fBRTAW_DEFAULT\fR\fR
176 .RS 20n
177 Default awareness.
181 .ne 2
183 \fB\fBRTAW_UNDER_IPMP\fR\fR
185 .RS 20n
186 IPMP underlying interface awareness. When enabled, underlying IP interfaces in
187 an IPMP group remain visible to the routing socket and events related to them
188 continue to be generated.
193 An \fBRTM_ADD\fR request tied to an underlying IP interface in an IPMP group is
194 translated to an \fBRTM_ADD\fR request for its corresponding IPMP IP interface.
195 All routing socket requests other than \fBRTM_ADD\fR and \fBRTM_GET\fR  fail
196 when issued on an underlying IP interface in an IPMP group.
199 If a route is in use when it is deleted, the routing entry is marked down and
200 removed from the routing table, but the resources associated with it are not
201 reclaimed until all references to it are released.
204 The \fBRTM_IFINFO\fR, \fBRTM_NEWADDR\fR, and \fBRTM_ADD\fR messages associated
205 with interface configuration (setting the \fBIFF_UP\fR bit) are normally
206 delayed until after Duplicate Address Detection completes. Thus, applications
207 that configure interfaces and wish to wait until the interface is ready can
208 wait until \fBRTM_IFINFO\fR is returned and \fBSIOCGLIFFLAGS\fR shows that
209 \fBIFF_DUPLICATE\fR is not set.
210 .SS "Messages"
213 User processes can obtain information about the routing entry to a specific
214 destination by using a \fBRTM_GET\fR message.
217 Messages include:
219 .in +2
221 #define RTM_ADD      0x1   /* Add Route */
222 #define RTM_DELETE   0x2   /* Delete Route */
223 #define RTM_CHANGE   0x3   /* Change Metrics, Flags, or Gateway */
224 #define RTM_GET      0x4   /* Report Information */
225 #define RTM_LOSING   0x5   /* Kernel Suspects Partitioning */
226 #define RTM_REDIRECT 0x6   /* Told to use different route */
227 #define RTM_MISS     0x7   /* Lookup failed on this address */
228 #define RTM_LOCK     0x8   /* fix specified metrics */
229 #define RTM_OLDADD   0x9   /* caused by SIOCADDRT */
230 #define RTM_OLDDEL   0xa   /* caused by SIOCDELRT */
231 #define RTM_RESOLVE  0xb   /* request to resolve dst to LL addr */
232 #define RTM_NEWADDR  0xc   /* address being added to iface */
233 #define RTM_DELADDR  0xd   /* address being removed from iface */
234 #define RTM_IFINFO   0xe   /* iface going up/down etc. */
236 .in -2
240 A message header consists of:
242 .in +2
244 struct rt_msghdr {
245   ushort_t rtm_msglen;    /* to skip over non-understood messages */
246   uchar_t  rtm_version;   /* future binary compatibility */
247   uchar_t  rtm_type;      /* message type */
248   ushort_t rtm_index;     /* index for associated ifp */
249   pid_t   rtm_pid;        /* identify sender */
250   int     rtm_addrs;      /* bitmask identifying sockaddrs in msg */
251   int     rtm_seq;        /* for sender to identify action */
252   int     rtm_errno;      /* why failed */
253   int     rtm_flags;      /*  flags,  incl  kern  &  message, e.g., DONE */
254   int     rtm_use;        /* from rtentry */
255   uint_t  rtm_inits;      /* which values we are initializing */
257 struct  rt_metrics rtm_rmx;   /* metrics themselves */
258      };
260 .in -2
264 where
266 .in +2
268 struct rt_metrics {
269   uint32_t rmx_locks;      /* Kernel must leave  these  values alone */
270   uint32_t rmx_mtu;        /* MTU for this path */
271   uint32_t rmx_hopcount;   /* max hops expected */
272   uint32_t rmx_expire;     /* lifetime for route, e.g., redirect */
273   uint32_t rmx_recvpipe;   /* inbound delay-bandwidth  product */
274   uint32_t rmx_sendpipe;   /* outbound delay-bandwidth product */
275   uint32_t rmx_ssthresh;   /* outbound gateway buffer limit */
276   uint32_t rmx_rtt;        /* estimated round trip time */
277   uint32_t rmx_rttvar;     /* estimated rtt variance */
278   uint32_t rmx_pksent;     /* packets sent using this route */
279  };
281 /* Flags include the values */
284 #define RTF_UP         0x1     /* route usable */
285 #define RTF_GATEWAY    0x2     /* destination is a gateway */
286 #define RTF_HOST       0x4     /* host entry (net otherwise) */
287 #define RTF_REJECT     0x8     /* host or net unreachable */
288 #define RTF_DYNAMIC    0x10    /* created dynamically(by redirect) */
289 #define RTF_MODIFIED   0x20    /* modified dynamically(by redirect) */
290 #define RTF_DONE       0x40    /* message confirmed */
291 #define RTF_MASK       0x80    /* subnet mask present */
292 #define RTF_CLONING    0x100   /* generate new routes on use */
293 #define RTF_XRESOLVE   0x200   /* external daemon resolves name */
294 #define RTF_LLINFO     0x400   /* generated by ARP */
295 #define RTF_STATIC     0x800   /* manually added */
296 #define RTF_BLACKHOLE  0x1000  /* just discard pkts (during updates) */
297 #define RTF_PRIVATE    0x2000  /* do not advertise this route */
298 #define RTF_PROTO2     0x4000  /* protocol specific routing flag #2 */
299 #define RTF_PROTO1     0x8000  /* protocol specific routing flag #1 */
301 /* Specifiers for metric values in rmx_locks and rtm_inits are */
303 #define RTV_MTU        0x1     /* init or lock _mtu */
304 #define RTV_HOPCOUNT   0x2     /* init or lock _hopcount */
305 #define RTV_EXPIRE     0x4     /* init or lock _expire */
306 #define RTV_RPIPE      0x8     /* init or lock _recvpipe */
307 #define RTV_SPIPE      0x10    /* init or lock _sendpipe */
308 #define RTV_SSTHRESH   0x20    /* init or lock _ssthresh */
309 #define RTV_RTT        0x40    /* init or lock _rtt */
310 #define RTV_RTTVAR     0x80    /* init or lock _rttvar */
312 /* Specifiers for which addresses are present in  the  messages are */
314 #define RTA_DST        0x1     /* destination sockaddr present */
315 #define RTA_GATEWAY    0x2     /* gateway sockaddr present */
316 #define RTA_NETMASK    0x4     /* netmask sockaddr present */
317 #define RTA_GENMASK    0x8     /* cloning mask sockaddr present */
318 #define RTA_IFP        0x10    /* interface name sockaddr present */
319 #define RTA_IFA        0x20    /* interface addr sockaddr present */
320 #define RTA_AUTHOR     0x40    /* sockaddr for author of redirect */
321 #define RTA_BRD        0x80    /* for NEWADDR, broadcast or p-p dest addr */
323 .in -2
325 .SH SEE ALSO
328 \fBioctl\fR(2), \fBsetsockopt\fR(3SOCKET), \fBshutdown\fR(3SOCKET),
329 \fBrouting\fR(7P)
330 .SH NOTES
333 Some of the metrics might not be implemented and return zero. The implemented
334 metrics are set in \fBrtm_inits\fR.