]> git.ipfire.org Git - thirdparty/bird.git/commitdiff
RAdv: Update to new timers
authorOndrej Zajicek (work) <santiago@crfreenet.org>
Wed, 14 Jun 2017 15:02:11 +0000 (17:02 +0200)
committerOndrej Zajicek (work) <santiago@crfreenet.org>
Thu, 7 Dec 2017 12:53:42 +0000 (13:53 +0100)
proto/radv/radv.c
proto/radv/radv.h

index 34a3f4734bead07d36262e338dbde279f9aa2071..978d209199820e4f68cfd2ba5bb0a5e6dcea4573 100644 (file)
@@ -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;
index 35eea9ba538e5f7c51e54dfc4a7cd26005f2b013..a4429c60eb9ac975003c7c37dad9b3ad5ce0514c 100644 (file)
@@ -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 */
 };