summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-06-14 17:02:11 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-12-07 13:53:42 +0100
commitc521b3ac324e1c97b22581a06172dcb08fd740f6 (patch)
treecc91f5fe3770aa9d557953599a1d49ce27486d86 /proto
parentd59c1a295834aa5cc63aceb6769c8413fa0639fe (diff)
RAdv: Update to new timers
Diffstat (limited to 'proto')
-rw-r--r--proto/radv/radv.c26
-rw-r--r--proto/radv/radv.h4
2 files changed, 13 insertions, 17 deletions
diff --git a/proto/radv/radv.c b/proto/radv/radv.c
index 34a3f473..978d2091 100644
--- a/proto/radv/radv.c
+++ b/proto/radv/radv.c
@@ -54,17 +54,18 @@ radv_timer(timer *tm)
radv_send_ra(ifa, 0);
/* Update timer */
- ifa->last = now;
- unsigned after = ifa->cf->min_ra_int;
- after += random() % (ifa->cf->max_ra_int - ifa->cf->min_ra_int + 1);
+ ifa->last = current_time();
+ btime t = (btime) ifa->cf->min_ra_int S;
+ btime r = (btime) (ifa->cf->max_ra_int - ifa->cf->min_ra_int) S;
+ t += random() % (r + 1);
if (ifa->initial)
+ {
+ t = MIN(t, MAX_INITIAL_RTR_ADVERT_INTERVAL);
ifa->initial--;
+ }
- if (ifa->initial)
- after = MIN(after, MAX_INITIAL_RTR_ADVERT_INTERVAL);
-
- tm_start(ifa->timer, after);
+ tm2_start(ifa->timer, t);
}
static char* ev_name[] = { NULL, "Init", "Change", "RS" };
@@ -92,13 +93,8 @@ radv_iface_notify(struct radv_iface *ifa, int event)
}
/* Update timer */
- unsigned delta = now - ifa->last;
- unsigned after = 0;
-
- if (delta < ifa->cf->min_delay)
- after = ifa->cf->min_delay - delta;
-
- tm_start(ifa->timer, after);
+ btime t = ifa->last + (btime) ifa->cf->min_delay S - current_time();
+ tm2_start(ifa->timer, t);
}
static void
@@ -154,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 = tm_new_set(pool, radv_timer, ifa, 0, 0);
+ ifa->timer = tm2_new_init(pool, radv_timer, ifa, 0, 0);
struct object_lock *lock = olock_new(pool);
lock->addr = IPA_NONE;
diff --git a/proto/radv/radv.h b/proto/radv/radv.h
index 35eea9ba..a4429c60 100644
--- a/proto/radv/radv.h
+++ b/proto/radv/radv.h
@@ -30,7 +30,7 @@
#define ICMPV6_RA 134
#define MAX_INITIAL_RTR_ADVERTISEMENTS 3
-#define MAX_INITIAL_RTR_ADVERT_INTERVAL 16
+#define MAX_INITIAL_RTR_ADVERT_INTERVAL (16 S_)
#define DEFAULT_MAX_RA_INT 600
#define DEFAULT_MIN_DELAY 3
@@ -130,7 +130,7 @@ struct radv_iface
struct object_lock *lock;
sock *sk;
- bird_clock_t last; /* Time of last sending of RA */
+ btime last; /* Time of last sending of RA */
u16 plen; /* Length of prepared RA in tbuf, or 0 if not valid */
byte initial; /* List of active ifaces */
};