Main index | Section 9 | Options |
#include <sys/types.h>
#include <sys/socket.h>
#include <net/route.h>
options RADIX_MPATH
The rtalloc1_fib() function is the most general form of rtalloc(), and all of the other forms are implemented as calls to it. It takes a struct sockaddr * directly as the dst argument. The second argument, report, controls whether the routing sockets are notified when a lookup fails. The third argument, flags, is a combination of the following values:
RTF_RNH_LOCKED indicates that the radix tree lock is already held | |
The last argument fibnum specifies number of forwarding information database (FIB) on which the lookup should be performed. In case of success the rtalloc1_fib() function returns a pointer to a locked struct rtentry with an additional reference.
The rtalloc_fib() is the most simple variant. Its main argument is ro, a pointer to a struct route, which is defined as follows:
struct route { struct rtentry *ro_rt; struct llentry *ro_lle; struct sockaddr ro_dst; };
Thus, this function can only be used for address families which are smaller than the default struct sockaddr. Before calling rtalloc_fib() for the first time, callers should ensure that unused bits of the structure are set to zero. The second argument fibnum is FIB number. In case of success of the rtalloc_fib() the ro_rt points to a valid and unlocked rtentry(9), which has an additional reference put on it, freeing which is responsibility of the caller. On subsequent calls, rtalloc_fib() returns without performing a lookup if ro->ro_rt is non-null and the RTF_UP flag is set in the rtentry's rt_flags field.
The rtalloc_ign_fib() function is the same as the rtalloc_fib(), but there is additional flags argument, which is same as in rtalloc1_fib().
The RTFREE_LOCKED() macro is used to unref and possibly free a locked routing entry with one our reference, for example previously allocated by rtalloc1_fib().
The RTFREE() macro is used to unref and possibly free an unlocked route entries with one our reference, for example previously allocated by rtalloc_fib() or rtalloc_ign_fib().
Both RTFREE_LOCKED() and RTFREE() macros decrement the reference count on the routing table entry, and proceed with actual freeing if the reference count has reached zero.
The RT_LOCK() macro is used to lock a routing table entry.
The RT_UNLOCK() macro is used to unlock a routing table entry.
The RT_ADDREF() macro increments the reference count on a previously locked route entry. It should be used whenever a reference to an rtentry(9) is going to be stored outside the routing table.
The RT_REMREF() macro decrements the reference count on a previously locked route entry. Its usage is contrary to RT_ADDREF().
The RO_RTFREE() macro is used to free route entry that is referenced by struct route. At certain circumstances the latter may not hold a reference on rtentry, and RO_RTFREE() treats such routes correctly.
The rtfree() function does the actual free of the routing table entry, and shouldn't be called directly by facilities, that just perform routing table lookups.
RTALLOC (9) | July 4, 2012 |
Main index | Section 9 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
“ | Unix...best if used before: Tue Jan 19 03:14:08 GMT 2038 | ” |