RAdv: Update to new timers

This commit is contained in:
Ondrej Zajicek (work) 2017-06-14 17:02:11 +02:00
parent d59c1a2958
commit c521b3ac32
2 changed files with 13 additions and 17 deletions

View file

@ -54,17 +54,18 @@ radv_timer(timer *tm)
radv_send_ra(ifa, 0); radv_send_ra(ifa, 0);
/* Update timer */ /* Update timer */
ifa->last = now; ifa->last = current_time();
unsigned after = ifa->cf->min_ra_int; btime t = (btime) ifa->cf->min_ra_int S;
after += random() % (ifa->cf->max_ra_int - ifa->cf->min_ra_int + 1); btime r = (btime) (ifa->cf->max_ra_int - ifa->cf->min_ra_int) S;
t += random() % (r + 1);
if (ifa->initial) if (ifa->initial)
{
t = MIN(t, MAX_INITIAL_RTR_ADVERT_INTERVAL);
ifa->initial--; ifa->initial--;
}
if (ifa->initial) tm2_start(ifa->timer, t);
after = MIN(after, MAX_INITIAL_RTR_ADVERT_INTERVAL);
tm_start(ifa->timer, after);
} }
static char* ev_name[] = { NULL, "Init", "Change", "RS" }; static char* ev_name[] = { NULL, "Init", "Change", "RS" };
@ -92,13 +93,8 @@ radv_iface_notify(struct radv_iface *ifa, int event)
} }
/* Update timer */ /* Update timer */
unsigned delta = now - ifa->last; btime t = ifa->last + (btime) ifa->cf->min_delay S - current_time();
unsigned after = 0; tm2_start(ifa->timer, t);
if (delta < ifa->cf->min_delay)
after = ifa->cf->min_delay - delta;
tm_start(ifa->timer, after);
} }
static void 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); 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); struct object_lock *lock = olock_new(pool);
lock->addr = IPA_NONE; lock->addr = IPA_NONE;

View file

@ -30,7 +30,7 @@
#define ICMPV6_RA 134 #define ICMPV6_RA 134
#define MAX_INITIAL_RTR_ADVERTISEMENTS 3 #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_MAX_RA_INT 600
#define DEFAULT_MIN_DELAY 3 #define DEFAULT_MIN_DELAY 3
@ -130,7 +130,7 @@ struct radv_iface
struct object_lock *lock; struct object_lock *lock;
sock *sk; 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 */ u16 plen; /* Length of prepared RA in tbuf, or 0 if not valid */
byte initial; /* List of active ifaces */ byte initial; /* List of active ifaces */
}; };