From 21f4f0f4b0785e30ce2af4741ffa6f2ebdd7d714 Mon Sep 17 00:00:00 2001 From: "Ondrej Zajicek (work)" Date: Wed, 14 Jun 2017 13:15:35 +0200 Subject: [PATCH] Kernel: Update to new timers --- sysdep/unix/krt.Y | 4 ++-- sysdep/unix/krt.c | 45 +++++++++++++++++++++------------------------ sysdep/unix/krt.h | 4 ++-- 3 files changed, 25 insertions(+), 28 deletions(-) diff --git a/sysdep/unix/krt.Y b/sysdep/unix/krt.Y index 3bf7da65..6d90db64 100644 --- a/sysdep/unix/krt.Y +++ b/sysdep/unix/krt.Y @@ -68,7 +68,7 @@ kern_item: | PERSIST bool { THIS_KRT->persist = $2; } | SCAN TIME expr { /* Scan time of 0 means scan on startup only */ - THIS_KRT->scan_time = $3; + THIS_KRT->scan_time = $3 S_; } | LEARN bool { THIS_KRT->learn = $2; @@ -103,7 +103,7 @@ kif_item: | INTERFACE kif_iface | SCAN TIME expr { /* Scan time of 0 means scan on startup only */ - THIS_KIF->scan_time = $3; + THIS_KIF->scan_time = $3 S_; } ; diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index a5ec8a39..5b1c40f0 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -87,7 +87,7 @@ krt_io_init(void) struct kif_proto *kif_proto; static struct kif_config *kif_cf; static timer *kif_scan_timer; -static bird_clock_t kif_last_shot; +static btime kif_last_shot; static struct kif_iface_config kif_default_iface = {}; @@ -105,25 +105,25 @@ kif_scan(timer *t) struct kif_proto *p = t->data; KRT_TRACE(p, D_EVENTS, "Scanning interfaces"); - kif_last_shot = now; + kif_last_shot = current_time(); kif_do_scan(p); } static void kif_force_scan(void) { - if (kif_proto && kif_last_shot + 2 < now) + if (kif_proto && ((kif_last_shot + 2 S) < current_time())) { kif_scan(kif_scan_timer); - tm_start(kif_scan_timer, ((struct kif_config *) kif_proto->p.cf)->scan_time); + tm2_start(kif_scan_timer, ((struct kif_config *) kif_proto->p.cf)->scan_time); } } void kif_request_scan(void) { - if (kif_proto && (kif_scan_timer->expires TO_S > (now + 1))) - tm_start(kif_scan_timer, 1); + if (kif_proto && (kif_scan_timer->expires > (current_time() + 1 S))) + tm2_start(kif_scan_timer, 1 S); } static struct proto * @@ -144,12 +144,9 @@ kif_start(struct proto *P) kif_sys_start(p); /* Start periodic interface scanning */ - kif_scan_timer = tm_new(P->pool); - kif_scan_timer->hook = kif_scan; - kif_scan_timer->data = p; - kif_scan_timer->recurrent = KIF_CF->scan_time S; + kif_scan_timer = tm2_new_init(P->pool, kif_scan, p, KIF_CF->scan_time, 0); kif_scan(kif_scan_timer); - tm_start(kif_scan_timer, KIF_CF->scan_time); + tm2_start(kif_scan_timer, KIF_CF->scan_time); return PS_UP; } @@ -159,7 +156,7 @@ kif_shutdown(struct proto *P) { struct kif_proto *p = (struct kif_proto *) P; - tm_stop(kif_scan_timer); + tm2_stop(kif_scan_timer); kif_sys_shutdown(p); kif_proto = NULL; @@ -177,10 +174,10 @@ kif_reconfigure(struct proto *p, struct proto_config *new) if (o->scan_time != n->scan_time) { - tm_stop(kif_scan_timer); - kif_scan_timer->recurrent = n->scan_time S; + tm2_stop(kif_scan_timer); + kif_scan_timer->recurrent = n->scan_time; kif_scan(kif_scan_timer); - tm_start(kif_scan_timer, n->scan_time); + tm2_start(kif_scan_timer, n->scan_time); } if (!EMPTY_LIST(o->iface_list) || !EMPTY_LIST(n->iface_list)) @@ -212,7 +209,7 @@ kif_init_config(int class) cf_error("Kernel device protocol already defined"); kif_cf = (struct kif_config *) proto_config_new(&proto_unix_iface, class); - kif_cf->scan_time = 60; + kif_cf->scan_time = 60 S; init_list(&kif_cf->iface_list); kif_sys_init_config(kif_cf); @@ -843,11 +840,11 @@ static void krt_scan_timer_start(struct krt_proto *p) { if (!krt_scan_count) - krt_scan_timer = tm_new_set(krt_pool, krt_scan, NULL, 0, KRT_CF->scan_time); + krt_scan_timer = tm2_new_init(krt_pool, krt_scan, NULL, KRT_CF->scan_time, 0); krt_scan_count++; - tm_start(krt_scan_timer, 1); + tm2_start(krt_scan_timer, 1 S); } static void @@ -865,7 +862,7 @@ krt_scan_timer_stop(struct krt_proto *p UNUSED) static void krt_scan_timer_kick(struct krt_proto *p UNUSED) { - tm_start(krt_scan_timer, 0); + tm2_start(krt_scan_timer, 0); } #else @@ -885,20 +882,20 @@ krt_scan(timer *t) static void krt_scan_timer_start(struct krt_proto *p) { - p->scan_timer = tm_new_set(p->p.pool, krt_scan, p, 0, KRT_CF->scan_time); - tm_start(p->scan_timer, 1); + p->scan_timer = tm2_new_init(p->p.pool, krt_scan, p, KRT_CF->scan_time, 0); + tm2_start(p->scan_timer, 1 S); } static void krt_scan_timer_stop(struct krt_proto *p) { - tm_stop(p->scan_timer); + tm2_stop(p->scan_timer); } static void krt_scan_timer_kick(struct krt_proto *p) { - tm_start(p->scan_timer, 0); + tm2_start(p->scan_timer, 0); } #endif @@ -1174,7 +1171,7 @@ krt_init_config(int class) #endif krt_cf = (struct krt_config *) proto_config_new(&proto_unix_kernel, class); - krt_cf->scan_time = 60; + krt_cf->scan_time = 60 S; krt_sys_init_config(krt_cf); return (struct proto_config *) krt_cf; diff --git a/sysdep/unix/krt.h b/sysdep/unix/krt.h index 39e16a2a..eda83b91 100644 --- a/sysdep/unix/krt.h +++ b/sysdep/unix/krt.h @@ -46,8 +46,8 @@ extern struct protocol proto_unix_kernel; struct krt_config { struct proto_config c; struct krt_params sys; /* Sysdep params */ + btime scan_time; /* How often we re-scan routes */ int persist; /* Keep routes when we exit */ - int scan_time; /* How often we re-scan routes */ int learn; /* Learn routes from other sources */ int devroutes; /* Allow export of device routes */ int graceful_restart; /* Regard graceful restart recovery */ @@ -100,7 +100,7 @@ struct kif_config { struct kif_params sys; /* Sysdep params */ list iface_list; /* List of iface configs (struct kif_iface_config) */ - int scan_time; /* How often we re-scan interfaces */ + btime scan_time; /* How often we re-scan interfaces */ }; struct kif_iface_config {