Note that recurrent timers are currently limited to ~1 hour.
req->lsa = lsa;
req->lsa_body = LSA_BODY_DUMMY;
- if (!tm_active(n->lsrq_timer))
- tm_start(n->lsrq_timer, 0);
+ if (!tm2_active(n->lsrq_timer))
+ tm2_start(n->lsrq_timer, 0);
}
}
n->options = rcv_options;
n->myimms &= ~DBDES_MS;
n->imms = rcv_imms;
- tm_stop(n->dbdes_timer);
+ tm2_stop(n->dbdes_timer);
ospf_neigh_sm(n, INM_NEGDONE);
ospf_send_dbdes(p, n);
break;
if (!(n->myimms & DBDES_M) && !(n->imms & DBDES_M))
{
- tm_stop(n->dbdes_timer);
+ tm2_stop(n->dbdes_timer);
ospf_neigh_sm(n, INM_EXDONE);
break;
}
ospf_send_dbdes(p, n);
- tm_start(n->dbdes_timer, n->ifa->rxmtint);
+ tm2_start(n->dbdes_timer, n->ifa->rxmtint S);
}
else
{
ospf_neigh_sm(n, INM_KILLNBR);
if (ifa->hello_timer)
- tm_stop(ifa->hello_timer);
+ tm2_stop(ifa->hello_timer);
if (ifa->poll_timer)
- tm_stop(ifa->poll_timer);
+ tm2_stop(ifa->poll_timer);
if (ifa->wait_timer)
- tm_stop(ifa->wait_timer);
+ tm2_stop(ifa->wait_timer);
ospf_flush2_lsa(p, &ifa->link_lsa);
ospf_flush2_lsa(p, &ifa->net_lsa);
{
ospf_iface_chstate(ifa, OSPF_IS_WAITING);
if (ifa->wait_timer)
- tm_start(ifa->wait_timer, ifa->waitint);
+ tm2_start(ifa->wait_timer, ifa->waitint S);
}
}
if (ifa->hello_timer)
- tm_start(ifa->hello_timer, ifa->helloint);
+ tm2_start(ifa->hello_timer, ifa->helloint S);
if (ifa->poll_timer)
- tm_start(ifa->poll_timer, ifa->pollint);
+ tm2_start(ifa->poll_timer, ifa->pollint S);
ospf_send_hello(ifa, OHS_HELLO, NULL);
}
if (! ifa->stub)
{
- ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint);
+ ifa->hello_timer = tm2_new_init(ifa->pool, hello_timer_hook, ifa, ifa->helloint S, 0);
if (ifa->type == OSPF_IT_NBMA)
- ifa->poll_timer = tm_new_set(ifa->pool, poll_timer_hook, ifa, 0, ifa->pollint);
+ ifa->poll_timer = tm2_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 = tm_new_set(ifa->pool, wait_timer_hook, ifa, 0, 0);
+ ifa->wait_timer = tm2_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 *));
add_tail(&p->iface_list, NODE ifa);
- ifa->hello_timer = tm_new_set(ifa->pool, hello_timer_hook, ifa, 0, ifa->helloint);
+ ifa->hello_timer = tm2_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 *));
tm->recurrent = val S;
- if (tm_active(tm))
- tm_start(tm, val);
+ if (tm2_active(tm))
+ tm2_start(tm, val S);
}
static inline void
ifname, ifa->waitint, new->waitint);
ifa->waitint = new->waitint;
- if (ifa->wait_timer && ifa->wait_timer->expires)
- tm_start(ifa->wait_timer, ifa->waitint);
+ if (ifa->wait_timer && tm2_active(ifa->wait_timer))
+ tm2_start(ifa->wait_timer, ifa->waitint S);
}
/* DEAD TIMER */
void lsa_parse_ext(struct top_hash_entry *en, int ospf2, int af, struct ospf_lsa_ext_local *rt);
int lsa_validate(struct ospf_lsa_header *lsa, u32 lsa_type, int ospf2, void *body);
+static inline btime lsa_inst_age(struct top_hash_entry *en)
+{ return current_time() - en->inst_time; }
+
#endif /* _BIRD_OSPF_LSALIB_H_ */
if (EMPTY_SLIST(n->lsrql))
{
- tm_stop(n->lsrq_timer);
+ tm2_stop(n->lsrq_timer);
if (n->state == NEIGHBOR_LOADING)
ospf_neigh_sm(n, INM_LOADDONE);
ret->lsa = en->lsa;
ret->lsa_body = LSA_BODY_DUMMY;
- if (!tm_active(n->lsrt_timer))
- tm_start(n->lsrt_timer, n->ifa->rxmtint);
+ if (!tm2_active(n->lsrt_timer))
+ tm2_start(n->lsrt_timer, n->ifa->rxmtint S);
}
void
ospf_hash_delete(n->lsrth, ret);
if (EMPTY_SLIST(n->lsrtl))
- tm_stop(n->lsrt_timer);
+ tm2_stop(n->lsrt_timer);
}
static inline int
ospf_lsa_lsrt_up(en, n);
/* If we found any flushed LSA, we send them ASAP */
- if (tm_active(n->lsrt_timer))
- tm_start(n->lsrt_timer, 0);
+ if (tm2_active(n->lsrt_timer))
+ tm2_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);
{
/* 13. (5a) - enforce minimum time between updates for received LSAs */
/* We also use this to ratelimit reactions to received self-originated LSAs */
- if (en && ((now - en->inst_time) < MINLSARRIVAL))
+ if (en && (lsa_inst_age(en) < MINLSARRIVAL))
{
OSPF_TRACE(D_EVENTS, "Skipping LSA received in less that MinLSArrival");
continue;
if (!EMPTY_SLIST(n->lsrql) && (n->lsrqi == SHEAD(n->lsrql)))
{
ospf_send_lsreq(p, n);
- tm_start(n->lsrq_timer, n->ifa->rxmtint);
+ tm2_start(n->lsrq_timer, n->ifa->rxmtint S);
}
return;
ospf_top_free(n->lsrth);
ospf_reset_lsack_queue(n);
- tm_stop(n->dbdes_timer);
- tm_stop(n->lsrq_timer);
- tm_stop(n->lsrt_timer);
- tm_stop(n->ackd_timer);
+ tm2_stop(n->dbdes_timer);
+ tm2_stop(n->lsrq_timer);
+ tm2_stop(n->lsrt_timer);
+ tm2_stop(n->ackd_timer);
init_lists(p, n);
}
init_list(&n->ackl[ACKL_DIRECT]);
init_list(&n->ackl[ACKL_DELAY]);
- n->inactim = tm_new_set(pool, inactivity_timer_hook, n, 0, 0);
- n->dbdes_timer = tm_new_set(pool, dbdes_timer_hook, n, 0, ifa->rxmtint);
- n->lsrq_timer = tm_new_set(pool, lsrq_timer_hook, n, 0, ifa->rxmtint);
- n->lsrt_timer = tm_new_set(pool, lsrt_timer_hook, n, 0, ifa->rxmtint);
- n->ackd_timer = tm_new_set(pool, ackd_timer_hook, n, 0, ifa->rxmtint / 2);
+ 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);
return (n);
}
n->dds++;
n->myimms = DBDES_IMMS;
- tm_start(n->dbdes_timer, 0);
- tm_start(n->ackd_timer, ifa->rxmtint / 2);
+ tm2_start(n->dbdes_timer, 0);
+ tm2_start(n->ackd_timer, ifa->rxmtint S / 2);
}
if (state > NEIGHBOR_EXSTART)
ospf_neigh_chstate(n, NEIGHBOR_INIT);
/* Restart inactivity timer */
- tm_start(n->inactim, n->ifa->deadint);
+ tm2_start(n->inactim, n->ifa->deadint S);
break;
case INM_2WAYREC:
p->asbr = c->asbr;
p->ecmp = c->ecmp;
p->tick = c->tick;
- p->disp_timer = tm_new_set(P->pool, ospf_disp, p, 0, p->tick);
- tm_start(p->disp_timer, 1);
+ p->disp_timer = tm2_new_init(P->pool, ospf_disp, p, p->tick S, 0);
+ tm2_start(p->disp_timer, 100 MS);
p->lsab_size = 256;
p->lsab_used = 0;
p->lsab = mb_alloc(P->pool, p->lsab_size);
p->ecmp = new->ecmp;
p->tick = new->tick;
p->disp_timer->recurrent = p->tick S;
- tm_start(p->disp_timer, 1);
+ tm2_start(p->disp_timer, 100 MS);
/* Mark all areas and ifaces */
WALK_LIST(oa, p->area_list)
#define OSPF_PROTO 89
-#define LSREFRESHTIME 1800 /* 30 minutes */
-#define MINLSINTERVAL 5
-#define MINLSARRIVAL 1
-#define LSINFINITY 0xffffff
+#define LSREFRESHTIME 1800 /* 30 minutes */
+#define MINLSINTERVAL (5 S_)
+#define MINLSARRIVAL (1 S_)
+#define LSINFINITY 0xffffff
#define OSPF_DEFAULT_TICK 1
#define OSPF_DEFAULT_STUB_COST 1000
interface. LSAs contained in the update */
u16 helloint; /* number of seconds between hello sending */
list *passwords;
- u32 csn; /* Last used crypt seq number */
- bird_clock_t csn_use; /* Last time when packet with that CSN was sent */
+ u32 csn; /* Last used crypt seq number */
+ btime csn_use; /* Last time when packet with that CSN was sent */
ip_addr all_routers; /* Multicast (or broadcast) address for all routers */
ip_addr des_routers; /* Multicast (or NULL) address for designated routers */
ip_addr drip; /* Designated router IP */
reboot when system does not have independent RTC? */
if (!ifa->csn)
{
- ifa->csn = (u32) now;
- ifa->csn_use = now;
+ ifa->csn = (u32) (current_real_time() TO_S);
+ ifa->csn_use = current_time();
}
/* We must have sufficient delay between sending a packet and increasing
CSN to prevent reordering of packets (in a network) with different CSNs */
- if ((now - ifa->csn_use) > 1)
+ if ((current_time() - ifa->csn_use) > 1 S)
ifa->csn++;
- ifa->csn_use = now;
+ ifa->csn_use = current_time();
uint auth_len = mac_type_length(pass->alg);
byte *auth_tail = ((byte *) pkt + *plen);
if (translate && (oa->translate != TRANS_ON))
{
if (oa->translate == TRANS_WAIT)
- tm_stop(oa->translator_timer);
+ tm2_stop(oa->translator_timer);
oa->translate = TRANS_ON;
}
if (!translate && (oa->translate == TRANS_ON))
{
if (oa->translator_timer == NULL)
- oa->translator_timer = tm_new_set(p->p.pool, translator_timer_hook, oa, 0, 0);
+ oa->translator_timer = tm2_new_init(p->p.pool, translator_timer_hook, oa, 0, 0);
/* Schedule the end of translation */
- tm_start(oa->translator_timer, oa->ac->transint);
+ tm2_start(oa->translator_timer, oa->ac->transint S);
oa->translate = TRANS_WAIT;
}
}
en->lsa_body = body;
en->lsa = *lsa;
en->init_age = en->lsa.age;
- en->inst_time = now;
+ en->inst_time = current_time();
/*
* We do not set en->mode. It is either default LSA_M_BASIC, or in a special
en->lsa.sn = lsa->sn + 1;
en->lsa.age = 0;
en->init_age = 0;
- en->inst_time = now;
+ en->inst_time = current_time();
lsa_generate_checksum(&en->lsa, en->lsa_body);
OSPF_TRACE(D_EVENTS, "Advancing LSA: Type: %04x, Id: %R, Rt: %R, Seq: %08x",
en->lsa = *lsa;
en->lsa.age = LSA_MAXAGE;
en->init_age = lsa->age;
- en->inst_time = now;
+ en->inst_time = current_time();
OSPF_TRACE(D_EVENTS, "Resetting LSA: Type: %04x, Id: %R, Rt: %R, Seq: %08x",
en->lsa_type, en->lsa.id, en->lsa.rt, en->lsa.sn);
ospf_do_originate_lsa(struct ospf_proto *p, struct top_hash_entry *en, void *lsa_body, u16 lsa_blen, u16 lsa_opts)
{
/* Enforce MinLSInterval */
- if ((en->init_age == 0) && en->inst_time && ((en->inst_time + MINLSINTERVAL) > now))
+ if (!en->init_age && en->inst_time && (lsa_inst_age(en) < MINLSINTERVAL))
return 0;
/* Handle wrapping sequence number */
en->lsa.sn++;
en->lsa.age = 0;
en->init_age = 0;
- en->inst_time = now;
+ en->inst_time = current_time();
lsa_generate_checksum(&en->lsa, en->lsa_body);
OSPF_TRACE(D_EVENTS, "Originating LSA: Type: %04x, Id: %R, Rt: %R, Seq: %08x",
en->lsa.sn++;
en->lsa.age = 0;
en->init_age = 0;
- en->inst_time = now;
+ en->inst_time = current_time();
lsa_generate_checksum(&en->lsa, en->lsa_body);
ospf_flood_lsa(p, en, NULL);
}
ospf_update_lsadb(struct ospf_proto *p)
{
struct top_hash_entry *en, *nxt;
- bird_clock_t real_age;
+ btime now_ = current_time();
+ int real_age;
WALK_SLIST_DELSAFE(en, nxt, p->lsal)
{
if (en->next_lsa_body)
ospf_originate_next_lsa(p, en);
- real_age = en->init_age + (now - en->inst_time);
+ real_age = en->init_age + (now_ - en->inst_time) TO_S;
if (en->lsa.age == LSA_MAXAGE)
{
}
static inline int breaks_minlsinterval(struct top_hash_entry *en)
-{ return en && (en->lsa.age < LSA_MAXAGE) && ((en->inst_time + MINLSINTERVAL) > now); }
+{ return en && (en->lsa.age < LSA_MAXAGE) && (lsa_inst_age(en) < MINLSINTERVAL); }
void
ospf_update_topology(struct ospf_proto *p)
void *next_lsa_body; /* For postponed LSA origination */
u16 next_lsa_blen; /* For postponed LSA origination */
u16 next_lsa_opts; /* For postponed LSA origination */
- bird_clock_t inst_time; /* Time of installation into DB */
+ btime inst_time; /* Time of installation into DB */
struct ort *nf; /* Reference fibnode for sum and ext LSAs, NULL for otherwise */
struct nexthop *nhs; /* Computed nexthops - valid only in ospf_rt_spf() */
ip_addr lb; /* In OSPFv2, link back address. In OSPFv3, any global address in the area useful for vlinks */