1996-10-08 18:45:06 +00:00
|
|
|
.\"
|
|
|
|
.\" 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
|
|
|
|
.\" software without specific, written prior permission. M.I.T. makes
|
|
|
|
.\" no representations about the suitability of this software for any
|
|
|
|
.\" purpose. It is provided "as is" without express or implied
|
|
|
|
.\" warranty.
|
2001-07-14 19:41:16 +00:00
|
|
|
.\"
|
1996-10-08 18:45:06 +00:00
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS
|
|
|
|
.\" ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT
|
|
|
|
.\" SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
.\" LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
|
|
.\" USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
|
|
.\" ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
|
|
.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
|
|
|
.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
.\" SUCH DAMAGE.
|
|
|
|
.\"
|
1999-08-28 00:22:10 +00:00
|
|
|
.\" $FreeBSD$
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
.\"
|
|
|
|
.Dd December 11, 2008
|
1996-10-08 18:45:06 +00:00
|
|
|
.Os
|
|
|
|
.Dt RTALLOC 9
|
|
|
|
.Sh NAME
|
|
|
|
.Nm rtalloc ,
|
|
|
|
.Nm rtalloc_ign ,
|
2004-10-07 10:14:23 +00:00
|
|
|
.Nm rtalloc1 ,
|
|
|
|
.Nm rtfree
|
1996-10-08 18:45:06 +00:00
|
|
|
.Nd look up a route in the kernel routing table
|
|
|
|
.Sh SYNOPSIS
|
2001-10-01 16:09:29 +00:00
|
|
|
.In sys/types.h
|
|
|
|
.In sys/socket.h
|
|
|
|
.In net/route.h
|
1996-10-08 18:45:06 +00:00
|
|
|
.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"
|
2004-10-07 10:14:23 +00:00
|
|
|
.Ft void
|
|
|
|
.Fn rtfree "struct rt_entry *rt"
|
|
|
|
.Fn RTFREE "struct rt_entry *rt"
|
2004-10-11 20:48:36 +00:00
|
|
|
.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"
|
1996-10-08 18:45:06 +00:00
|
|
|
.Sh DESCRIPTION
|
|
|
|
The kernel uses a radix tree structure to manage routes for the
|
2003-10-23 02:15:46 +00:00
|
|
|
networking subsystem.
|
|
|
|
The
|
1996-10-08 18:45:06 +00:00
|
|
|
.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.
|
|
|
|
.\" XXX - -mdoc should contain a standard request for getting em and
|
2000-12-29 09:18:45 +00:00
|
|
|
.\" en dashes.
|
1996-10-08 18:45:06 +00:00
|
|
|
.Pp
|
|
|
|
.Dv RTF_PRCLONING
|
2004-10-08 09:52:00 +00:00
|
|
|
flag is obsolete and thus ignored by facility.
|
1996-10-08 18:45:06 +00:00
|
|
|
If the
|
|
|
|
.Dv RTF_XRESOLVE
|
|
|
|
flag is set, then the
|
|
|
|
.Dv RTM_RESOLVE
|
|
|
|
message is sent instead on the
|
|
|
|
.Xr route 4
|
|
|
|
socket interface, requesting that an external program resolve the
|
|
|
|
address in question and modify the route appropriately.
|
|
|
|
.Pp
|
|
|
|
The default interface is
|
|
|
|
.Fn rtalloc .
|
|
|
|
Its only argument is
|
2003-05-31 14:07:25 +00:00
|
|
|
.Fa ro ,
|
1996-10-08 18:45:06 +00:00
|
|
|
a pointer to a
|
|
|
|
.Dq Li "struct route" ,
|
|
|
|
which is defined as follows:
|
|
|
|
.Bd -literal -offset indent
|
|
|
|
struct route {
|
|
|
|
struct sockaddr ro_dst;
|
|
|
|
struct rtentry *ro_rt;
|
|
|
|
};
|
|
|
|
.Ed
|
2004-10-07 10:59:09 +00:00
|
|
|
.Pp
|
1996-10-08 18:45:06 +00:00
|
|
|
Thus, this function can only be used for address families which are
|
|
|
|
smaller than the default
|
|
|
|
.Dq Li "struct sockaddr" .
|
|
|
|
Before calling
|
2001-07-14 19:41:16 +00:00
|
|
|
.Fn rtalloc
|
|
|
|
for the first time, callers should ensure that unused bits of the
|
2003-10-23 02:15:46 +00:00
|
|
|
structure are set to zero.
|
|
|
|
On subsequent calls,
|
1996-10-08 18:45:06 +00:00
|
|
|
.Fn rtalloc
|
|
|
|
returns without performing a lookup if
|
2003-06-02 15:02:06 +00:00
|
|
|
.Fa ro->ro_rt
|
1996-10-08 18:45:06 +00:00
|
|
|
is non-null and the
|
|
|
|
.Dv RTF_UP
|
|
|
|
flag is set in the route's
|
|
|
|
.Li rt_flags
|
|
|
|
field.
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn rtalloc_ign
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
interface can be used when the caller does not want to receive
|
|
|
|
the returned
|
|
|
|
.Fa rtentry
|
|
|
|
locked.
|
2003-10-23 02:15:46 +00:00
|
|
|
The
|
2003-05-31 14:07:25 +00:00
|
|
|
.Fa ro
|
2001-07-14 19:41:16 +00:00
|
|
|
argument is the same as
|
1996-10-08 18:45:06 +00:00
|
|
|
.Fn rtalloc ,
|
|
|
|
but there is additionally a
|
2003-05-31 14:07:25 +00:00
|
|
|
.Fa flags
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
argument, which is now only used to pass
|
|
|
|
.Dv RTF_RNH_LOCKED
|
|
|
|
indicating that the radix tree lock is already held.
|
2004-10-07 10:14:23 +00:00
|
|
|
Both
|
|
|
|
.Fn rtalloc
|
|
|
|
and
|
|
|
|
.Fn rtalloc_ign
|
2004-10-07 10:59:09 +00:00
|
|
|
functions return a pointer to an unlocked
|
|
|
|
.Vt "struct rtentry" .
|
1996-10-08 18:45:06 +00:00
|
|
|
.Pp
|
|
|
|
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
|
|
|
|
.Dq Li "struct route" ,
|
|
|
|
and is therefore suitable for address families which require more
|
|
|
|
space than is in a traditional
|
|
|
|
.Dq Li "struct sockaddr" .
|
|
|
|
Instead, it takes a
|
|
|
|
.Dq Li "struct sockaddr *"
|
|
|
|
directly as the
|
2003-05-31 14:07:25 +00:00
|
|
|
.Fa sa
|
2003-10-23 02:15:46 +00:00
|
|
|
argument.
|
|
|
|
The second argument,
|
2003-05-31 14:07:25 +00:00
|
|
|
.Fa report ,
|
This main goals of this project are:
1. separating L2 tables (ARP, NDP) from the L3 routing tables
2. removing as much locking dependencies among these layers as
possible to allow for some parallelism in the search operations
3. simplify the logic in the routing code,
The most notable end result is the obsolescent of the route
cloning (RTF_CLONING) concept, which translated into code reduction
in both IPv4 ARP and IPv6 NDP related modules, and size reduction in
struct rtentry{}. The change in design obsoletes the semantics of
RTF_CLONING, RTF_WASCLONE and RTF_LLINFO routing flags. The userland
applications such as "arp" and "ndp" have been modified to reflect
those changes. The output from "netstat -r" shows only the routing
entries.
Quite a few developers have contributed to this project in the
past: Glebius Smirnoff, Luigi Rizzo, Alessandro Cerri, and
Andre Oppermann. And most recently:
- Kip Macy revised the locking code completely, thus completing
the last piece of the puzzle, Kip has also been conducting
active functional testing
- Sam Leffler has helped me improving/refactoring the code, and
provided valuable reviews
- Julian Elischer setup the perforce tree for me and has helped
me maintaining that branch before the svn conversion
2008-12-15 06:10:57 +00:00
|
|
|
controls whether the lower layers are notified when a lookup fails.
|
1996-10-08 18:45:06 +00:00
|
|
|
The third argument,
|
2003-05-31 14:07:25 +00:00
|
|
|
.Fa flags ,
|
1996-10-08 18:45:06 +00:00
|
|
|
is a set of flags to ignore, as in
|
|
|
|
.Fn rtalloc_ign .
|
2004-10-07 10:59:09 +00:00
|
|
|
The
|
2004-10-07 10:14:23 +00:00
|
|
|
.Fn rtalloc1
|
2004-10-08 09:52:00 +00:00
|
|
|
function returns a pointer to a locked
|
2004-10-07 10:59:09 +00:00
|
|
|
.Vt "struct rtentry" .
|
2004-10-07 10:14:23 +00:00
|
|
|
.Pp
|
1996-10-08 18:45:06 +00:00
|
|
|
The
|
2004-10-07 10:14:23 +00:00
|
|
|
.Fn rtfree
|
2004-10-08 09:52:00 +00:00
|
|
|
function frees a locked route entry, e.g., a previously allocated by
|
2004-10-07 10:14:23 +00:00
|
|
|
.Fn rtalloc1 .
|
|
|
|
.Pp
|
2004-10-07 10:59:09 +00:00
|
|
|
The
|
2004-10-07 10:14:23 +00:00
|
|
|
.Fn RTFREE
|
|
|
|
macro is used to free unlocked route entries, previously allocated by
|
1996-10-08 18:45:06 +00:00
|
|
|
.Fn rtalloc
|
2004-10-07 10:14:23 +00:00
|
|
|
or
|
|
|
|
.Fn rtalloc_ign .
|
2004-10-11 20:48:36 +00:00
|
|
|
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.
|
|
|
|
.Pp
|
2004-10-07 10:14:23 +00:00
|
|
|
The preferred usage is allocating a route using
|
|
|
|
.Fn rtalloc
|
|
|
|
or
|
|
|
|
.Fn rtalloc_ign
|
|
|
|
and freeing using
|
|
|
|
.Fn RTFREE .
|
2004-10-11 20:48:36 +00:00
|
|
|
.Pp
|
|
|
|
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.
|
|
|
|
.Pp
|
|
|
|
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.
|
2004-10-07 10:14:23 +00:00
|
|
|
.Sh RETURN VALUES
|
|
|
|
The
|
|
|
|
.Fn rtalloc ,
|
1996-10-08 18:45:06 +00:00
|
|
|
.Fn rtalloc_ign
|
2004-10-07 10:14:23 +00:00
|
|
|
and
|
|
|
|
.Fn rtfree
|
2003-10-23 02:15:46 +00:00
|
|
|
functions do not return a value.
|
|
|
|
The
|
1996-10-08 18:45:06 +00:00
|
|
|
.Fn rtalloc1
|
|
|
|
function returns a pointer to a routing-table entry if it succeeds,
|
2003-10-23 02:15:46 +00:00
|
|
|
otherwise a null pointer.
|
|
|
|
Lack of a route should in most cases be
|
1996-10-08 18:45:06 +00:00
|
|
|
translated to the
|
|
|
|
.Xr errno 2
|
|
|
|
value
|
|
|
|
.Er EHOSTUNREACH .
|
|
|
|
.Sh SEE ALSO
|
1996-10-08 20:25:39 +00:00
|
|
|
.Xr route 4 ,
|
|
|
|
.Xr rtentry 9
|
1996-10-08 18:45:06 +00:00
|
|
|
.Sh HISTORY
|
|
|
|
The
|
2000-11-20 18:41:33 +00:00
|
|
|
.Nm
|
1996-10-08 18:45:06 +00:00
|
|
|
facility first appeared in
|
|
|
|
.Bx 4.2 ,
|
2003-10-23 02:15:46 +00:00
|
|
|
although with much different internals.
|
|
|
|
The
|
1996-10-08 18:45:06 +00:00
|
|
|
.Fn rtalloc_ign
|
|
|
|
function and the
|
2003-05-31 14:07:25 +00:00
|
|
|
.Fa flags
|
1996-10-08 18:45:06 +00:00
|
|
|
argument to
|
|
|
|
.Fn rtalloc1
|
|
|
|
first appeared in
|
|
|
|
.Fx 2.0 .
|
2004-10-11 20:48:36 +00:00
|
|
|
Routing table locking was introduced in
|
|
|
|
.Fx 5.2 .
|
1998-03-12 07:31:21 +00:00
|
|
|
.Sh AUTHORS
|
|
|
|
This manual page was written by
|
|
|
|
.An Garrett Wollman ,
|
|
|
|
as were the changes to implement
|
1996-10-08 18:45:06 +00:00
|
|
|
.Dv RTF_PRCLONING
|
|
|
|
and the
|
|
|
|
.Fn rtalloc_ign
|
|
|
|
function and the
|
2003-05-31 14:07:25 +00:00
|
|
|
.Fa flags
|
2001-07-14 19:41:16 +00:00
|
|
|
argument to
|
1996-10-08 18:45:06 +00:00
|
|
|
.Fn rtalloc1 .
|