mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-21 09:11:54 +00:00
Timers: Revert temporary names and remove old timer.h
This commit is contained in:
parent
574b232427
commit
a6f79ca57f
12
conf/conf.c
12
conf/conf.c
@ -52,7 +52,7 @@
|
||||
#include "lib/resource.h"
|
||||
#include "lib/string.h"
|
||||
#include "lib/event.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "lib/timer.h"
|
||||
#include "conf/conf.h"
|
||||
#include "filter/filter.h"
|
||||
|
||||
@ -341,9 +341,9 @@ config_commit(struct config *c, int type, uint timeout)
|
||||
|
||||
undo_available = 1;
|
||||
if (timeout)
|
||||
tm2_start(config_timer, timeout S);
|
||||
tm_start(config_timer, timeout S);
|
||||
else
|
||||
tm2_stop(config_timer);
|
||||
tm_stop(config_timer);
|
||||
|
||||
if (configuring)
|
||||
{
|
||||
@ -384,7 +384,7 @@ config_confirm(void)
|
||||
if (config_timer->expires == 0)
|
||||
return CONF_NOTHING;
|
||||
|
||||
tm2_stop(config_timer);
|
||||
tm_stop(config_timer);
|
||||
|
||||
return CONF_CONFIRM;
|
||||
}
|
||||
@ -420,7 +420,7 @@ config_undo(void)
|
||||
return CONF_NOTHING;
|
||||
|
||||
undo_available = 0;
|
||||
tm2_stop(config_timer);
|
||||
tm_stop(config_timer);
|
||||
|
||||
if (configuring)
|
||||
{
|
||||
@ -468,7 +468,7 @@ config_init(void)
|
||||
config_event = ev_new(&root_pool);
|
||||
config_event->hook = config_done;
|
||||
|
||||
config_timer = tm2_new(&root_pool);
|
||||
config_timer = tm_new(&root_pool);
|
||||
config_timer->hook = config_timeout;
|
||||
}
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "lib/ip.h"
|
||||
#include "lib/hash.h"
|
||||
#include "lib/resource.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "lib/timer.h"
|
||||
|
||||
|
||||
/* Configuration structure */
|
||||
|
@ -11,16 +11,6 @@ CF_HDR
|
||||
#define PARSER 1
|
||||
|
||||
#include "nest/bird.h"
|
||||
#include "conf/conf.h"
|
||||
#include "lib/resource.h"
|
||||
#include "lib/socket.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "lib/string.h"
|
||||
#include "nest/protocol.h"
|
||||
#include "nest/iface.h"
|
||||
#include "nest/route.h"
|
||||
#include "nest/cli.h"
|
||||
#include "filter/filter.h"
|
||||
#include "lib/flowspec.h"
|
||||
|
||||
|
||||
|
46
lib/timer.c
46
lib/timer.c
@ -93,17 +93,17 @@ current_real_time(void)
|
||||
|
||||
|
||||
static void
|
||||
tm2_free(resource *r)
|
||||
tm_free(resource *r)
|
||||
{
|
||||
timer2 *t = (timer2 *) r;
|
||||
timer *t = (void *) r;
|
||||
|
||||
tm2_stop(t);
|
||||
tm_stop(t);
|
||||
}
|
||||
|
||||
static void
|
||||
tm2_dump(resource *r)
|
||||
tm_dump(resource *r)
|
||||
{
|
||||
timer2 *t = (timer2 *) r;
|
||||
timer *t = (void *) r;
|
||||
|
||||
debug("(code %p, data %p, ", t->hook, t->data);
|
||||
if (t->randomize)
|
||||
@ -117,25 +117,25 @@ tm2_dump(resource *r)
|
||||
}
|
||||
|
||||
|
||||
static struct resclass tm2_class = {
|
||||
static struct resclass tm_class = {
|
||||
"Timer",
|
||||
sizeof(timer2),
|
||||
tm2_free,
|
||||
tm2_dump,
|
||||
sizeof(timer),
|
||||
tm_free,
|
||||
tm_dump,
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
timer2 *
|
||||
tm2_new(pool *p)
|
||||
timer *
|
||||
tm_new(pool *p)
|
||||
{
|
||||
timer2 *t = ralloc(p, &tm2_class);
|
||||
timer *t = ralloc(p, &tm_class);
|
||||
t->index = -1;
|
||||
return t;
|
||||
}
|
||||
|
||||
void
|
||||
tm2_set(timer2 *t, btime when)
|
||||
tm_set(timer *t, btime when)
|
||||
{
|
||||
struct timeloop *loop = timeloop_current();
|
||||
uint tc = timers_count(loop);
|
||||
@ -145,17 +145,17 @@ tm2_set(timer2 *t, btime when)
|
||||
t->index = ++tc;
|
||||
t->expires = when;
|
||||
BUFFER_PUSH(loop->timers) = t;
|
||||
HEAP_INSERT(loop->timers.data, tc, timer2 *, TIMER_LESS, TIMER_SWAP);
|
||||
HEAP_INSERT(loop->timers.data, tc, timer *, TIMER_LESS, TIMER_SWAP);
|
||||
}
|
||||
else if (t->expires < when)
|
||||
{
|
||||
t->expires = when;
|
||||
HEAP_INCREASE(loop->timers.data, tc, timer2 *, TIMER_LESS, TIMER_SWAP, t->index);
|
||||
HEAP_INCREASE(loop->timers.data, tc, timer *, TIMER_LESS, TIMER_SWAP, t->index);
|
||||
}
|
||||
else if (t->expires > when)
|
||||
{
|
||||
t->expires = when;
|
||||
HEAP_DECREASE(loop->timers.data, tc, timer2 *, TIMER_LESS, TIMER_SWAP, t->index);
|
||||
HEAP_DECREASE(loop->timers.data, tc, timer *, TIMER_LESS, TIMER_SWAP, t->index);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_BFD
|
||||
@ -166,13 +166,13 @@ tm2_set(timer2 *t, btime when)
|
||||
}
|
||||
|
||||
void
|
||||
tm2_start(timer2 *t, btime after)
|
||||
tm_start(timer *t, btime after)
|
||||
{
|
||||
tm2_set(t, current_time() + MAX(after, 0));
|
||||
tm_set(t, current_time() + MAX(after, 0));
|
||||
}
|
||||
|
||||
void
|
||||
tm2_stop(timer2 *t)
|
||||
tm_stop(timer *t)
|
||||
{
|
||||
if (!t->expires)
|
||||
return;
|
||||
@ -180,7 +180,7 @@ tm2_stop(timer2 *t)
|
||||
struct timeloop *loop = timeloop_current();
|
||||
uint tc = timers_count(loop);
|
||||
|
||||
HEAP_DELETE(loop->timers.data, tc, timer2 *, TIMER_LESS, TIMER_SWAP, t->index);
|
||||
HEAP_DELETE(loop->timers.data, tc, timer *, TIMER_LESS, TIMER_SWAP, t->index);
|
||||
BUFFER_POP(loop->timers);
|
||||
|
||||
t->index = -1;
|
||||
@ -202,7 +202,7 @@ void
|
||||
timers_fire(struct timeloop *loop)
|
||||
{
|
||||
btime base_time;
|
||||
timer2 *t;
|
||||
timer *t;
|
||||
|
||||
times_update(loop);
|
||||
base_time = loop->last_time;
|
||||
@ -222,10 +222,10 @@ timers_fire(struct timeloop *loop)
|
||||
if (t->randomize)
|
||||
when += random() % (t->randomize + 1);
|
||||
|
||||
tm2_set(t, when);
|
||||
tm_set(t, when);
|
||||
}
|
||||
else
|
||||
tm2_stop(t);
|
||||
tm_stop(t);
|
||||
|
||||
/* This is ugly hack, we want to log just timers executed from the main I/O loop */
|
||||
if (loop == &main_timeloop)
|
||||
|
42
lib/timer.h
42
lib/timer.h
@ -7,18 +7,18 @@
|
||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||
*/
|
||||
|
||||
#ifndef _BIRD_TIMER2_H_
|
||||
#define _BIRD_TIMER2_H_
|
||||
#ifndef _BIRD_TIMER_H_
|
||||
#define _BIRD_TIMER_H_
|
||||
|
||||
#include "nest/bird.h"
|
||||
#include "lib/buffer.h"
|
||||
#include "lib/resource.h"
|
||||
|
||||
|
||||
typedef struct timer2
|
||||
typedef struct timer
|
||||
{
|
||||
resource r;
|
||||
void (*hook)(struct timer2 *);
|
||||
void (*hook)(struct timer *);
|
||||
void *data;
|
||||
|
||||
btime expires; /* 0=inactive */
|
||||
@ -26,11 +26,11 @@ typedef struct timer2
|
||||
uint recurrent; /* Timer recurrence */
|
||||
|
||||
int index;
|
||||
} timer2;
|
||||
} timer;
|
||||
|
||||
struct timeloop
|
||||
{
|
||||
BUFFER(timer2 *) timers;
|
||||
BUFFER(timer *) timers;
|
||||
btime last_time;
|
||||
btime real_time;
|
||||
};
|
||||
@ -38,7 +38,7 @@ struct timeloop
|
||||
static inline uint timers_count(struct timeloop *loop)
|
||||
{ return loop->timers.used - 1; }
|
||||
|
||||
static inline timer2 *timers_first(struct timeloop *loop)
|
||||
static inline timer *timers_first(struct timeloop *loop)
|
||||
{ return (loop->timers.used > 1) ? loop->timers.data[1] : NULL; }
|
||||
|
||||
extern struct timeloop main_timeloop;
|
||||
@ -50,28 +50,28 @@ btime current_real_time(void);
|
||||
//#define now_real (current_real_time() TO_S)
|
||||
extern btime boot_time;
|
||||
|
||||
timer2 *tm2_new(pool *p);
|
||||
void tm2_set(timer2 *t, btime when);
|
||||
void tm2_start(timer2 *t, btime after);
|
||||
void tm2_stop(timer2 *t);
|
||||
timer *tm_new(pool *p);
|
||||
void tm_set(timer *t, btime when);
|
||||
void tm_start(timer *t, btime after);
|
||||
void tm_stop(timer *t);
|
||||
|
||||
static inline int
|
||||
tm2_active(timer2 *t)
|
||||
tm_active(timer *t)
|
||||
{
|
||||
return t->expires != 0;
|
||||
}
|
||||
|
||||
static inline btime
|
||||
tm2_remains(timer2 *t)
|
||||
tm_remains(timer *t)
|
||||
{
|
||||
btime now_ = current_time();
|
||||
return (t->expires > now_) ? (t->expires - now_) : 0;
|
||||
}
|
||||
|
||||
static inline timer2 *
|
||||
tm2_new_init(pool *p, void (*hook)(struct timer2 *), void *data, uint rec, uint rand)
|
||||
static inline timer *
|
||||
tm_new_init(pool *p, void (*hook)(struct timer *), void *data, uint rec, uint rand)
|
||||
{
|
||||
timer2 *t = tm2_new(p);
|
||||
timer *t = tm_new(p);
|
||||
t->hook = hook;
|
||||
t->data = data;
|
||||
t->recurrent = rec;
|
||||
@ -80,17 +80,17 @@ tm2_new_init(pool *p, void (*hook)(struct timer2 *), void *data, uint rec, uint
|
||||
}
|
||||
|
||||
static inline void
|
||||
tm2_set_max(timer2 *t, btime when)
|
||||
tm_set_max(timer *t, btime when)
|
||||
{
|
||||
if (when > t->expires)
|
||||
tm2_set(t, when);
|
||||
tm_set(t, when);
|
||||
}
|
||||
|
||||
static inline void
|
||||
tm2_start_max(timer2 *t, btime after)
|
||||
tm_start_max(timer *t, btime after)
|
||||
{
|
||||
btime rem = tm2_remains(t);
|
||||
tm2_start(t, MAX_(rem, after));
|
||||
btime rem = tm_remains(t);
|
||||
tm_start(t, MAX_(rem, after));
|
||||
}
|
||||
|
||||
/* In sysdep code */
|
||||
|
12
nest/proto.c
12
nest/proto.c
@ -1083,8 +1083,8 @@ graceful_restart_init(void)
|
||||
}
|
||||
|
||||
graceful_restart_state = GRS_ACTIVE;
|
||||
gr_wait_timer = tm2_new_init(proto_pool, graceful_restart_done, NULL, 0, 0);
|
||||
tm2_start(gr_wait_timer, config->gr_wait S);
|
||||
gr_wait_timer = tm_new_init(proto_pool, graceful_restart_done, NULL, 0, 0);
|
||||
tm_start(gr_wait_timer, config->gr_wait S);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1135,7 +1135,7 @@ graceful_restart_show_status(void)
|
||||
|
||||
cli_msg(-24, "Graceful restart recovery in progress");
|
||||
cli_msg(-24, " Waiting for %d channels to recover", graceful_restart_locks);
|
||||
cli_msg(-24, " Wait timer is %t/%u", tm2_remains(gr_wait_timer), config->gr_wait);
|
||||
cli_msg(-24, " Wait timer is %t/%u", tm_remains(gr_wait_timer), config->gr_wait);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1181,7 +1181,7 @@ channel_graceful_restart_unlock(struct channel *c)
|
||||
graceful_restart_locks--;
|
||||
|
||||
if ((graceful_restart_state == GRS_ACTIVE) && !graceful_restart_locks)
|
||||
tm2_start(gr_wait_timer, 0);
|
||||
tm_start(gr_wait_timer, 0);
|
||||
}
|
||||
|
||||
|
||||
@ -1288,7 +1288,7 @@ protos_build(void)
|
||||
#endif
|
||||
|
||||
proto_pool = rp_new(&root_pool, "Protocols");
|
||||
proto_shutdown_timer = tm2_new(proto_pool);
|
||||
proto_shutdown_timer = tm_new(proto_pool);
|
||||
proto_shutdown_timer->hook = proto_shutdown_loop;
|
||||
}
|
||||
|
||||
@ -1328,7 +1328,7 @@ proto_schedule_down(struct proto *p, byte restart, byte code)
|
||||
|
||||
p->down_sched = restart ? PDS_RESTART : PDS_DISABLE;
|
||||
p->down_code = code;
|
||||
tm2_start_max(proto_shutdown_timer, restart ? 250 MS : 0);
|
||||
tm_start_max(proto_shutdown_timer, restart ? 250 MS : 0);
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "lib/lists.h"
|
||||
#include "lib/resource.h"
|
||||
#include "lib/event.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "nest/route.h"
|
||||
#include "conf/conf.h"
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
|
||||
#include "lib/lists.h"
|
||||
#include "lib/resource.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "lib/net.h"
|
||||
|
||||
struct ea_list;
|
||||
|
@ -1433,14 +1433,14 @@ babel_iface_timer(timer *t)
|
||||
|
||||
btime next_event = MIN(ifa->next_hello, ifa->next_regular);
|
||||
if (ifa->want_triggered) next_event = MIN(next_event, ifa->next_triggered);
|
||||
tm2_set(ifa->timer, next_event);
|
||||
tm_set(ifa->timer, next_event);
|
||||
}
|
||||
|
||||
static inline void
|
||||
babel_iface_kick_timer(struct babel_iface *ifa)
|
||||
{
|
||||
if (ifa->timer->expires > (current_time() + 100 MS))
|
||||
tm2_start(ifa->timer, 100 MS);
|
||||
tm_start(ifa->timer, 100 MS);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1454,7 +1454,7 @@ babel_iface_start(struct babel_iface *ifa)
|
||||
ifa->next_regular = current_time() + (random() % ifa->cf->update_interval);
|
||||
ifa->next_triggered = current_time() + MIN(1 S, ifa->cf->update_interval / 2);
|
||||
ifa->want_triggered = 0; /* We send an immediate update (below) */
|
||||
tm2_start(ifa->timer, 100 MS);
|
||||
tm_start(ifa->timer, 100 MS);
|
||||
ifa->up = 1;
|
||||
|
||||
babel_send_hello(ifa);
|
||||
@ -1487,7 +1487,7 @@ babel_iface_stop(struct babel_iface *ifa)
|
||||
}
|
||||
}
|
||||
|
||||
tm2_stop(ifa->timer);
|
||||
tm_stop(ifa->timer);
|
||||
ifa->up = 0;
|
||||
}
|
||||
|
||||
@ -1585,7 +1585,7 @@ babel_add_iface(struct babel_proto *p, struct iface *new, struct babel_iface_con
|
||||
init_list(&ifa->neigh_list);
|
||||
ifa->hello_seqno = 1;
|
||||
|
||||
ifa->timer = tm2_new_init(ifa->pool, babel_iface_timer, ifa, 0, 0);
|
||||
ifa->timer = tm_new_init(ifa->pool, babel_iface_timer, ifa, 0, 0);
|
||||
|
||||
init_list(&ifa->msg_queue);
|
||||
ifa->send_event = ev_new(ifa->pool);
|
||||
@ -2050,7 +2050,7 @@ static inline void
|
||||
babel_kick_timer(struct babel_proto *p)
|
||||
{
|
||||
if (p->timer->expires > (current_time() + 100 MS))
|
||||
tm2_start(p->timer, 100 MS);
|
||||
tm_start(p->timer, 100 MS);
|
||||
}
|
||||
|
||||
|
||||
@ -2214,8 +2214,8 @@ babel_start(struct proto *P)
|
||||
OFFSETOF(struct babel_entry, n), 0, babel_init_entry);
|
||||
|
||||
init_list(&p->interfaces);
|
||||
p->timer = tm2_new_init(P->pool, babel_timer, p, 1 S, 0);
|
||||
tm2_start(p->timer, 1 S);
|
||||
p->timer = tm_new_init(P->pool, babel_timer, p, 1 S, 0);
|
||||
tm_start(p->timer, 1 S);
|
||||
p->update_seqno = 1;
|
||||
p->router_id = proto_get_router_id(&cf->c);
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include "lib/lists.h"
|
||||
#include "lib/socket.h"
|
||||
#include "lib/string.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "lib/timer.h"
|
||||
|
||||
#define EA_BABEL_METRIC EA_CODE(EAP_BABEL, 0)
|
||||
#define EA_BABEL_ROUTER_ID EA_CODE(EAP_BABEL, 1)
|
||||
|
@ -64,16 +64,15 @@
|
||||
* ready, the protocol just creates a BFD request like any other protocol.
|
||||
*
|
||||
* The protocol uses a new generic event loop (structure &birdloop) from |io.c|,
|
||||
* which supports sockets, timers and events like the main loop. Timers
|
||||
* (structure &timer2) are new microsecond based timers, while sockets and
|
||||
* events are the same. A birdloop is associated with a thread (field @thread)
|
||||
* in which event hooks are executed. Most functions for setting event sources
|
||||
* (like sk_start() or tm2_start()) must be called from the context of that
|
||||
* thread. Birdloop allows to temporarily acquire the context of that thread for
|
||||
* the main thread by calling birdloop_enter() and then birdloop_leave(), which
|
||||
* also ensures mutual exclusion with all event hooks. Note that resources
|
||||
* associated with a birdloop (like timers) should be attached to the
|
||||
* independent resource pool, detached from the main resource tree.
|
||||
* which supports sockets, timers and events like the main loop. A birdloop is
|
||||
* associated with a thread (field @thread) in which event hooks are executed.
|
||||
* Most functions for setting event sources (like sk_start() or tm_start()) must
|
||||
* be called from the context of that thread. Birdloop allows to temporarily
|
||||
* acquire the context of that thread for the main thread by calling
|
||||
* birdloop_enter() and then birdloop_leave(), which also ensures mutual
|
||||
* exclusion with all event hooks. Note that resources associated with a
|
||||
* birdloop (like timers) should be attached to the independent resource pool,
|
||||
* detached from the main resource tree.
|
||||
*
|
||||
* There are two kinds of interaction between the BFD core (running in the BFD
|
||||
* thread) and the rest of BFD (running in the main thread). The first kind are
|
||||
@ -177,7 +176,7 @@ bfd_session_update_tx_interval(struct bfd_session *s)
|
||||
return;
|
||||
|
||||
/* Set timer relative to last tx_timer event */
|
||||
tm2_set(s->tx_timer, s->last_tx + tx_int_l);
|
||||
tm_set(s->tx_timer, s->last_tx + tx_int_l);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -191,7 +190,7 @@ bfd_session_update_detection_time(struct bfd_session *s, int kick)
|
||||
if (!s->last_rx)
|
||||
return;
|
||||
|
||||
tm2_set(s->hold_timer, s->last_rx + timeout);
|
||||
tm_set(s->hold_timer, s->last_rx + timeout);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -212,16 +211,16 @@ bfd_session_control_tx_timer(struct bfd_session *s, int reset)
|
||||
goto stop;
|
||||
|
||||
/* So TX timer should run */
|
||||
if (reset || !tm2_active(s->tx_timer))
|
||||
if (reset || !tm_active(s->tx_timer))
|
||||
{
|
||||
s->last_tx = 0;
|
||||
tm2_start(s->tx_timer, 0);
|
||||
tm_start(s->tx_timer, 0);
|
||||
}
|
||||
|
||||
return;
|
||||
|
||||
stop:
|
||||
tm2_stop(s->tx_timer);
|
||||
tm_stop(s->tx_timer);
|
||||
s->last_tx = 0;
|
||||
}
|
||||
|
||||
@ -380,7 +379,7 @@ bfd_find_session_by_addr(struct bfd_proto *p, ip_addr addr)
|
||||
}
|
||||
|
||||
static void
|
||||
bfd_tx_timer_hook(timer2 *t)
|
||||
bfd_tx_timer_hook(timer *t)
|
||||
{
|
||||
struct bfd_session *s = t->data;
|
||||
|
||||
@ -389,7 +388,7 @@ bfd_tx_timer_hook(timer2 *t)
|
||||
}
|
||||
|
||||
static void
|
||||
bfd_hold_timer_hook(timer2 *t)
|
||||
bfd_hold_timer_hook(timer *t)
|
||||
{
|
||||
bfd_session_timeout(t->data);
|
||||
}
|
||||
@ -433,8 +432,8 @@ bfd_add_session(struct bfd_proto *p, ip_addr addr, ip_addr local, struct iface *
|
||||
s->passive = ifa->cf->passive;
|
||||
s->tx_csn = random_u32();
|
||||
|
||||
s->tx_timer = tm2_new_init(p->tpool, bfd_tx_timer_hook, s, 0, 0);
|
||||
s->hold_timer = tm2_new_init(p->tpool, bfd_hold_timer_hook, s, 0, 0);
|
||||
s->tx_timer = tm_new_init(p->tpool, bfd_tx_timer_hook, s, 0, 0);
|
||||
s->hold_timer = tm_new_init(p->tpool, bfd_hold_timer_hook, s, 0, 0);
|
||||
bfd_session_update_tx_interval(s);
|
||||
bfd_session_control_tx_timer(s, 1);
|
||||
|
||||
|
@ -140,8 +140,8 @@ struct bfd_session
|
||||
btime last_tx; /* Time of last sent periodic control packet */
|
||||
btime last_rx; /* Time of last received valid control packet */
|
||||
|
||||
timer2 *tx_timer; /* Periodic control packet timer */
|
||||
timer2 *hold_timer; /* Timer for session down detection time */
|
||||
timer *tx_timer; /* Periodic control packet timer */
|
||||
timer *hold_timer; /* Timer for session down detection time */
|
||||
|
||||
list request_list; /* List of client requests (struct bfd_request) */
|
||||
btime last_state_change; /* Time of last state change */
|
||||
|
@ -477,7 +477,7 @@ static void *
|
||||
birdloop_main(void *arg)
|
||||
{
|
||||
struct birdloop *loop = arg;
|
||||
timer2 *t;
|
||||
timer *t;
|
||||
int rv, timeout;
|
||||
|
||||
birdloop_set_current(loop);
|
||||
@ -492,7 +492,7 @@ birdloop_main(void *arg)
|
||||
if (events_waiting(loop))
|
||||
timeout = 0;
|
||||
else if (t = timers_first(&loop->time))
|
||||
timeout = (tm2_remains(t) TO_MS) + 1;
|
||||
timeout = (tm_remains(t) TO_MS) + 1;
|
||||
else
|
||||
timeout = -1;
|
||||
|
||||
|
@ -328,10 +328,10 @@ bgp_start_timer(timer *t, uint value)
|
||||
/* The randomization procedure is specified in RFC 4271 section 10 */
|
||||
btime time = value S;
|
||||
btime randomize = random() % ((time / 4) + 1);
|
||||
tm2_start(t, time - randomize);
|
||||
tm_start(t, time - randomize);
|
||||
}
|
||||
else
|
||||
tm2_stop(t);
|
||||
tm_stop(t);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -517,7 +517,7 @@ bgp_conn_enter_established_state(struct bgp_conn *conn)
|
||||
int peer_gr_ready = peer->gr_aware && !(peer->gr_flags & BGP_GRF_RESTART);
|
||||
|
||||
if (p->gr_active_num)
|
||||
tm2_stop(p->gr_timer);
|
||||
tm_stop(p->gr_timer);
|
||||
|
||||
/* Number of active channels */
|
||||
int num = 0;
|
||||
@ -616,7 +616,7 @@ bgp_conn_enter_close_state(struct bgp_conn *conn)
|
||||
int os = conn->state;
|
||||
|
||||
bgp_conn_set_state(conn, BS_CLOSE);
|
||||
tm2_stop(conn->keepalive_timer);
|
||||
tm_stop(conn->keepalive_timer);
|
||||
conn->sk->rx_hook = NULL;
|
||||
|
||||
/* Timeout for CLOSE state, if we cannot send notification soon then we just hangup */
|
||||
@ -779,7 +779,7 @@ bgp_send_open(struct bgp_conn *conn)
|
||||
DBG("BGP: Sending open\n");
|
||||
conn->sk->rx_hook = bgp_rx;
|
||||
conn->sk->tx_hook = bgp_tx;
|
||||
tm2_stop(conn->connect_timer);
|
||||
tm_stop(conn->connect_timer);
|
||||
bgp_schedule_packet(conn, NULL, PKT_OPEN);
|
||||
bgp_conn_set_state(conn, BS_OPENSENT);
|
||||
bgp_start_timer(conn->hold_timer, conn->bgp->cf->initial_hold_time);
|
||||
@ -888,9 +888,9 @@ bgp_setup_conn(struct bgp_proto *p, struct bgp_conn *conn)
|
||||
conn->last_channel = 0;
|
||||
conn->last_channel_count = 0;
|
||||
|
||||
conn->connect_timer = tm2_new_init(p->p.pool, bgp_connect_timeout, conn, 0, 0);
|
||||
conn->hold_timer = tm2_new_init(p->p.pool, bgp_hold_timeout, conn, 0, 0);
|
||||
conn->keepalive_timer = tm2_new_init(p->p.pool, bgp_keepalive_timeout, conn, 0, 0);
|
||||
conn->connect_timer = tm_new_init(p->p.pool, bgp_connect_timeout, conn, 0, 0);
|
||||
conn->hold_timer = tm_new_init(p->p.pool, bgp_hold_timeout, conn, 0, 0);
|
||||
conn->keepalive_timer = tm_new_init(p->p.pool, bgp_keepalive_timeout, conn, 0, 0);
|
||||
|
||||
conn->tx_ev = ev_new(p->p.pool);
|
||||
conn->tx_ev->hook = bgp_kick_tx;
|
||||
@ -1303,8 +1303,8 @@ bgp_start(struct proto *P)
|
||||
p->event->hook = bgp_decision;
|
||||
p->event->data = p;
|
||||
|
||||
p->startup_timer = tm2_new_init(p->p.pool, bgp_startup_timeout, p, 0, 0);
|
||||
p->gr_timer = tm2_new_init(p->p.pool, bgp_graceful_restart_timeout, p, 0, 0);
|
||||
p->startup_timer = tm_new_init(p->p.pool, bgp_startup_timeout, p, 0, 0);
|
||||
p->gr_timer = tm_new_init(p->p.pool, bgp_graceful_restart_timeout, p, 0, 0);
|
||||
|
||||
p->local_id = proto_get_router_id(P->cf);
|
||||
if (p->rr_client)
|
||||
@ -2004,18 +2004,18 @@ bgp_show_proto_info(struct proto *P)
|
||||
struct bgp_conn *oc = &p->outgoing_conn;
|
||||
|
||||
if ((p->start_state < BSS_CONNECT) &&
|
||||
(tm2_active(p->startup_timer)))
|
||||
(tm_active(p->startup_timer)))
|
||||
cli_msg(-1006, " Error wait: %t/%u",
|
||||
tm2_remains(p->startup_timer), p->startup_delay);
|
||||
tm_remains(p->startup_timer), p->startup_delay);
|
||||
|
||||
if ((oc->state == BS_ACTIVE) &&
|
||||
(tm2_active(oc->connect_timer)))
|
||||
(tm_active(oc->connect_timer)))
|
||||
cli_msg(-1006, " Connect delay: %t/%u",
|
||||
tm2_remains(oc->connect_timer), p->cf->connect_delay_time);
|
||||
tm_remains(oc->connect_timer), p->cf->connect_delay_time);
|
||||
|
||||
if (p->gr_active_num && tm2_active(p->gr_timer))
|
||||
if (p->gr_active_num && tm_active(p->gr_timer))
|
||||
cli_msg(-1006, " Restart timer: %t/-",
|
||||
tm2_remains(p->gr_timer));
|
||||
tm_remains(p->gr_timer));
|
||||
}
|
||||
else if (P->proto_state == PS_UP)
|
||||
{
|
||||
@ -2037,9 +2037,9 @@ bgp_show_proto_info(struct proto *P)
|
||||
*/
|
||||
cli_msg(-1006, " Source address: %I", p->source_addr);
|
||||
cli_msg(-1006, " Hold timer: %t/%u",
|
||||
tm2_remains(p->conn->hold_timer), p->conn->hold_time);
|
||||
tm_remains(p->conn->hold_timer), p->conn->hold_time);
|
||||
cli_msg(-1006, " Keepalive timer: %t/%u",
|
||||
tm2_remains(p->conn->keepalive_timer), p->conn->keepalive_time);
|
||||
tm_remains(p->conn->keepalive_timer), p->conn->keepalive_time);
|
||||
}
|
||||
|
||||
if ((p->last_error_class != BE_NONE) &&
|
||||
|
@ -279,8 +279,8 @@ ospf_process_dbdes(struct ospf_proto *p, struct ospf_packet *pkt, struct ospf_ne
|
||||
req->lsa = lsa;
|
||||
req->lsa_body = LSA_BODY_DUMMY;
|
||||
|
||||
if (!tm2_active(n->lsrq_timer))
|
||||
tm2_start(n->lsrq_timer, 0);
|
||||
if (!tm_active(n->lsrq_timer))
|
||||
tm_start(n->lsrq_timer, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@ -366,7 +366,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
|
||||
n->options = rcv_options;
|
||||
n->myimms &= ~DBDES_MS;
|
||||
n->imms = rcv_imms;
|
||||
tm2_stop(n->dbdes_timer);
|
||||
tm_stop(n->dbdes_timer);
|
||||
ospf_neigh_sm(n, INM_NEGDONE);
|
||||
ospf_send_dbdes(p, n);
|
||||
break;
|
||||
@ -422,13 +422,13 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
|
||||
|
||||
if (!(n->myimms & DBDES_M) && !(n->imms & DBDES_M))
|
||||
{
|
||||
tm2_stop(n->dbdes_timer);
|
||||
tm_stop(n->dbdes_timer);
|
||||
ospf_neigh_sm(n, INM_EXDONE);
|
||||
break;
|
||||
}
|
||||
|
||||
ospf_send_dbdes(p, n);
|
||||
tm2_start(n->dbdes_timer, n->ifa->rxmtint S);
|
||||
tm_start(n->dbdes_timer, n->ifa->rxmtint S);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -263,13 +263,13 @@ ospf_iface_down(struct ospf_iface *ifa)
|
||||
ospf_neigh_sm(n, INM_KILLNBR);
|
||||
|
||||
if (ifa->hello_timer)
|
||||
tm2_stop(ifa->hello_timer);
|
||||
tm_stop(ifa->hello_timer);
|
||||
|
||||
if (ifa->poll_timer)
|
||||
tm2_stop(ifa->poll_timer);
|
||||
tm_stop(ifa->poll_timer);
|
||||
|
||||
if (ifa->wait_timer)
|
||||
tm2_stop(ifa->wait_timer);
|
||||
tm_stop(ifa->wait_timer);
|
||||
|
||||
ospf_flush2_lsa(p, &ifa->link_lsa);
|
||||
ospf_flush2_lsa(p, &ifa->net_lsa);
|
||||
@ -396,15 +396,15 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
|
||||
{
|
||||
ospf_iface_chstate(ifa, OSPF_IS_WAITING);
|
||||
if (ifa->wait_timer)
|
||||
tm2_start(ifa->wait_timer, ifa->waitint S);
|
||||
tm_start(ifa->wait_timer, ifa->waitint S);
|
||||
}
|
||||
}
|
||||
|
||||
if (ifa->hello_timer)
|
||||
tm2_start(ifa->hello_timer, ifa->helloint S);
|
||||
tm_start(ifa->hello_timer, ifa->helloint S);
|
||||
|
||||
if (ifa->poll_timer)
|
||||
tm2_start(ifa->poll_timer, ifa->pollint S);
|
||||
tm_start(ifa->poll_timer, ifa->pollint S);
|
||||
|
||||
ospf_send_hello(ifa, OHS_HELLO, NULL);
|
||||
}
|
||||
@ -494,13 +494,13 @@ ospf_iface_add(struct object_lock *lock)
|
||||
|
||||
if (! ifa->stub)
|
||||
{
|
||||
ifa->hello_timer = tm2_new_init(ifa->pool, hello_timer_hook, ifa, ifa->helloint S, 0);
|
||||
ifa->hello_timer = tm_new_init(ifa->pool, hello_timer_hook, ifa, ifa->helloint S, 0);
|
||||
|
||||
if (ifa->type == OSPF_IT_NBMA)
|
||||
ifa->poll_timer = tm2_new_init(ifa->pool, poll_timer_hook, ifa, ifa->pollint S, 0);
|
||||
ifa->poll_timer = tm_new_init(ifa->pool, poll_timer_hook, ifa, ifa->pollint S, 0);
|
||||
|
||||
if ((ifa->type == OSPF_IT_BCAST) || (ifa->type == OSPF_IT_NBMA))
|
||||
ifa->wait_timer = tm2_new_init(ifa->pool, wait_timer_hook, ifa, 0, 0);
|
||||
ifa->wait_timer = tm_new_init(ifa->pool, wait_timer_hook, ifa, 0, 0);
|
||||
|
||||
ifa->flood_queue_size = ifa_flood_queue_size(ifa);
|
||||
ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *));
|
||||
@ -703,7 +703,7 @@ ospf_iface_new_vlink(struct ospf_proto *p, struct ospf_iface_patt *ip)
|
||||
|
||||
add_tail(&p->iface_list, NODE ifa);
|
||||
|
||||
ifa->hello_timer = tm2_new_init(ifa->pool, hello_timer_hook, ifa, ifa->helloint S, 0);
|
||||
ifa->hello_timer = tm_new_init(ifa->pool, hello_timer_hook, ifa, ifa->helloint S, 0);
|
||||
|
||||
ifa->flood_queue_size = ifa_flood_queue_size(ifa);
|
||||
ifa->flood_queue = mb_allocz(ifa->pool, ifa->flood_queue_size * sizeof(void *));
|
||||
@ -717,8 +717,8 @@ ospf_iface_change_timer(timer *tm, uint val)
|
||||
|
||||
tm->recurrent = val S;
|
||||
|
||||
if (tm2_active(tm))
|
||||
tm2_start(tm, val S);
|
||||
if (tm_active(tm))
|
||||
tm_start(tm, val S);
|
||||
}
|
||||
|
||||
static inline void
|
||||
@ -801,8 +801,8 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
|
||||
ifname, ifa->waitint, new->waitint);
|
||||
|
||||
ifa->waitint = new->waitint;
|
||||
if (ifa->wait_timer && tm2_active(ifa->wait_timer))
|
||||
tm2_start(ifa->wait_timer, ifa->waitint S);
|
||||
if (ifa->wait_timer && tm_active(ifa->wait_timer))
|
||||
tm_start(ifa->wait_timer, ifa->waitint S);
|
||||
}
|
||||
|
||||
/* DEAD TIMER */
|
||||
|
@ -115,7 +115,7 @@ ospf_lsa_lsrq_down(struct top_hash_entry *req, struct ospf_neighbor *n)
|
||||
|
||||
if (EMPTY_SLIST(n->lsrql))
|
||||
{
|
||||
tm2_stop(n->lsrq_timer);
|
||||
tm_stop(n->lsrq_timer);
|
||||
|
||||
if (n->state == NEIGHBOR_LOADING)
|
||||
ospf_neigh_sm(n, INM_LOADDONE);
|
||||
@ -136,8 +136,8 @@ ospf_lsa_lsrt_up(struct top_hash_entry *en, struct ospf_neighbor *n)
|
||||
ret->lsa = en->lsa;
|
||||
ret->lsa_body = LSA_BODY_DUMMY;
|
||||
|
||||
if (!tm2_active(n->lsrt_timer))
|
||||
tm2_start(n->lsrt_timer, n->ifa->rxmtint S);
|
||||
if (!tm_active(n->lsrt_timer))
|
||||
tm_start(n->lsrt_timer, n->ifa->rxmtint S);
|
||||
}
|
||||
|
||||
void
|
||||
@ -150,7 +150,7 @@ ospf_lsa_lsrt_down_(struct top_hash_entry *en, struct ospf_neighbor *n, struct t
|
||||
ospf_hash_delete(n->lsrth, ret);
|
||||
|
||||
if (EMPTY_SLIST(n->lsrtl))
|
||||
tm2_stop(n->lsrt_timer);
|
||||
tm_stop(n->lsrt_timer);
|
||||
}
|
||||
|
||||
static inline int
|
||||
@ -175,8 +175,8 @@ ospf_add_flushed_to_lsrt(struct ospf_proto *p, struct ospf_neighbor *n)
|
||||
ospf_lsa_lsrt_up(en, n);
|
||||
|
||||
/* If we found any flushed LSA, we send them ASAP */
|
||||
if (tm2_active(n->lsrt_timer))
|
||||
tm2_start(n->lsrt_timer, 0);
|
||||
if (tm_active(n->lsrt_timer))
|
||||
tm_start(n->lsrt_timer, 0);
|
||||
}
|
||||
|
||||
static int ospf_flood_lsupd(struct ospf_proto *p, struct top_hash_entry **lsa_list, uint lsa_count, uint lsa_min_count, struct ospf_iface *ifa);
|
||||
@ -700,7 +700,7 @@ ospf_receive_lsupd(struct ospf_packet *pkt, struct ospf_iface *ifa,
|
||||
if (!EMPTY_SLIST(n->lsrql) && (n->lsrqi == SHEAD(n->lsrql)))
|
||||
{
|
||||
ospf_send_lsreq(p, n);
|
||||
tm2_start(n->lsrq_timer, n->ifa->rxmtint S);
|
||||
tm_start(n->lsrq_timer, n->ifa->rxmtint S);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -66,10 +66,10 @@ reset_lists(struct ospf_proto *p, struct ospf_neighbor *n)
|
||||
ospf_top_free(n->lsrth);
|
||||
ospf_reset_lsack_queue(n);
|
||||
|
||||
tm2_stop(n->dbdes_timer);
|
||||
tm2_stop(n->lsrq_timer);
|
||||
tm2_stop(n->lsrt_timer);
|
||||
tm2_stop(n->ackd_timer);
|
||||
tm_stop(n->dbdes_timer);
|
||||
tm_stop(n->lsrq_timer);
|
||||
tm_stop(n->lsrt_timer);
|
||||
tm_stop(n->ackd_timer);
|
||||
|
||||
init_lists(p, n);
|
||||
}
|
||||
@ -94,11 +94,11 @@ ospf_neighbor_new(struct ospf_iface *ifa)
|
||||
init_list(&n->ackl[ACKL_DIRECT]);
|
||||
init_list(&n->ackl[ACKL_DELAY]);
|
||||
|
||||
n->inactim = tm2_new_init(pool, inactivity_timer_hook, n, 0, 0);
|
||||
n->dbdes_timer = tm2_new_init(pool, dbdes_timer_hook, n, ifa->rxmtint S, 0);
|
||||
n->lsrq_timer = tm2_new_init(pool, lsrq_timer_hook, n, ifa->rxmtint S, 0);
|
||||
n->lsrt_timer = tm2_new_init(pool, lsrt_timer_hook, n, ifa->rxmtint S, 0);
|
||||
n->ackd_timer = tm2_new_init(pool, ackd_timer_hook, n, ifa->rxmtint S / 2, 0);
|
||||
n->inactim = tm_new_init(pool, inactivity_timer_hook, n, 0, 0);
|
||||
n->dbdes_timer = tm_new_init(pool, dbdes_timer_hook, n, ifa->rxmtint S, 0);
|
||||
n->lsrq_timer = tm_new_init(pool, lsrq_timer_hook, n, ifa->rxmtint S, 0);
|
||||
n->lsrt_timer = tm_new_init(pool, lsrt_timer_hook, n, ifa->rxmtint S, 0);
|
||||
n->ackd_timer = tm_new_init(pool, ackd_timer_hook, n, ifa->rxmtint S / 2, 0);
|
||||
|
||||
return (n);
|
||||
}
|
||||
@ -185,8 +185,8 @@ ospf_neigh_chstate(struct ospf_neighbor *n, u8 state)
|
||||
n->dds++;
|
||||
n->myimms = DBDES_IMMS;
|
||||
|
||||
tm2_start(n->dbdes_timer, 0);
|
||||
tm2_start(n->ackd_timer, ifa->rxmtint S / 2);
|
||||
tm_start(n->dbdes_timer, 0);
|
||||
tm_start(n->ackd_timer, ifa->rxmtint S / 2);
|
||||
}
|
||||
|
||||
if (state > NEIGHBOR_EXSTART)
|
||||
@ -231,7 +231,7 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
|
||||
ospf_neigh_chstate(n, NEIGHBOR_INIT);
|
||||
|
||||
/* Restart inactivity timer */
|
||||
tm2_start(n->inactim, n->ifa->deadint S);
|
||||
tm_start(n->inactim, n->ifa->deadint S);
|
||||
break;
|
||||
|
||||
case INM_2WAYREC:
|
||||
@ -664,5 +664,5 @@ ospf_sh_neigh_info(struct ospf_neighbor *n)
|
||||
|
||||
cli_msg(-1013, "%-1R\t%3u\t%s/%s\t%7t\t%-10s %-1I",
|
||||
n->rid, n->priority, ospf_ns_names[n->state], pos,
|
||||
tm2_remains(n->inactim), ifa->ifname, n->ip);
|
||||
tm_remains(n->inactim), ifa->ifname, n->ip);
|
||||
}
|
||||
|
@ -241,8 +241,8 @@ ospf_start(struct proto *P)
|
||||
p->asbr = c->asbr;
|
||||
p->ecmp = c->ecmp;
|
||||
p->tick = c->tick;
|
||||
p->disp_timer = tm2_new_init(P->pool, ospf_disp, p, p->tick S, 0);
|
||||
tm2_start(p->disp_timer, 100 MS);
|
||||
p->disp_timer = tm_new_init(P->pool, ospf_disp, p, p->tick S, 0);
|
||||
tm_start(p->disp_timer, 100 MS);
|
||||
p->lsab_size = 256;
|
||||
p->lsab_used = 0;
|
||||
p->lsab = mb_alloc(P->pool, p->lsab_size);
|
||||
@ -677,7 +677,7 @@ ospf_reconfigure(struct proto *P, struct proto_config *CF)
|
||||
p->ecmp = new->ecmp;
|
||||
p->tick = new->tick;
|
||||
p->disp_timer->recurrent = p->tick S;
|
||||
tm2_start(p->disp_timer, 100 MS);
|
||||
tm_start(p->disp_timer, 100 MS);
|
||||
|
||||
/* Mark all areas and ifaces */
|
||||
WALK_LIST(oa, p->area_list)
|
||||
|
@ -18,7 +18,7 @@
|
||||
#include "lib/lists.h"
|
||||
#include "lib/slists.h"
|
||||
#include "lib/socket.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "lib/timer.h"
|
||||
#include "lib/resource.h"
|
||||
#include "nest/protocol.h"
|
||||
#include "nest/iface.h"
|
||||
|
@ -1321,7 +1321,7 @@ ospf_rt_abr2(struct ospf_proto *p)
|
||||
if (translate && (oa->translate != TRANS_ON))
|
||||
{
|
||||
if (oa->translate == TRANS_WAIT)
|
||||
tm2_stop(oa->translator_timer);
|
||||
tm_stop(oa->translator_timer);
|
||||
|
||||
oa->translate = TRANS_ON;
|
||||
}
|
||||
@ -1329,10 +1329,10 @@ ospf_rt_abr2(struct ospf_proto *p)
|
||||
if (!translate && (oa->translate == TRANS_ON))
|
||||
{
|
||||
if (oa->translator_timer == NULL)
|
||||
oa->translator_timer = tm2_new_init(p->p.pool, translator_timer_hook, oa, 0, 0);
|
||||
oa->translator_timer = tm_new_init(p->p.pool, translator_timer_hook, oa, 0, 0);
|
||||
|
||||
/* Schedule the end of translation */
|
||||
tm2_start(oa->translator_timer, oa->ac->transint S);
|
||||
tm_start(oa->translator_timer, oa->ac->transint S);
|
||||
oa->translate = TRANS_WAIT;
|
||||
}
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ radv_timer(timer *tm)
|
||||
ifa->initial--;
|
||||
}
|
||||
|
||||
tm2_start(ifa->timer, t);
|
||||
tm_start(ifa->timer, t);
|
||||
}
|
||||
|
||||
static char* ev_name[] = { NULL, "Init", "Change", "RS" };
|
||||
@ -94,7 +94,7 @@ radv_iface_notify(struct radv_iface *ifa, int event)
|
||||
|
||||
/* Update timer */
|
||||
btime t = ifa->last + ifa->cf->min_delay S - current_time();
|
||||
tm2_start(ifa->timer, t);
|
||||
tm_start(ifa->timer, t);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -150,7 +150,7 @@ radv_iface_new(struct radv_proto *p, struct iface *iface, struct radv_iface_conf
|
||||
|
||||
add_tail(&p->iface_list, NODE ifa);
|
||||
|
||||
ifa->timer = tm2_new_init(pool, radv_timer, ifa, 0, 0);
|
||||
ifa->timer = tm_new_init(pool, radv_timer, ifa, 0, 0);
|
||||
|
||||
struct object_lock *lock = olock_new(pool);
|
||||
lock->addr = IPA_NONE;
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "lib/ip.h"
|
||||
#include "lib/lists.h"
|
||||
#include "lib/socket.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "lib/timer.h"
|
||||
#include "lib/resource.h"
|
||||
#include "nest/protocol.h"
|
||||
#include "nest/iface.h"
|
||||
|
@ -509,7 +509,7 @@ rip_iface_start(struct rip_iface *ifa)
|
||||
ifa->next_regular = current_time() + (random() % ifa->cf->update_time) + 100 MS;
|
||||
ifa->next_triggered = current_time(); /* Available immediately */
|
||||
ifa->want_triggered = 1; /* All routes in triggered update */
|
||||
tm2_start(ifa->timer, 100 MS);
|
||||
tm_start(ifa->timer, 100 MS);
|
||||
ifa->up = 1;
|
||||
|
||||
if (!ifa->cf->passive)
|
||||
@ -529,7 +529,7 @@ rip_iface_stop(struct rip_iface *ifa)
|
||||
WALK_LIST_FIRST(n, ifa->neigh_list)
|
||||
rip_remove_neighbor(p, n);
|
||||
|
||||
tm2_stop(ifa->timer);
|
||||
tm_stop(ifa->timer);
|
||||
ifa->up = 0;
|
||||
}
|
||||
|
||||
@ -642,7 +642,7 @@ rip_add_iface(struct rip_proto *p, struct iface *iface, struct rip_iface_config
|
||||
|
||||
add_tail(&p->iface_list, NODE ifa);
|
||||
|
||||
ifa->timer = tm2_new_init(p->p.pool, rip_iface_timer, ifa, 0, 0);
|
||||
ifa->timer = tm_new_init(p->p.pool, rip_iface_timer, ifa, 0, 0);
|
||||
|
||||
struct object_lock *lock = olock_new(p->p.pool);
|
||||
lock->type = OBJLOCK_UDP;
|
||||
@ -897,14 +897,14 @@ rip_timer(timer *t)
|
||||
next = MIN(next, expires);
|
||||
}
|
||||
|
||||
tm2_start(p->timer, MAX(next - now_, 100 MS));
|
||||
tm_start(p->timer, MAX(next - now_, 100 MS));
|
||||
}
|
||||
|
||||
static inline void
|
||||
rip_kick_timer(struct rip_proto *p)
|
||||
{
|
||||
if (p->timer->expires > (current_time() + 100 MS))
|
||||
tm2_start(p->timer, 100 MS);
|
||||
tm_start(p->timer, 100 MS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -933,7 +933,7 @@ rip_iface_timer(timer *t)
|
||||
if (ifa->tx_active)
|
||||
{
|
||||
if (now_ < (ifa->next_regular + period))
|
||||
{ tm2_start(ifa->timer, 100 MS); return; }
|
||||
{ tm_start(ifa->timer, 100 MS); return; }
|
||||
|
||||
/* We are too late, reset is done by rip_send_table() */
|
||||
log(L_WARN "%s: Too slow update on %s, resetting", p->p.name, ifa->iface->name);
|
||||
@ -958,14 +958,14 @@ rip_iface_timer(timer *t)
|
||||
p->triggered = 0;
|
||||
}
|
||||
|
||||
tm2_start(ifa->timer, ifa->want_triggered ? (1 S) : (ifa->next_regular - now_));
|
||||
tm_start(ifa->timer, ifa->want_triggered ? (1 S) : (ifa->next_regular - now_));
|
||||
}
|
||||
|
||||
static inline void
|
||||
rip_iface_kick_timer(struct rip_iface *ifa)
|
||||
{
|
||||
if (ifa->timer->expires > (current_time() + 100 MS))
|
||||
tm2_start(ifa->timer, 100 MS);
|
||||
tm_start(ifa->timer, 100 MS);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1111,7 +1111,7 @@ rip_start(struct proto *P)
|
||||
fib_init(&p->rtable, P->pool, cf->rip2 ? NET_IP4 : NET_IP6,
|
||||
sizeof(struct rip_entry), OFFSETOF(struct rip_entry, n), 0, NULL);
|
||||
p->rte_slab = sl_new(P->pool, sizeof(struct rip_rte));
|
||||
p->timer = tm2_new_init(P->pool, rip_timer, p, 0, 0);
|
||||
p->timer = tm_new_init(P->pool, rip_timer, p, 0, 0);
|
||||
|
||||
p->rip2 = cf->rip2;
|
||||
p->ecmp = cf->ecmp;
|
||||
@ -1121,7 +1121,7 @@ rip_start(struct proto *P)
|
||||
p->log_pkt_tbf = (struct tbf){ .rate = 1, .burst = 5 };
|
||||
p->log_rte_tbf = (struct tbf){ .rate = 4, .burst = 20 };
|
||||
|
||||
tm2_start(p->timer, MIN(cf->min_timeout_time, cf->max_garbage_time));
|
||||
tm_start(p->timer, MIN(cf->min_timeout_time, cf->max_garbage_time));
|
||||
|
||||
return PS_UP;
|
||||
}
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "lib/resource.h"
|
||||
#include "lib/socket.h"
|
||||
#include "lib/string.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "lib/timer.h"
|
||||
|
||||
|
||||
#define RIP_V1 1
|
||||
|
@ -321,7 +321,7 @@ rpki_schedule_next_refresh(struct rpki_cache *cache)
|
||||
btime t = cache->refresh_interval S;
|
||||
|
||||
CACHE_DBG(cache, "after %t s", t);
|
||||
tm2_start(cache->refresh_timer, t);
|
||||
tm_start(cache->refresh_timer, t);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -330,7 +330,7 @@ rpki_schedule_next_retry(struct rpki_cache *cache)
|
||||
btime t = cache->retry_interval S;
|
||||
|
||||
CACHE_DBG(cache, "after %t s", t);
|
||||
tm2_start(cache->retry_timer, t);
|
||||
tm_start(cache->retry_timer, t);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -341,28 +341,28 @@ rpki_schedule_next_expire_check(struct rpki_cache *cache)
|
||||
t = MAX(t, 1 S);
|
||||
|
||||
CACHE_DBG(cache, "after %t s", t);
|
||||
tm2_start(cache->expire_timer, t);
|
||||
tm_start(cache->expire_timer, t);
|
||||
}
|
||||
|
||||
static void
|
||||
rpki_stop_refresh_timer_event(struct rpki_cache *cache)
|
||||
{
|
||||
CACHE_DBG(cache, "Stop");
|
||||
tm2_stop(cache->refresh_timer);
|
||||
tm_stop(cache->refresh_timer);
|
||||
}
|
||||
|
||||
static void
|
||||
rpki_stop_retry_timer_event(struct rpki_cache *cache)
|
||||
{
|
||||
CACHE_DBG(cache, "Stop");
|
||||
tm2_stop(cache->retry_timer);
|
||||
tm_stop(cache->retry_timer);
|
||||
}
|
||||
|
||||
static void UNUSED
|
||||
rpki_stop_expire_timer_event(struct rpki_cache *cache)
|
||||
{
|
||||
CACHE_DBG(cache, "Stop");
|
||||
tm2_stop(cache->expire_timer);
|
||||
tm_stop(cache->expire_timer);
|
||||
}
|
||||
|
||||
static int
|
||||
@ -569,9 +569,9 @@ rpki_init_cache(struct rpki_proto *p, struct rpki_config *cf)
|
||||
cache->refresh_interval = cf->refresh_interval;
|
||||
cache->retry_interval = cf->retry_interval;
|
||||
cache->expire_interval = cf->expire_interval;
|
||||
cache->refresh_timer = tm2_new_init(pool, &rpki_refresh_hook, cache, 0, 0);
|
||||
cache->retry_timer = tm2_new_init(pool, &rpki_retry_hook, cache, 0, 0);
|
||||
cache->expire_timer = tm2_new_init(pool, &rpki_expire_hook, cache, 0, 0);
|
||||
cache->refresh_timer = tm_new_init(pool, &rpki_refresh_hook, cache, 0, 0);
|
||||
cache->retry_timer = tm_new_init(pool, &rpki_retry_hook, cache, 0, 0);
|
||||
cache->expire_timer = tm_new_init(pool, &rpki_expire_hook, cache, 0, 0);
|
||||
|
||||
cache->tr_sock = mb_allocz(pool, sizeof(struct rpki_tr_sock));
|
||||
cache->tr_sock->cache = cache;
|
||||
@ -791,8 +791,8 @@ rpki_get_status(struct proto *P, byte *buf)
|
||||
static void
|
||||
rpki_show_proto_info_timer(const char *name, uint num, timer *t)
|
||||
{
|
||||
if (tm2_active(t))
|
||||
cli_msg(-1006, " %-16s: %t/%u", name, tm2_remains(t), num);
|
||||
if (tm_active(t))
|
||||
cli_msg(-1006, " %-16s: %t/%u", name, tm_remains(t), num);
|
||||
else
|
||||
cli_msg(-1006, " %-16s: ---", name);
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
#include "nest/protocol.h"
|
||||
#include "nest/iface.h"
|
||||
#include "lib/alloca.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "sysdep/unix/unix.h"
|
||||
#include "sysdep/unix/krt.h"
|
||||
#include "lib/socket.h"
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "nest/bird.h"
|
||||
#include "lib/lists.h"
|
||||
#include "lib/resource.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "lib/socket.h"
|
||||
#include "lib/event.h"
|
||||
#include "lib/timer.h"
|
||||
@ -2143,7 +2142,7 @@ io_loop(void)
|
||||
{
|
||||
int poll_tout, timeout;
|
||||
int nfds, events, pout;
|
||||
timer2 *t;
|
||||
timer *t;
|
||||
sock *s;
|
||||
node *n;
|
||||
int fdmax = 256;
|
||||
@ -2162,7 +2161,7 @@ io_loop(void)
|
||||
if (t = timers_first(&main_timeloop))
|
||||
{
|
||||
times_update(&main_timeloop);
|
||||
timeout = (tm2_remains(t) TO_MS) + 1;
|
||||
timeout = (tm_remains(t) TO_MS) + 1;
|
||||
poll_tout = MIN(poll_tout, timeout);
|
||||
}
|
||||
|
||||
|
@ -56,9 +56,9 @@
|
||||
#include "nest/route.h"
|
||||
#include "nest/protocol.h"
|
||||
#include "filter/filter.h"
|
||||
#include "sysdep/unix/timer.h"
|
||||
#include "conf/conf.h"
|
||||
#include "lib/string.h"
|
||||
#include "lib/timer.h"
|
||||
|
||||
#include "unix.h"
|
||||
#include "krt.h"
|
||||
@ -115,7 +115,7 @@ kif_force_scan(void)
|
||||
if (kif_proto && ((kif_last_shot + 2 S) < current_time()))
|
||||
{
|
||||
kif_scan(kif_scan_timer);
|
||||
tm2_start(kif_scan_timer, ((struct kif_config *) kif_proto->p.cf)->scan_time);
|
||||
tm_start(kif_scan_timer, ((struct kif_config *) kif_proto->p.cf)->scan_time);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ void
|
||||
kif_request_scan(void)
|
||||
{
|
||||
if (kif_proto && (kif_scan_timer->expires > (current_time() + 1 S)))
|
||||
tm2_start(kif_scan_timer, 1 S);
|
||||
tm_start(kif_scan_timer, 1 S);
|
||||
}
|
||||
|
||||
static struct proto *
|
||||
@ -144,9 +144,9 @@ kif_start(struct proto *P)
|
||||
kif_sys_start(p);
|
||||
|
||||
/* Start periodic interface scanning */
|
||||
kif_scan_timer = tm2_new_init(P->pool, kif_scan, p, KIF_CF->scan_time, 0);
|
||||
kif_scan_timer = tm_new_init(P->pool, kif_scan, p, KIF_CF->scan_time, 0);
|
||||
kif_scan(kif_scan_timer);
|
||||
tm2_start(kif_scan_timer, KIF_CF->scan_time);
|
||||
tm_start(kif_scan_timer, KIF_CF->scan_time);
|
||||
|
||||
return PS_UP;
|
||||
}
|
||||
@ -156,7 +156,7 @@ kif_shutdown(struct proto *P)
|
||||
{
|
||||
struct kif_proto *p = (struct kif_proto *) P;
|
||||
|
||||
tm2_stop(kif_scan_timer);
|
||||
tm_stop(kif_scan_timer);
|
||||
kif_sys_shutdown(p);
|
||||
kif_proto = NULL;
|
||||
|
||||
@ -174,10 +174,10 @@ kif_reconfigure(struct proto *p, struct proto_config *new)
|
||||
|
||||
if (o->scan_time != n->scan_time)
|
||||
{
|
||||
tm2_stop(kif_scan_timer);
|
||||
tm_stop(kif_scan_timer);
|
||||
kif_scan_timer->recurrent = n->scan_time;
|
||||
kif_scan(kif_scan_timer);
|
||||
tm2_start(kif_scan_timer, n->scan_time);
|
||||
tm_start(kif_scan_timer, n->scan_time);
|
||||
}
|
||||
|
||||
if (!EMPTY_LIST(o->iface_list) || !EMPTY_LIST(n->iface_list))
|
||||
@ -840,11 +840,11 @@ static void
|
||||
krt_scan_timer_start(struct krt_proto *p)
|
||||
{
|
||||
if (!krt_scan_count)
|
||||
krt_scan_timer = tm2_new_init(krt_pool, krt_scan, NULL, KRT_CF->scan_time, 0);
|
||||
krt_scan_timer = tm_new_init(krt_pool, krt_scan, NULL, KRT_CF->scan_time, 0);
|
||||
|
||||
krt_scan_count++;
|
||||
|
||||
tm2_start(krt_scan_timer, 1 S);
|
||||
tm_start(krt_scan_timer, 1 S);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -862,7 +862,7 @@ krt_scan_timer_stop(struct krt_proto *p UNUSED)
|
||||
static void
|
||||
krt_scan_timer_kick(struct krt_proto *p UNUSED)
|
||||
{
|
||||
tm2_start(krt_scan_timer, 0);
|
||||
tm_start(krt_scan_timer, 0);
|
||||
}
|
||||
|
||||
#else
|
||||
@ -882,20 +882,20 @@ krt_scan(timer *t)
|
||||
static void
|
||||
krt_scan_timer_start(struct krt_proto *p)
|
||||
{
|
||||
p->scan_timer = tm2_new_init(p->p.pool, krt_scan, p, KRT_CF->scan_time, 0);
|
||||
tm2_start(p->scan_timer, 1 S);
|
||||
p->scan_timer = tm_new_init(p->p.pool, krt_scan, p, KRT_CF->scan_time, 0);
|
||||
tm_start(p->scan_timer, 1 S);
|
||||
}
|
||||
|
||||
static void
|
||||
krt_scan_timer_stop(struct krt_proto *p)
|
||||
{
|
||||
tm2_stop(p->scan_timer);
|
||||
tm_stop(p->scan_timer);
|
||||
}
|
||||
|
||||
static void
|
||||
krt_scan_timer_kick(struct krt_proto *p)
|
||||
{
|
||||
tm2_start(p->scan_timer, 0);
|
||||
tm_start(p->scan_timer, 0);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -1,51 +0,0 @@
|
||||
/*
|
||||
* BIRD -- Unix Timers
|
||||
*
|
||||
* (c) 1998 Martin Mares <mj@ucw.cz>
|
||||
*
|
||||
* Can be freely distributed and used under the terms of the GNU GPL.
|
||||
*/
|
||||
|
||||
#ifndef _BIRD_TIMER_H_
|
||||
#define _BIRD_TIMER_H_
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include "lib/birdlib.h"
|
||||
#include "lib/timer.h"
|
||||
|
||||
|
||||
typedef struct timer2 timer;
|
||||
#if 0
|
||||
static inline timer *tm_new(pool *p)
|
||||
{ return (void *) tm2_new(p); }
|
||||
|
||||
static inline void tm_start(timer *t, bird_clock_t after)
|
||||
{ tm2_start(t, after S_); }
|
||||
|
||||
static inline void tm_stop(timer *t)
|
||||
{ tm2_stop(t); }
|
||||
|
||||
// void tm_dump_all(void);
|
||||
|
||||
//extern bird_clock_t now; /* Relative, monotonic time in seconds */
|
||||
//extern bird_clock_t now_real; /* Time in seconds since fixed known epoch */
|
||||
//extern bird_clock_t boot_time;
|
||||
|
||||
static inline int tm_active(timer *t)
|
||||
{ return tm2_active(t); }
|
||||
|
||||
static inline bird_clock_t tm_remains(timer *t)
|
||||
{ return tm2_remains(t) TO_S; }
|
||||
|
||||
static inline void tm_start_max(timer *t, bird_clock_t after)
|
||||
{ tm2_start_max(t, after S_); }
|
||||
|
||||
static inline timer * tm_new_set(pool *p, void (*hook)(timer *), void *data, uint rand, uint rec)
|
||||
{ return tm2_new_init(p, hook, data, rec S_, rand S_); }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user