RT_UNLOCK (9)
Leading comments
Copyright 1996 Massachusetts Institute of Technology Permission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that both the above copyright notice and this permission notice appear in all copies, that both the above copyright notice and this permission notice appear in all supporting documentation, and that the name of M.I.T. not be used in advertising or publicity pertaining to distribution of the softwar...
NAME
rtalloc1_fib rtalloc_ign_fib rtalloc_fib - look up a route in the kernel routing tableSYNOPSIS
In sys/types.h In sys/socket.h In net/route.h Ft struct rtentry * Fn rtalloc1_fib struct sockaddr *dst int report u_long flags u_int fibnum Ft void Fn rtalloc_fib struct route *ro u_int fibnum Ft void Fn rtalloc_ign_fib struct route *ro u_long flags u_int fibnum Fn RTFREE_LOCKED struct rt_entry *rt Fn RTFREE struct rt_entry *rt Fn RT_LOCK struct rt_entry *rt Fn RT_UNLOCK struct rt_entry *rt Fn RT_ADDREF struct rt_entry *rt Fn RT_REMREF struct rt_entry *rt Fn RO_RTFREE struct route *ro Ft void Fn rtfree struct rt_entry *rt Ft struct rtentry * Fn rtalloc1 struct sockaddr *dst int report u_long flags Ft void Fn rtalloc struct route *ro Ft void Fn rtalloc_ign struct route *ro u_long flagsoptions RADIX_MPATH
DESCRIPTION
The kernel uses a radix tree structure to manage routes for the networking subsystem. If compiled with options RADIX_MPATH kernel may maintain several independent forwarding information databases (FIBs). The Fn rtalloc family of routines is used by protocols to query these structures for a route corresponding to a particular end-node address, and to cause certain protocol- and interface-specific actions to take place.The Fn rtalloc1_fib function is the most general form of Fn rtalloc , and all of the other forms are implemented as calls to it. It takes a Fa struct sockaddr * directly as the Fa dst argument. The second argument, Fa report , controls whether the routing sockets are notified when a lookup fails. The third argument, Fa flags , is a combination of the following values:
- RTF_RNH_LOCKED
- indicates that the radix tree lock is already held
The last argument Fa fibnum specifies number of forwarding information database (FIB) on which the lookup should be performed. In case of success the Fn rtalloc1_fib function returns a pointer to a locked Vt struct rtentry with an additional reference.
The Fn rtalloc_fib is the most simple variant. Its main argument is Fa ro , a pointer to a Fa 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 Ft struct sockaddr . Before calling Fn rtalloc_fib for the first time, callers should ensure that unused bits of the structure are set to zero. The second argument Fa fibnum is FIB number. In case of success of the Fn rtalloc_fib the Fa 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, Fn rtalloc_fib returns without performing a lookup if Fa ro->ro_rt is non-null and the RTF_UP flag is set in the rtentry's Fa rt_flags field.
The Fn rtalloc_ign_fib function is the same as the Fn rtalloc_fib , but there is additional Fa flags argument, which is same as in Fn rtalloc1_fib .
The Fn RTFREE_LOCKED macro is used to unref and possibly free a locked routing entry with one our reference, for example previously allocated by Fn rtalloc1_fib .
The Fn RTFREE macro is used to unref and possibly free an unlocked route entries with one our reference, for example previously allocated by Fn rtalloc_fib or Fn rtalloc_ign_fib .
Both Fn RTFREE_LOCKED and Fn RTFREE macros decrement the reference count on the routing table entry, and proceed with actual freeing if the reference count has reached zero.
The Fn RT_LOCK macro is used to lock a routing table entry.
The Fn RT_UNLOCK macro is used to unlock a routing table entry.
The Fn 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 Fn RT_REMREF macro decrements the reference count on a previously locked route entry. Its usage is contrary to Fn RT_ADDREF .
The Fn 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 Fn RO_RTFREE treats such routes correctly.
The Fn 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.