summaryrefslogtreecommitdiff
path: root/share/man/man9/route.9
blob: 42e879d22c35750bf650f3ba6a6bf94c49f7568e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
.\"     $OpenBSD: route.9,v 1.9 2014/03/18 09:01:11 mpi Exp $
.\"
.\" Copyright (c) 2011 Bret S. Lambert <blambert@openbsd.org>
.\" All rights reserved.
.\"
.\" Permission to use, copy, modify, and distribute this software for any
.\" purpose with or without fee is hereby granted, provided that the above
.\" copyright notice and this permission notice appear in all copies.
.\"
.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
.Dd $Mdocdate: March 18 2014 $
.Dt ROUTE 9
.Os
.Sh NAME
.Nm route
.Nd kernel routing interface
.Sh SYNOPSIS
.In net/route.h
.Ft struct rtentry *
.Fn rt_lookup "struct sockaddr *dst" "struct sockaddr *mask" "u_int tableid"
.Ft void
.Fn rtalloc "struct route *ro"
.Ft void
.Fn rtalloc_noclone "struct route *ro"
.Ft struct rtentry *
.Fn rtalloc1 "struct sockaddr *dst" "int flags" "u_int tableid"
.Ft void
.Fn rtfree "struct rtentry *rt"
.Fn RTFREE "struct rtentry *rt"
.Ft int
.Fn rtrequest1 "int req" "struct rt_addrinfo *info" "u_int8_t prio" \
"struct rtentry **ret_nrt" "u_int tableid"
.Ft int
.Fn rt_setgate "struct rtentry *rt0" "struct sockaddr *dst" \
"struct sockaddr *gate" "u_int tableid"
.Ft void
.Fn rtredirect "struct sockaddr *dst" "struct sockaddr *gateway" \
"struct sockaddr *netmask" "int flags" "struct sockaddr *src" \
"struct rtentry **rtp" "u_int rdomain"
.Ft int
.Fn rtdeletemsg "struct rtentry *rt" "u_int tableid"
.Bd -literal
struct rt_addrinfo {
	int	rti_addrs;
	struct	sockaddr *rti_info[RTAX_MAX];
	int	rti_flags;
	struct	ifaddr *rti_ifa;
	struct	ifnet *rti_ifp;
	struct	rt_msghdr *rti_rtm;
	u_char	rti_mpls;
};

#define RTAX_DST	0	/* destination sockaddr present */
#define RTAX_GATEWAY	1	/* gateway sockaddr present */
#define RTAX_NETMASK	2	/* netmask sockaddr present */
#define RTAX_IFP	4	/* interface name sockaddr present */
#define RTAX_IFA	5	/* interface addr sockaddr present */
#define RTAX_AUTHOR	6	/* sockaddr for author of redirect */
#define RTAX_BRD	7	/* for NEWADDR, broadcast or p-p dest */
#define RTAX_SRC	8	/* source sockaddr present */
#define RTAX_SRCMASK	9	/* source netmask present */
#define RTAX_LABEL	10	/* route label present */
#define RTAX_MAX	11	/* size of array to allocate */
.Ed
.Sh DESCRIPTION
Routing entries describe the routes to be taken by packets in a router.
.Bl -tag -width Ds
.It Fn rt_lookup "struct sockaddr *dst" "struct sockaddr *mask" "u_int tableid"
Return pointer to routing entry corresponding to address
.Fa dst
with a mask of
.Fa mask
from table
.Fa tableid .
.It Fn rtrequest1 "int req" "struct rt_addrinfo *info" "u_int8_t prio" \
"struct rtentry **ret_nrt" "u_int tableid"
Perform the action specified in
.Fa req
on table
.Fa tableid .
.Fa req
can be any of the following:
.Bl -tag -width "RTM_RESOLVEXXX" -offset indent
.It RTM_ADD
.\" XXX Describe adding an entry.
.It RTM_RESOLVE
.\" XXX Describe resolving an entry.
.It RTM_DELETE
.\" XXX Describe deleting an entry.
.El
.Pp
If
.Fa ret_nrt
is non-NULL, a pointer to the routing entry which satisfied the request is
placed there.
If
.Fa prio
is 0, a default priority based on the egress interface is used.
.It Fn rt_setgate "struct rtentry *rt0" "struct sockaddr *dst" \
"struct sockaddr *gate" "u_int tableid"
Set the address of the gateway for routes described by
.Fa rt0
to
.Fa gateway .
If memory must be allocated to hold the gateway address,
the address for which
.Fa rt0
describes routes will be copied from
.Fa dst .
.It Fn rtredirect "struct sockaddr *dst" "struct sockaddr *gateway" \
"struct sockaddr *netmask" "int flags" "struct sockaddr *src" \
"struct rtentry **rtp" "u_int rdomain"
Redirect routes to
.Fa dst
through
.Fa gateway ,
such as in response to an ICMP redirect message.
.Fa src
should be the address from which the redirect message was received.
If
.Fa rtp
is not NULL,
it will be populated by the routing entry corresponding to
.Fa dst .
.It Fn rtdeletemsg "struct rtentry *rt" "u_int tableid"
Delete routing table entry
.Fa rt
from table
.Fa tableid
and forward a notification message to all
.Fa AF_ROUTE
sockets.
.It Fn rtfree "struct rtentry *rt"
Release a reference to
.Fa rt ,
freeing it if the reference count drops to 0.
.It Fn RTFREE
A macro which calls
.Fn rtfree .
.El
.Sh RETURN VALUES
.Fn rtrequest1
may fail with:
.Pp
.Bl -tag -width Er -compact
.It Bq Er EAFNOSUPPORT
The protocol used by
.Fa info
is not supported in table with ID of
.Fa tableid .
.It Bq Er ESEARCH
No routing entry corresponding to
.Fa info
could be found.
.It Bq Er ESEARCH
Multipath route with no gateway provided in
.Fa info .
.It Bq Er ESEARCH
The routing entry could not be found in the routing table.
.It Bq Er EINVAL
.Fa req
specified
.Fa RTM_RESOLVE
with a
.Fa ret_nrt
argument which does not point to a cloneable routing entry.
.It Bq Er EEXIST
Multipath route conflicts with existing multipath route.
.It Bq Er EEXIST
The route could not be entered into the routing table.
.It Bq Er ENOMEM
Space for MPLS protocol data could not be allocated.
.It Bq Er ENOBUFS
Space for a new routing entry could not be allocated.
.It Bq Er ENETUNREACH
An interface address corresponding to the route described by
.Fa info
could not be found.
.El
.Pp
.Fn rt_setgate
returns non-0 if it cannot allocate memory.
.Pp
.Fn rtdeletemsg
may fail with:
.Pp
.Bl -tag -width Er -compact
.It Bq Er EAFNOSUPPORT
The protocol used by
.Fa rt
is not supported by table with ID
.Fa tableid .
.It Bq Er ESRCH
No routing entry for
.Fa rt
could be found.
.It Bq Er ESRCH
.Fa rt
is a multipath route that conflicts with existing multipath route.
.El
.Sh SEE ALSO
.Xr route 4 ,
.Xr route 8 ,
.Xr rt_timer_add 9 ,
.Xr rtable_add 9 ,
.Xr rtlabel_id2name 9
.Sh BUGS
The current route entry reference counting code, while not incorrect, is also
likely not correct either.