NetBSD/share/man/man9/rt_timer.9
2016-06-01 08:17:47 +00:00

136 lines
4.8 KiB
Groff

.\" $NetBSD: rt_timer.9,v 1.15 2016/06/01 08:17:47 wiz Exp $
.\"
.\" Copyright (c) 1998 The NetBSD Foundation, Inc.
.\" All rights reserved.
.\"
.\" This code is derived from software contributed to The NetBSD Foundation
.\" by Kevin M. Lahey of the Numerical Aerospace Simulation Facility,
.\" NASA Ames Research Center.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\" notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
.\" 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.
.\"
.Dd June 1, 2016
.Dt RT_TIMER 9
.Os
.Sh NAME
.Nm rt_timer ,
.Nm rt_timer_add ,
.Nm rt_timer_queue_create ,
.Nm rt_timer_queue_change ,
.Nm rt_timer_queue_destroy ,
.Nm rt_timer_remove_all
.Nd route callout functions
.Sh SYNOPSIS
.In net/route.h
.Ft "struct rttimer_queue *"
.Fn rt_timer_queue_create "time_t timeout"
.Ft void
.Fn rt_timer_queue_change "struct rttimer_queue *q" "time_t timeout"
.Ft void
.Fn rt_timer_queue_destroy "struct rttimer_queue *q" "int destroy"
.Ft int
.Fn rt_timer_add "struct rtentry *rt" \
"void(*f)(struct rtentry *, struct rttimer *)" "struct rttimer_queue *q"
.Ft void
.Fn rt_timer_remove_all "struct rtentry *rt"
.Sh DESCRIPTION
The
.Nm
functions provide a generic route callout functionality.
They allow a function to be called for a route at any time.
This was originally intended to be used to remove routes added
by path MTU discovery code.
.Pp
For maximum efficiency, a separate queue should be defined for each
timeout period.
For example, one queue should be created for the 10 minute path MTU
discovery timeouts, another for 20 minute ARP timeouts after 20
minutes, and so on.
This permits extremely fast queue manipulations so that the timeout
functions remain scalable, even in the face of thousands of route
manipulations per minute.
.Pp
It is possible to create only a single timeout queue for all possible
timeout values, but doing so is not scalable as queue manipulations
become quite expensive if the timeout deltas are not roughly constant.
.Pp
The
.Nm
interface provides the following functions:
.Bl -tag -width compact
.It Fn rt_timer_queue_create "time_t timeout"
This function creates a new timer queue with the specified timeout period
.Fa timeout ,
expressed in seconds.
.It Fn rt_timer_queue_change "rttimer_queue *q" "time_t timeout"
This function modifies the timeout period for a timer queue.
Any value, including 0, is valid.
The next time the timer queue's timeout expires (based on the previous
timeout value), all entries which are valid to execute based on the new
timeout will be executed, and the new timeout period scheduled.
.It Fn rt_timer_queue_destroy "rttimer_queue *q" "int destroy"
This function destroys a timeout queue.
All entries are removed, and if the
.Fa destroy
argument is non-zero, the timeout action is performed for each entry.
.It Fn rt_timer_add "struct rtentry *rt" \
"void(*f)(struct rtentry *, struct rttimer *)" "struct rttimer_queue *q"
This function adds an entry to a timeout queue.
The function
.Fa f
will be called after the timeout period for queue
.Fa q
has elapsed.
If
.Fa f
is NULL
the route will be deleted when the timeout expires.
.It Fn rt_timer_remove_all "struct rtentry *rt"
This function removes all references to the given route from the
.Nm
subsystem.
This is used when a route is deleted to ensure that no dangling
references remain.
.El
.Sh CODE REFERENCES
The
.Nm
interface is implemented in
.Pa sys/net/route.h
and
.Pa sys/net/route.c .
.Sh SEE ALSO
.Xr netstat 1 ,
.Xr arp 9
.Sh HISTORY
The
.Nm
interface appeared in
.Nx 1.4 .
.Sh AUTHORS
.An -nosplit
This interface is roughly based on (but, alas, not compatible with) one
designed by David Borman of BSDI.
This implementation is by
.An Kevin Lahey
of the Numerical Aerospace Simulation Facility, NASA Ames Research Center.