xref: /openbsd-src/share/man/man9/route.9 (revision 50b7afb2c2c0993b0894d4e34bf857cb13ed9c80)
1.\"     $OpenBSD: route.9,v 1.10 2014/04/02 13:10:48 mpi Exp $
2.\"
3.\" Copyright (c) 2011 Bret S. Lambert <blambert@openbsd.org>
4.\" All rights reserved.
5.\"
6.\" Permission to use, copy, modify, and distribute this software for any
7.\" purpose with or without fee is hereby granted, provided that the above
8.\" copyright notice and this permission notice appear in all copies.
9.\"
10.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17.\"
18.Dd $Mdocdate: April 2 2014 $
19.Dt ROUTE 9
20.Os
21.Sh NAME
22.Nm route
23.Nd kernel routing interface
24.Sh SYNOPSIS
25.In net/route.h
26.Ft struct rtentry *
27.Fn rt_lookup "struct sockaddr *dst" "struct sockaddr *mask" "u_int tableid"
28.Ft void
29.Fn rtalloc "struct route *ro"
30.Ft void
31.Fn rtalloc_noclone "struct route *ro"
32.Ft struct rtentry *
33.Fn rtalloc1 "struct sockaddr *dst" "int flags" "u_int tableid"
34.Ft void
35.Fn rtfree "struct rtentry *rt"
36.Fn RTFREE "struct rtentry *rt"
37.Ft int
38.Fn rt_setgate "struct rtentry *rt0" "struct sockaddr *dst" \
39"struct sockaddr *gate" "u_int tableid"
40.Ft void
41.Fn rtredirect "struct sockaddr *dst" "struct sockaddr *gateway" \
42"struct sockaddr *netmask" "int flags" "struct sockaddr *src" \
43"struct rtentry **rtp" "u_int rdomain"
44.Ft int
45.Fn rtdeletemsg "struct rtentry *rt" "u_int tableid"
46.Sh DESCRIPTION
47Routing entries describe the routes to be taken by packets in a router.
48.Bl -tag -width Ds
49.It Fn rt_lookup "struct sockaddr *dst" "struct sockaddr *mask" "u_int tableid"
50Return pointer to routing entry corresponding to address
51.Fa dst
52with a mask of
53.Fa mask
54from table
55.Fa tableid .
56.It Fn rt_setgate "struct rtentry *rt0" "struct sockaddr *dst" \
57"struct sockaddr *gate" "u_int tableid"
58Set the address of the gateway for routes described by
59.Fa rt0
60to
61.Fa gateway .
62If memory must be allocated to hold the gateway address,
63the address for which
64.Fa rt0
65describes routes will be copied from
66.Fa dst .
67.It Fn rtredirect "struct sockaddr *dst" "struct sockaddr *gateway" \
68"struct sockaddr *netmask" "int flags" "struct sockaddr *src" \
69"struct rtentry **rtp" "u_int rdomain"
70Redirect routes to
71.Fa dst
72through
73.Fa gateway ,
74such as in response to an ICMP redirect message.
75.Fa src
76should be the address from which the redirect message was received.
77If
78.Fa rtp
79is not NULL,
80it will be populated by the routing entry corresponding to
81.Fa dst .
82.It Fn rtdeletemsg "struct rtentry *rt" "u_int tableid"
83Delete routing table entry
84.Fa rt
85from table
86.Fa tableid
87and forward a notification message to all
88.Fa AF_ROUTE
89sockets.
90.It Fn rtfree "struct rtentry *rt"
91Release a reference to
92.Fa rt ,
93freeing it if the reference count drops to 0.
94.It Fn RTFREE
95A macro which calls
96.Fn rtfree .
97.El
98.Sh RETURN VALUES
99.Fn rt_setgate
100returns non-0 if it cannot allocate memory.
101.Pp
102.Fn rtdeletemsg
103may fail with:
104.Pp
105.Bl -tag -width Er -compact
106.It Bq Er EAFNOSUPPORT
107The protocol used by
108.Fa rt
109is not supported by table with ID
110.Fa tableid .
111.It Bq Er ESRCH
112No routing entry for
113.Fa rt
114could be found.
115.It Bq Er ESRCH
116.Fa rt
117is a multipath route that conflicts with existing multipath route.
118.El
119.Sh SEE ALSO
120.Xr route 4 ,
121.Xr route 8 ,
122.Xr rt_timer_add 9 ,
123.Xr rtable_add 9 ,
124.Xr rtlabel_id2name 9 ,
125.Xr rtrequest1 9
126