xref: /openbsd-src/share/man/man9/rtalloc.9 (revision 3f686ced6c71229260242b8419092671b6635b38)
1*3f686cedSmpi.\" $OpenBSD: rtalloc.9,v 1.12 2019/07/12 16:53:57 mpi Exp $
271d9dc5bSmpi.\"
30cc6bee5Smpi.\" Copyright (c) 2014-2015 Martin Pieuchot
471d9dc5bSmpi.\"
571d9dc5bSmpi.\" Permission to use, copy, modify, and distribute this software for any
671d9dc5bSmpi.\" purpose with or without fee is hereby granted, provided that the above
771d9dc5bSmpi.\" copyright notice and this permission notice appear in all copies.
871d9dc5bSmpi.\"
971d9dc5bSmpi.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1071d9dc5bSmpi.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1171d9dc5bSmpi.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1271d9dc5bSmpi.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1371d9dc5bSmpi.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1471d9dc5bSmpi.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1571d9dc5bSmpi.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1671d9dc5bSmpi.\"
17*3f686cedSmpi.Dd $Mdocdate: July 12 2019 $
1871d9dc5bSmpi.Dt RTALLOC 9
1971d9dc5bSmpi.Os
2071d9dc5bSmpi.Sh NAME
2132956d1bSschwarze.Nm rtalloc ,
2232956d1bSschwarze.Nm rtalloc_mpath ,
230cc6bee5Smpi.Nm rtisvalid ,
24a32c8259Sjmc.Nm rtref ,
2532956d1bSschwarze.Nm rtfree
26b77d0811Sjmc.Nd routing entry interface
2771d9dc5bSmpi.Sh SYNOPSIS
2871d9dc5bSmpi.In sys/types.h
2971d9dc5bSmpi.In sys/socket.h
3071d9dc5bSmpi.In net/route.h
3171d9dc5bSmpi.Ft struct rtentry *
3271d9dc5bSmpi.Fn rtalloc "struct sockaddr *dst" "int flags" "unsigned int rtableid"
3371d9dc5bSmpi.Ft struct rtentry *
3471d9dc5bSmpi.Fn rtalloc_mpath "struct sockaddr *dst" "uint32_t *src" "unsigned int rtableid"
350cc6bee5Smpi.Ft int
360cc6bee5Smpi.Fn rtisvalid "struct rtentry *rt"
3771d9dc5bSmpi.Ft void
38ab21d605Smpi.Fn rtref "struct rtentry *rt"
39ab21d605Smpi.Ft void
4071d9dc5bSmpi.Fn rtfree "struct rtentry *rt"
4171d9dc5bSmpi.Sh DESCRIPTION
4271d9dc5bSmpiThe
4371d9dc5bSmpi.Fn rtalloc
44b77d0811Sjmcfunction looks in the routing table
4571d9dc5bSmpi.Fa rtableid
4671d9dc5bSmpifor an entry matching
4771d9dc5bSmpi.Fa dst .
4871d9dc5bSmpiThe following
4971d9dc5bSmpi.Fa flags
5071d9dc5bSmpican be specified:
5171d9dc5bSmpi.Bl -tag -width RT_RESOLVE -offset indent
5271d9dc5bSmpi.It Dv RT_RESOLVE
5371d9dc5bSmpiAllocate and return a cloned entry for
5471d9dc5bSmpi.Fa dst
5571d9dc5bSmpiif it does not exist and the lookup returned a cloning entry.
5671d9dc5bSmpi.El
5771d9dc5bSmpi.Pp
5871d9dc5bSmpiThe
5971d9dc5bSmpi.Fn rtalloc_mpath
6071d9dc5bSmpifunction does the same as
6171d9dc5bSmpi.Fn rtalloc
6271d9dc5bSmpiwith the
6371d9dc5bSmpi.Dv RT_RESOLVE
64e191f1c3Sjmc.Fa flag ,
6571d9dc5bSmpibut selects a multipath routing entry corresponding to
6671d9dc5bSmpi.Fa src
6771d9dc5bSmpiwhen possible.
6871d9dc5bSmpi.Pp
6971d9dc5bSmpiThe
700cc6bee5Smpi.Fn rtisvalid
710cc6bee5Smpifunction checks if the route entry
720cc6bee5Smpi.Fa rt
730cc6bee5Smpiis still valid and can be used.
740cc6bee5SmpiCached entries that are no longer valid should be released by calling
750cc6bee5Smpi.Fn rtfree .
760cc6bee5Smpi.Pp
770cc6bee5SmpiThe
78ab21d605Smpi.Fn rtref
79ab21d605Smpifunction increments a reference to the routing entry
80ab21d605Smpi.Fa rt .
81ab21d605Smpi.Pp
82ab21d605SmpiThe
8371d9dc5bSmpi.Fn rtfree
8471d9dc5bSmpifunction releases a reference to the routing entry
8571d9dc5bSmpi.Fa rt ,
8671d9dc5bSmpifreeing it if the reference count drops to 0.
878e659bc7SmpiIf
888e659bc7Smpi.Fa rt
898e659bc7Smpiis a
908e659bc7Smpi.Dv NULL
918e659bc7Smpipointer, no action occurs.
9271d9dc5bSmpi.Sh CONTEXT
9371d9dc5bSmpi.Fn rtalloc ,
9471d9dc5bSmpi.Fn rtalloc_mpath ,
950cc6bee5Smpi.Fn rtisvalid ,
96ab21d605Smpi.Fn rtref ,
9771d9dc5bSmpiand
9871d9dc5bSmpi.Fn rtfree
9971d9dc5bSmpican be called during autoconf, from process context, or from interrupt context.
1000cc6bee5Smpi.Sh RETURN VALUES
1010cc6bee5Smpi.Fn rtisvalid
1020cc6bee5Smpireturns 1 if the route entry is valid, otherwise 0.
10371d9dc5bSmpi.Sh SEE ALSO
10471d9dc5bSmpi.Xr route 4 ,
105*3f686cedSmpi.Xr rtable_walk 9 ,
1069ab903caSbluhm.Xr rtrequest 9
107