summaryrefslogtreecommitdiff
path: root/proto/ospf
diff options
context:
space:
mode:
Diffstat (limited to 'proto/ospf')
-rw-r--r--proto/ospf/dbdes.c10
-rw-r--r--proto/ospf/iface.c28
-rw-r--r--proto/ospf/lsalib.h3
-rw-r--r--proto/ospf/lsupd.c16
-rw-r--r--proto/ospf/neighbor.c24
-rw-r--r--proto/ospf/ospf.c6
-rw-r--r--proto/ospf/ospf.h12
-rw-r--r--proto/ospf/packet.c8
-rw-r--r--proto/ospf/rt.c6
-rw-r--r--proto/ospf/topology.c19
-rw-r--r--proto/ospf/topology.h2
11 files changed, 69 insertions, 65 deletions
diff --git a/proto/ospf/dbdes.c b/proto/ospf/dbdes.c
index a4452cc8..270259a7 100644
--- a/proto/ospf/dbdes.c
+++ b/proto/ospf/dbdes.c
@@ -279,8 +279,8 @@ ospf_process_dbdes(struct ospf_proto *p, struct ospf_packet *pkt, struct ospf_ne
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);
}
}
@@ -366,7 +366,7 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
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;
@@ -422,13 +422,13 @@ ospf_receive_dbdes(struct ospf_packet *pkt, struct ospf_iface *ifa,
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
{
diff --git a/proto/ospf/iface.c b/proto/ospf/iface.c
index d1f9365e..33ec21fb 100644
--- a/proto/ospf/iface.c
+++ b/proto/ospf/iface.c
@@ -263,13 +263,13 @@ ospf_iface_down(struct ospf_iface *ifa)
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);
@@ -396,15 +396,15 @@ ospf_iface_sm(struct ospf_iface *ifa, int event)
{
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);
}
@@ -494,13 +494,13 @@ ospf_iface_add(struct object_lock *lock)
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 *));
@@ -703,7 +703,7 @@ ospf_iface_new_vlink(struct ospf_proto *p, struct ospf_iface_patt *ip)
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 *));
@@ -717,8 +717,8 @@ ospf_iface_change_timer(timer *tm, uint val)
tm->recurrent = val S;
- if (tm_active(tm))
- tm_start(tm, val);
+ if (tm2_active(tm))
+ tm2_start(tm, val S);
}
static inline void
@@ -801,8 +801,8 @@ ospf_iface_reconfigure(struct ospf_iface *ifa, struct ospf_iface_patt *new)
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 */
diff --git a/proto/ospf/lsalib.h b/proto/ospf/lsalib.h
index 0d477f58..fca7faec 100644
--- a/proto/ospf/lsalib.h
+++ b/proto/ospf/lsalib.h
@@ -60,4 +60,7 @@ void lsa_parse_sum_rt(struct top_hash_entry *en, int ospf2, u32 *drid, u32 *metr
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_ */
diff --git a/proto/ospf/lsupd.c b/proto/ospf/lsupd.c
index 157d9628..18811392 100644
--- a/proto/ospf/lsupd.c
+++ b/proto/ospf/lsupd.c
@@ -115,7 +115,7 @@ ospf_lsa_lsrq_down(struct top_hash_entry *req, struct ospf_neighbor *n)
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);
@@ -136,8 +136,8 @@ ospf_lsa_lsrt_up(struct top_hash_entry *en, struct ospf_neighbor *n)
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
@@ -150,7 +150,7 @@ ospf_lsa_lsrt_down_(struct top_hash_entry *en, struct ospf_neighbor *n, struct t
ospf_hash_delete(n->lsrth, ret);
if (EMPTY_SLIST(n->lsrtl))
- tm_stop(n->lsrt_timer);
+ tm2_stop(n->lsrt_timer);
}
static inline int
@@ -175,8 +175,8 @@ ospf_add_flushed_to_lsrt(struct ospf_proto *p, struct ospf_neighbor *n)
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);
@@ -572,7 +572,7 @@ ospf_receive_lsupd(struct ospf_packet *pkt, 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;
@@ -700,7 +700,7 @@ ospf_receive_lsupd(struct ospf_packet *pkt, struct ospf_iface *ifa,
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;
diff --git a/proto/ospf/neighbor.c b/proto/ospf/neighbor.c
index 74ea63d0..12eb9e84 100644
--- a/proto/ospf/neighbor.c
+++ b/proto/ospf/neighbor.c
@@ -66,10 +66,10 @@ reset_lists(struct ospf_proto *p, struct ospf_neighbor *n)
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);
}
@@ -94,11 +94,11 @@ ospf_neighbor_new(struct ospf_iface *ifa)
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);
}
@@ -185,8 +185,8 @@ ospf_neigh_chstate(struct ospf_neighbor *n, u8 state)
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)
@@ -231,7 +231,7 @@ ospf_neigh_sm(struct ospf_neighbor *n, int event)
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:
diff --git a/proto/ospf/ospf.c b/proto/ospf/ospf.c
index a9081ed0..13f3845b 100644
--- a/proto/ospf/ospf.c
+++ b/proto/ospf/ospf.c
@@ -241,8 +241,8 @@ ospf_start(struct proto *P)
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);
@@ -677,7 +677,7 @@ ospf_reconfigure(struct proto *P, struct proto_config *CF)
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)
diff --git a/proto/ospf/ospf.h b/proto/ospf/ospf.h
index 1530b26a..5aa27a16 100644
--- a/proto/ospf/ospf.h
+++ b/proto/ospf/ospf.h
@@ -64,10 +64,10 @@
#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
@@ -283,8 +283,8 @@ struct ospf_iface
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 */
diff --git a/proto/ospf/packet.c b/proto/ospf/packet.c
index 7f9f3b39..38d7a75f 100644
--- a/proto/ospf/packet.c
+++ b/proto/ospf/packet.c
@@ -77,16 +77,16 @@ ospf_pkt_finalize(struct ospf_iface *ifa, struct ospf_packet *pkt, uint *plen)
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);
diff --git a/proto/ospf/rt.c b/proto/ospf/rt.c
index b289d767..36bf0387 100644
--- a/proto/ospf/rt.c
+++ b/proto/ospf/rt.c
@@ -1321,7 +1321,7 @@ ospf_rt_abr2(struct ospf_proto *p)
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;
}
@@ -1329,10 +1329,10 @@ ospf_rt_abr2(struct ospf_proto *p)
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;
}
}
diff --git a/proto/ospf/topology.c b/proto/ospf/topology.c
index 8dd91a40..717c8280 100644
--- a/proto/ospf/topology.c
+++ b/proto/ospf/topology.c
@@ -70,7 +70,7 @@ ospf_install_lsa(struct ospf_proto *p, struct ospf_lsa_header *lsa, u32 type, u3
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
@@ -128,7 +128,7 @@ ospf_advance_lsa(struct ospf_proto *p, struct top_hash_entry *en, struct ospf_ls
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",
@@ -160,7 +160,7 @@ ospf_advance_lsa(struct ospf_proto *p, struct top_hash_entry *en, struct ospf_ls
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);
@@ -196,7 +196,7 @@ static int
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 */
@@ -237,7 +237,7 @@ ospf_do_originate_lsa(struct ospf_proto *p, struct top_hash_entry *en, void *lsa
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",
@@ -381,7 +381,7 @@ ospf_refresh_lsa(struct ospf_proto *p, struct top_hash_entry *en)
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);
}
@@ -476,14 +476,15 @@ void
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)
{
@@ -1636,7 +1637,7 @@ ospf_originate_prefix_net_lsa(struct ospf_proto *p, struct ospf_iface *ifa)
}
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)
diff --git a/proto/ospf/topology.h b/proto/ospf/topology.h
index d1682c54..ac87334b 100644
--- a/proto/ospf/topology.h
+++ b/proto/ospf/topology.h
@@ -26,7 +26,7 @@ struct top_hash_entry
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 */