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
|
.\" $OpenBSD: rtalloc.9,v 1.9 2015/10/30 09:48:03 bluhm Exp $
.\"
.\" Copyright (c) 2014-2015 Martin Pieuchot
.\"
.\" 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: October 30 2015 $
.Dt RTALLOC 9
.Os
.Sh NAME
.Nm rtalloc ,
.Nm rtalloc_mpath ,
.Nm rtisvalid ,
.Nm rtref ,
.Nm rtfree
.Nd routing entry interface
.Sh SYNOPSIS
.In sys/types.h
.In sys/socket.h
.In net/route.h
.Ft struct rtentry *
.Fn rtalloc "struct sockaddr *dst" "int flags" "unsigned int rtableid"
.Ft struct rtentry *
.Fn rtalloc_mpath "struct sockaddr *dst" "uint32_t *src" "unsigned int rtableid"
.Ft int
.Fn rtisvalid "struct rtentry *rt"
.Ft void
.Fn rtref "struct rtentry *rt"
.Ft void
.Fn rtfree "struct rtentry *rt"
.Sh DESCRIPTION
The
.Fn rtalloc
function looks in the routing table
.Fa rtableid
for an entry matching
.Fa dst .
The following
.Fa flags
can be specified:
.Bl -tag -width RT_RESOLVE -offset indent
.It Dv RT_REPORT
Notify the routing sockets if the lookup fails.
.It Dv RT_RESOLVE
Allocate and return a cloned entry for
.Fa dst
if it does not exist and the lookup returned a cloning entry.
.El
.Pp
The
.Fn rtalloc_mpath
function does the same as
.Fn rtalloc
with the
.Dv RT_REPORT
and
.Dv RT_RESOLVE
.Fa flags ,
but selects a multipath routing entry corresponding to
.Fa src
when possible.
.Pp
The
.Fn rtisvalid
function checks if the route entry
.Fa rt
is still valid and can be used.
Cached entries that are no longer valid should be released by calling
.Fn rtfree .
.Pp
The
.Fn rtref
function increments a reference to the routing entry
.Fa rt .
.Pp
The
.Fn rtfree
function releases a reference to the routing entry
.Fa rt ,
freeing it if the reference count drops to 0.
If
.Fa rt
is a
.Dv NULL
pointer, no action occurs.
.Sh CONTEXT
.Fn rtalloc ,
.Fn rtalloc_mpath ,
.Fn rtisvalid ,
.Fn rtref ,
and
.Fn rtfree
can be called during autoconf, from process context, or from interrupt context.
.Sh RETURN VALUES
.Fn rtisvalid
returns 1 if the route entry is valid, otherwise 0.
.Sh SEE ALSO
.Xr route 4 ,
.Xr rtrequest 9
|