1*5134dfccSwiz.\" $NetBSD: rt_timer.9,v 1.15 2016/06/01 08:17:47 wiz Exp $ 2238a0147Skml.\" 3238a0147Skml.\" Copyright (c) 1998 The NetBSD Foundation, Inc. 4238a0147Skml.\" All rights reserved. 5238a0147Skml.\" 6238a0147Skml.\" This code is derived from software contributed to The NetBSD Foundation 7238a0147Skml.\" by Kevin M. Lahey of the Numerical Aerospace Simulation Facility, 8238a0147Skml.\" NASA Ames Research Center. 9238a0147Skml.\" 10238a0147Skml.\" Redistribution and use in source and binary forms, with or without 11238a0147Skml.\" modification, are permitted provided that the following conditions 12238a0147Skml.\" are met: 13238a0147Skml.\" 1. Redistributions of source code must retain the above copyright 14238a0147Skml.\" notice, this list of conditions and the following disclaimer. 15238a0147Skml.\" 2. Redistributions in binary form must reproduce the above copyright 16238a0147Skml.\" notice, this list of conditions and the following disclaimer in the 17238a0147Skml.\" documentation and/or other materials provided with the distribution. 18238a0147Skml.\" 19238a0147Skml.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20238a0147Skml.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21238a0147Skml.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22238a0147Skml.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23238a0147Skml.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24238a0147Skml.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25238a0147Skml.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26238a0147Skml.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27238a0147Skml.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28238a0147Skml.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29238a0147Skml.\" POSSIBILITY OF SUCH DAMAGE. 30238a0147Skml.\" 31bda3fddbSpgoyette.Dd June 1, 2016 32238a0147Skml.Dt RT_TIMER 9 33e4c16bfbSgarbled.Os 34238a0147Skml.Sh NAME 35238a0147Skml.Nm rt_timer , 36238a0147Skml.Nm rt_timer_add , 37238a0147Skml.Nm rt_timer_queue_create , 38238a0147Skml.Nm rt_timer_queue_change , 39238a0147Skml.Nm rt_timer_queue_destroy , 40238a0147Skml.Nm rt_timer_remove_all 41238a0147Skml.Nd route callout functions 42238a0147Skml.Sh SYNOPSIS 43472351e1Swiz.In net/route.h 44238a0147Skml.Ft "struct rttimer_queue *" 45238a0147Skml.Fn rt_timer_queue_create "time_t timeout" 46238a0147Skml.Ft void 47238a0147Skml.Fn rt_timer_queue_change "struct rttimer_queue *q" "time_t timeout" 48238a0147Skml.Ft void 49238a0147Skml.Fn rt_timer_queue_destroy "struct rttimer_queue *q" "int destroy" 50238a0147Skml.Ft int 51238a0147Skml.Fn rt_timer_add "struct rtentry *rt" \ 52238a0147Skml"void(*f)(struct rtentry *, struct rttimer *)" "struct rttimer_queue *q" 53238a0147Skml.Ft void 54238a0147Skml.Fn rt_timer_remove_all "struct rtentry *rt" 55238a0147Skml.Sh DESCRIPTION 56238a0147SkmlThe 57238a0147Skml.Nm 58238a0147Skmlfunctions provide a generic route callout functionality. 59238a0147SkmlThey allow a function to be called for a route at any time. 60238a0147SkmlThis was originally intended to be used to remove routes added 61238a0147Skmlby path MTU discovery code. 62238a0147Skml.Pp 63238a0147SkmlFor maximum efficiency, a separate queue should be defined for each 64770eef21Swiztimeout period. 65770eef21SwizFor example, one queue should be created for the 10 minute path MTU 66770eef21Swizdiscovery timeouts, another for 20 minute ARP timeouts after 20 67770eef21Swizminutes, and so on. 68770eef21SwizThis permits extremely fast queue manipulations so that the timeout 69770eef21Swizfunctions remain scalable, even in the face of thousands of route 70770eef21Swizmanipulations per minute. 71238a0147Skml.Pp 72238a0147SkmlIt is possible to create only a single timeout queue for all possible 73238a0147Skmltimeout values, but doing so is not scalable as queue manipulations 74238a0147Skmlbecome quite expensive if the timeout deltas are not roughly constant. 75238a0147Skml.Pp 76238a0147SkmlThe 77238a0147Skml.Nm 78238a0147Skmlinterface provides the following functions: 79238a0147Skml.Bl -tag -width compact 80238a0147Skml.It Fn rt_timer_queue_create "time_t timeout" 81238a0147SkmlThis function creates a new timer queue with the specified timeout period 82238a0147Skml.Fa timeout , 83238a0147Skmlexpressed in seconds. 84238a0147Skml.It Fn rt_timer_queue_change "rttimer_queue *q" "time_t timeout" 85238a0147SkmlThis function modifies the timeout period for a timer queue. 86770eef21SwizAny value, including 0, is valid. 87770eef21SwizThe next time the timer queue's timeout expires (based on the previous 88770eef21Swiztimeout value), all entries which are valid to execute based on the new 89770eef21Swiztimeout will be executed, and the new timeout period scheduled. 90238a0147Skml.It Fn rt_timer_queue_destroy "rttimer_queue *q" "int destroy" 91770eef21SwizThis function destroys a timeout queue. 92770eef21SwizAll entries are removed, and if the 93238a0147Skml.Fa destroy 94238a0147Skmlargument is non-zero, the timeout action is performed for each entry. 95238a0147Skml.It Fn rt_timer_add "struct rtentry *rt" \ 96238a0147Skml"void(*f)(struct rtentry *, struct rttimer *)" "struct rttimer_queue *q" 97238a0147SkmlThis function adds an entry to a timeout queue. 98238a0147SkmlThe function 99238a0147Skml.Fa f 100238a0147Skmlwill be called after the timeout period for queue 101238a0147Skml.Fa q 102238a0147Skmlhas elapsed. 103238a0147SkmlIf 104238a0147Skml.Fa f 105238a0147Skmlis NULL 106238a0147Skmlthe route will be deleted when the timeout expires. 107238a0147Skml.It Fn rt_timer_remove_all "struct rtentry *rt" 108238a0147SkmlThis function removes all references to the given route from the 109238a0147Skml.Nm 110770eef21Swizsubsystem. 111770eef21SwizThis is used when a route is deleted to ensure that no dangling 112770eef21Swizreferences remain. 113238a0147Skml.El 1144119c8fbSwiz.Sh CODE REFERENCES 1154119c8fbSwizThe 1164119c8fbSwiz.Nm 1174119c8fbSwizinterface is implemented in 1184119c8fbSwiz.Pa sys/net/route.h 1194119c8fbSwizand 1204119c8fbSwiz.Pa sys/net/route.c . 121238a0147Skml.Sh SEE ALSO 1220307782fSwiz.Xr netstat 1 , 1230307782fSwiz.Xr arp 9 124409b5b81Sjoerg.Sh HISTORY 125409b5b81SjoergThe 126409b5b81Sjoerg.Nm 127409b5b81Sjoerginterface appeared in 128409b5b81Sjoerg.Nx 1.4 . 129238a0147Skml.Sh AUTHORS 130*5134dfccSwiz.An -nosplit 13140ac8480SwizThis interface is roughly based on (but, alas, not compatible with) one 132770eef21Swizdesigned by David Borman of BSDI. 133bda3fddbSpgoyetteThis implementation is by 134bda3fddbSpgoyette.An Kevin Lahey 135bda3fddbSpgoyetteof the Numerical Aerospace Simulation Facility, NASA Ames Research Center. 136