RTALLOC(9)

NAME
rtalloc, rtalloc_mpath, rtisvalid, rtref, rtfree - routing entry interface

SYNOPSIS
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
struct rtentry *
rtalloc(struct sockaddr *dst, int flags, unsigned int rtableid);
struct rtentry *
rtalloc_mpath(struct sockaddr *dst, uint32_t *src, unsigned int rtableid);
int
rtisvalid(struct rtentry *rt);
void
rtref(struct rtentry *rt);
void
rtfree(struct rtentry *rt);

DESCRIPTION
The rtalloc() function looks in the routing table rtableid for an entry matching dst. The following flags can be specified:

RT_RESOLVE
    Allocate and return a cloned entry for dst if it does not exist and the lookup returned a cloning entry.

The rtalloc_mpath() function does the same as rtalloc() with the RT_RESOLVE flag, but selects a multipath routing entry corresponding to src when possible.

The rtisvalid() function checks if the route entry rt is still valid and can be used. Cached entries that are no longer valid should be released by calling rtfree().

The rtref() function increments a reference to the routing entry rt.

The rtfree() function releases a reference to the routing entry rt, freeing it if the reference count drops to 0. If rt is a NULL pointer, no action occurs.

CONTEXT
rtalloc(), rtalloc_mpath(), rtisvalid(), rtref(), and rtfree() can be called during autoconf, from process context, or from interrupt context.

RETURN VALUES
rtisvalid() returns 1 if the route entry is valid, otherwise 0.

SEE ALSO
route(4), rtable_walk(9), rtrequest(9)