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