.\" $OpenBSD: rtalloc.9,v 1.11 2015/12/02 14:13:14 jmc 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: December 2 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_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_RESOLVE .Fa flag , 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