rtalloc1.9freebsd

Langue: en

Autres versions - même langue

Version: 365476 (ubuntu - 25/10/10)

Section: 9 (Appels noyau Linux)


BSD mandoc

NAME

rtalloc rtalloc_ign rtalloc1 rtfree - look up a route in the kernel routing table

SYNOPSIS

In sys/types.h In sys/socket.h In net/route.h Ft void Fn rtalloc struct route *ro Ft void Fn rtalloc_ign struct route *ro u_long flags Ft struct rtentry * Fn rtalloc1 struct sockaddr *sa int report u_long flags Ft void Fn rtfree 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

DESCRIPTION

The kernel uses a radix tree structure to manage routes for the networking subsystem. The Fn rtalloc family of routines is used by protocols to query this structure for a route corresponding to a particular end-node address, and to cause certain protocol- and interface-specific actions to take place.

RTF_PRCLONING flag is obsolete and thus ignored by facility. If the RTF_XRESOLVE flag is set, then the RTM_RESOLVE message is sent instead on the route(4) socket interface, requesting that an external program resolve the address in question and modify the route appropriately.

The default interface is Fn rtalloc . Its only argument is Fa ro , a pointer to a ``struct route '' which is defined as follows:

 struct route {
         struct sockaddr ro_dst;
         struct rtentry *ro_rt;
 };
 

Thus, this function can only be used for address families which are smaller than the default ``struct sockaddr '' Before calling Fn rtalloc for the first time, callers should ensure that unused bits of the structure are set to zero. On subsequent calls, Fn rtalloc returns without performing a lookup if Fa ro->ro_rt is non-null and the RTF_UP flag is set in the route's rt_flags field.

The Fn rtalloc_ign interface can be used when the caller does not want to receive the returned Fa rtentry locked. The Fa ro argument is the same as Fn rtalloc , but there is additionally a Fa flags argument, which is now only used to pass RTF_RNH_LOCKED indicating that the radix tree lock is already held. Both Fn rtalloc and Fn rtalloc_ign functions return a pointer to an unlocked Vt struct rtentry .

The Fn rtalloc1 function is the most general form of Fn rtalloc (and both of the other forms are implemented as calls to rtalloc1). It does not use the ``struct route '' and is therefore suitable for address families which require more space than is in a traditional ``struct sockaddr '' Instead, it takes a ``struct sockaddr * '' directly as the Fa sa argument. The second argument, Fa report , controls whether the lower layers are notified when a lookup fails. The third argument, Fa flags , is a set of flags to ignore, as in Fn rtalloc_ign . The Fn rtalloc1 function returns a pointer to a locked Vt struct rtentry .

The Fn rtfree function frees a locked route entry, e.g., a previously allocated by Fn rtalloc1 .

The Fn RTFREE macro is used to free unlocked route entries, previously allocated by Fn rtalloc or Fn rtalloc_ign . The Fn RTFREE macro decrements the reference count on the routing table entry (see below), and frees it if the reference count has reached zero.

The preferred usage is allocating a route using Fn rtalloc or Fn rtalloc_ign and freeing using Fn RTFREE .

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. The Fn RT_REMREF macro decrements the reference count on a previously locked route entry.

RETURN VALUES

The Fn rtalloc , Fn rtalloc_ign and Fn rtfree functions do not return a value. The Fn rtalloc1 function returns a pointer to a routing-table entry if it succeeds, otherwise a null pointer. Lack of a route should in most cases be translated to the errno(2) value Er EHOSTUNREACH .

SEE ALSO

route(4), rtentry(9)

HISTORY

The facility first appeared in BSD 4.2 although with much different internals. The Fn rtalloc_ign function and the Fa flags argument to Fn rtalloc1 first appeared in Fx 2.0 . Routing table locking was introduced in Fx 5.2 .

AUTHORS

This manual page was written by An Garrett Wollman , as were the changes to implement RTF_PRCLONING and the Fn rtalloc_ign function and the Fa flags argument to Fn rtalloc1 .