/* Activate triggered updates */
if (en->metric != old_metric)
{
- en->changed = now;
+ en->changed = current_time();
rip_trigger_update(p);
}
}
TRACE(D_EVENTS, "Starting interface %s", ifa->iface->name);
- ifa->next_regular = now + (random() % ifa->cf->update_time) + 1;
- ifa->next_triggered = now; /* Available immediately */
- ifa->want_triggered = 1; /* All routes in triggered update */
- tm_start(ifa->timer, 1); /* Or 100 ms */
+ ifa->next_regular = current_time() + (random() % ifa->cf->update_time) + 100 MS;
+ ifa->next_triggered = current_time(); /* Available immediately */
+ ifa->want_triggered = 1; /* All routes in triggered update */
+ tm2_start(ifa->timer, 100 MS);
ifa->up = 1;
if (!ifa->cf->passive)
WALK_LIST_FIRST(n, ifa->neigh_list)
rip_remove_neighbor(p, n);
- tm_stop(ifa->timer);
+ tm2_stop(ifa->timer);
ifa->up = 0;
}
add_tail(&p->iface_list, NODE ifa);
- ifa->timer = tm_new_set(p->p.pool, rip_iface_timer, ifa, 0, 0);
+ ifa->timer = tm2_new_init(p->p.pool, rip_iface_timer, ifa, 0, 0);
struct object_lock *lock = olock_new(p->p.pool);
lock->type = OBJLOCK_UDP;
rip_iface_update_buffers(ifa);
- if (ifa->next_regular > (now + (bird_clock_t) new->update_time))
- ifa->next_regular = now + (random() % new->update_time) + 1;
+ if (ifa->next_regular > (current_time() + new->update_time))
+ ifa->next_regular = current_time() + (random() % new->update_time) + 100 MS;
if (new->check_link != old->check_link)
rip_iface_update_state(ifa);
struct rip_iface *ifa;
struct rip_neighbor *n, *nn;
struct fib_iterator fit;
- bird_clock_t next = now + MIN(cf->min_timeout_time, cf->max_garbage_time);
- bird_clock_t expires = 0;
+ btime now_ = current_time();
+ btime next = now_ + MIN(cf->min_timeout_time, cf->max_garbage_time);
+ btime expires = 0;
TRACE(D_EVENTS, "Main timer fired");
/* Checking received routes for timeout and for dead neighbors */
for (rp = &en->routes; rt = *rp; /* rp = &rt->next */)
{
- if (!rip_valid_rte(rt) || (rt->expires <= now))
+ if (!rip_valid_rte(rt) || (rt->expires <= now_))
{
rip_remove_rte(p, rp);
changed = 1;
{
expires = en->changed + cf->max_garbage_time;
- if (expires <= now)
+ if (expires <= now_)
{
// TRACE(D_EVENTS, "entry is too old: %N", en->n.addr);
en->valid = 0;
{
expires = n->last_seen + n->ifa->cf->timeout_time;
- if (expires <= now)
+ if (expires <= now_)
rip_remove_neighbor(p, n);
else
next = MIN(next, expires);
}
- tm_start(p->timer, MAX(next - now, 1));
+ tm2_start(p->timer, MAX(next - now_, 100 MS));
}
static inline void
rip_kick_timer(struct rip_proto *p)
{
- if (p->timer->expires TO_S > (now + 1))
- tm_start(p->timer, 1); /* Or 100 ms */
+ if (p->timer->expires > (current_time() + 100 MS))
+ tm2_start(p->timer, 100 MS);
}
/**
{
struct rip_iface *ifa = t->data;
struct rip_proto *p = ifa->rip;
- bird_clock_t period = ifa->cf->update_time;
+ btime now_ = current_time();
+ btime period = ifa->cf->update_time;
if (ifa->cf->passive)
return;
if (ifa->tx_active)
{
- if (now < (ifa->next_regular + period))
- { tm_start(ifa->timer, 1); return; }
+ if (now_ < (ifa->next_regular + period))
+ { tm2_start(ifa->timer, 100 MS); return; }
/* We are too late, reset is done by rip_send_table() */
log(L_WARN "%s: Too slow update on %s, resetting", p->p.name, ifa->iface->name);
}
- if (now >= ifa->next_regular)
+ if (now_ >= ifa->next_regular)
{
/* Send regular update, set timer for next period (or following one if necessay) */
TRACE(D_EVENTS, "Sending regular updates for %s", ifa->iface->name);
rip_send_table(p, ifa, ifa->addr, 0);
- ifa->next_regular += period * (1 + ((now - ifa->next_regular) / period));
+ ifa->next_regular += period * (1 + ((now_ - ifa->next_regular) / period));
ifa->want_triggered = 0;
p->triggered = 0;
}
- else if (ifa->want_triggered && (now >= ifa->next_triggered))
+ else if (ifa->want_triggered && (now_ >= ifa->next_triggered))
{
/* Send triggered update, enforce interval between triggered updates */
TRACE(D_EVENTS, "Sending triggered updates for %s", ifa->iface->name);
rip_send_table(p, ifa, ifa->addr, ifa->want_triggered);
- ifa->next_triggered = now + MIN(5, period / 2 + 1);
+ ifa->next_triggered = now_ + MIN(5 S, period / 2);
ifa->want_triggered = 0;
p->triggered = 0;
}
- tm_start(ifa->timer, ifa->want_triggered ? 1 : (ifa->next_regular - now));
+ tm2_start(ifa->timer, ifa->want_triggered ? (1 S) : (ifa->next_regular - now_));
}
static inline void
rip_iface_kick_timer(struct rip_iface *ifa)
{
- if (ifa->timer->expires TO_S > (now + 1))
- tm_start(ifa->timer, 1); /* Or 100 ms */
+ if (ifa->timer->expires > (current_time() + 100 MS))
+ tm2_start(ifa->timer, 100 MS);
}
static void
continue;
TRACE(D_EVENTS, "Scheduling triggered updates for %s", ifa->iface->name);
- ifa->want_triggered = now;
+ ifa->want_triggered = current_time();
rip_iface_kick_timer(ifa);
}
fib_init(&p->rtable, P->pool, cf->rip2 ? NET_IP4 : NET_IP6,
sizeof(struct rip_entry), OFFSETOF(struct rip_entry, n), 0, NULL);
p->rte_slab = sl_new(P->pool, sizeof(struct rip_rte));
- p->timer = tm_new_set(P->pool, rip_timer, p, 0, 0);
+ p->timer = tm2_new_init(P->pool, rip_timer, p, 0, 0);
p->rip2 = cf->rip2;
p->ecmp = cf->ecmp;
p->log_pkt_tbf = (struct tbf){ .rate = 1, .burst = 5 };
p->log_rte_tbf = (struct tbf){ .rate = 4, .burst = 20 };
- tm_start(p->timer, MIN(cf->min_timeout_time, cf->max_garbage_time));
+ tm2_start(p->timer, MIN(cf->min_timeout_time, cf->max_garbage_time));
return PS_UP;
}
}
cli_msg(-1021, "%s:", p->p.name);
- cli_msg(-1021, "%-10s %-6s %6s %6s %6s",
+ cli_msg(-1021, "%-10s %-6s %6s %6s %7s",
"Interface", "State", "Metric", "Nbrs", "Timer");
WALK_LIST(ifa, p->iface_list)
if (n->last_seen)
nbrs++;
- int timer = MAX(ifa->next_regular - now, 0);
- cli_msg(-1021, "%-10s %-6s %6u %6u %6u",
+ btime now_ = current_time();
+ btime timer = (ifa->next_regular > now_) ? (ifa->next_regular - now_) : 0;
+ cli_msg(-1021, "%-10s %-6s %6u %6u %7t",
ifa->iface->name, (ifa->up ? "Up" : "Down"), ifa->cf->metric, nbrs, timer);
}
}
cli_msg(-1022, "%s:", p->p.name);
- cli_msg(-1022, "%-25s %-10s %6s %6s %6s",
+ cli_msg(-1022, "%-25s %-10s %6s %6s %7s",
"IP address", "Interface", "Metric", "Routes", "Seen");
WALK_LIST(ifa, p->iface_list)
if (!n->last_seen)
continue;
- int timer = now - n->last_seen;
- cli_msg(-1022, "%-25I %-10s %6u %6u %6u",
+ btime timer = current_time() - n->last_seen;
+ cli_msg(-1022, "%-25I %-10s %6u %6u %7t",
n->nbr->addr, ifa->iface->name, ifa->cf->metric, n->uc, timer);
}
}
i = 0;
FIB_WALK(&p->rtable, struct rip_entry, en)
{
- debug("RIP: entry #%d: %N via %I dev %s valid %d metric %d age %d s\n",
+ debug("RIP: entry #%d: %N via %I dev %s valid %d metric %d age %t\n",
i++, en->n.addr, en->next_hop, en->iface->name,
- en->valid, en->metric, now - en->changed);
+ en->valid, en->metric, current_time() - en->changed);
}
FIB_WALK_END;
#define RIP_DEFAULT_ECMP_LIMIT 16
#define RIP_DEFAULT_INFINITY 16
-#define RIP_DEFAULT_UPDATE_TIME 30
-#define RIP_DEFAULT_TIMEOUT_TIME 180
-#define RIP_DEFAULT_GARBAGE_TIME 120
+#define RIP_DEFAULT_UPDATE_TIME (30 S_)
+#define RIP_DEFAULT_TIMEOUT_TIME (180 S_)
+#define RIP_DEFAULT_GARBAGE_TIME (120 S_)
struct rip_config
u8 ecmp; /* Maximum number of nexthops in ECMP route, or 0 */
u8 infinity; /* Maximum metric value, representing infinity */
- u32 min_timeout_time; /* Minimum of interface timeout_time */
- u32 max_garbage_time; /* Maximum of interface garbage_time */
+ btime min_timeout_time; /* Minimum of interface timeout_time */
+ btime max_garbage_time; /* Maximum of interface garbage_time */
};
struct rip_iface_config
u16 tx_length; /* TX packet length limit (including headers), 0 for MTU */
int tx_tos;
int tx_priority;
- u32 update_time; /* Periodic update interval */
- u32 timeout_time; /* Route expiration timeout */
- u32 garbage_time; /* Unreachable entry GC timeout */
+ btime update_time; /* Periodic update interval */
+ btime timeout_time; /* Route expiration timeout */
+ btime garbage_time; /* Unreachable entry GC timeout */
list *passwords; /* Passwords for authentication */
};
list neigh_list; /* List of iface neighbors (struct rip_neighbor) */
/* Update scheduling */
- bird_clock_t next_regular; /* Next time when regular update should be called */
- bird_clock_t next_triggered; /* Next time when triggerd update may be called */
- bird_clock_t want_triggered; /* Nonzero if triggered update is scheduled */
+ btime next_regular; /* Next time when regular update should be called */
+ btime next_triggered; /* Next time when triggerd update may be called */
+ btime want_triggered; /* Nonzero if triggered update is scheduled */
/* Active update */
int tx_active; /* Update session is active */
ip_addr tx_addr; /* Update session destination address */
- bird_clock_t tx_changed; /* Minimal changed time for triggered update */
+ btime tx_changed; /* Minimal changed time for triggered update */
struct fib_iterator tx_fit; /* FIB iterator in RIP routing table (p.rtable) */
};
struct rip_iface *ifa; /* Associated interface, may be NULL if stale */
struct neighbor *nbr; /* Associaded core neighbor, may be NULL if stale */
struct bfd_request *bfd_req; /* BFD request, if BFD is used */
- bird_clock_t last_seen; /* Time of last received and accepted message */
+ btime last_seen; /* Time of last received and accepted message */
u32 uc; /* Use count, number of routes linking the neighbor */
u32 csn; /* Last received crypto sequence number */
};
struct iface *iface; /* Outgoing route iface (for next hop) */
ip_addr next_hop; /* Outgoing route next hop */
- bird_clock_t changed; /* Last time when the outgoing route metric changed */
+ btime changed; /* Last time when the outgoing route metric changed */
struct fib_node n;
};
u16 metric; /* Route metric (after increase) */
u16 tag; /* Route tag */
- bird_clock_t expires; /* Time of route expiration */
+ btime expires; /* Time of route expiration */
};
/* packets.c */
void rip_send_request(struct rip_proto *p, struct rip_iface *ifa);
-void rip_send_table(struct rip_proto *p, struct rip_iface *ifa, ip_addr addr, bird_clock_t changed);
+void rip_send_table(struct rip_proto *p, struct rip_iface *ifa, ip_addr addr, btime changed);
int rip_open_socket(struct rip_iface *ifa);