Revision 8b58f565 proto/babel/babel.c
proto/babel/babel.c | ||
---|---|---|
70 | 70 |
{ |
71 | 71 |
struct babel_entry *e = E; |
72 | 72 |
|
73 |
e->updated = now;
|
|
73 |
e->updated = current_time();
|
|
74 | 74 |
init_list(&e->sources); |
75 | 75 |
init_list(&e->routes); |
76 | 76 |
} |
... | ... | |
114 | 114 |
|
115 | 115 |
s = sl_alloc(p->source_slab); |
116 | 116 |
s->router_id = router_id; |
117 |
s->expires = now + BABEL_GARBAGE_INTERVAL;
|
|
117 |
s->expires = current_time() + BABEL_GARBAGE_INTERVAL;
|
|
118 | 118 |
s->seqno = 0; |
119 | 119 |
s->metric = BABEL_INFINITY; |
120 | 120 |
add_tail(&e->sources, NODE s); |
... | ... | |
127 | 127 |
{ |
128 | 128 |
struct babel_proto *p = e->proto; |
129 | 129 |
struct babel_source *n, *nx; |
130 |
btime now_ = current_time(); |
|
130 | 131 |
|
131 | 132 |
WALK_LIST_DELSAFE(n, nx, e->sources) |
132 | 133 |
{ |
133 |
if (n->expires && n->expires <= now) |
|
134 |
if (n->expires && n->expires <= now_)
|
|
134 | 135 |
{ |
135 | 136 |
rem_node(NODE n); |
136 | 137 |
sl_free(p->source_slab, n); |
... | ... | |
167 | 168 |
if (nbr) |
168 | 169 |
{ |
169 | 170 |
r->neigh = nbr; |
170 |
r->expires = now + BABEL_GARBAGE_INTERVAL;
|
|
171 |
r->expires = current_time() + BABEL_GARBAGE_INTERVAL;
|
|
171 | 172 |
add_tail(&nbr->routes, NODE &r->neigh_route); |
172 | 173 |
} |
173 | 174 |
|
... | ... | |
208 | 209 |
if (r->metric < BABEL_INFINITY) |
209 | 210 |
{ |
210 | 211 |
r->metric = BABEL_INFINITY; |
211 |
r->expires = now + r->expiry_interval;
|
|
212 |
r->expires = current_time() + r->expiry_interval;
|
|
212 | 213 |
} |
213 | 214 |
else |
214 | 215 |
{ |
... | ... | |
230 | 231 |
{ |
231 | 232 |
struct babel_route *r, *rx; |
232 | 233 |
struct fib_iterator fit; |
234 |
btime now_ = current_time(); |
|
233 | 235 |
|
234 | 236 |
FIB_ITERATE_INIT(&fit, rtable); |
235 | 237 |
|
... | ... | |
240 | 242 |
|
241 | 243 |
WALK_LIST_DELSAFE(r, rx, e->routes) |
242 | 244 |
{ |
243 |
if (r->refresh_time && r->refresh_time <= now) |
|
245 |
if (r->refresh_time && r->refresh_time <= now_)
|
|
244 | 246 |
babel_refresh_route(r); |
245 | 247 |
|
246 |
if (r->expires && r->expires <= now) |
|
248 |
if (r->expires && r->expires <= now_)
|
|
247 | 249 |
{ |
248 | 250 |
babel_expire_route(r); |
249 | 251 |
changed = 1; |
... | ... | |
360 | 362 |
{ |
361 | 363 |
struct babel_iface *ifa; |
362 | 364 |
struct babel_neighbor *nbr, *nbx; |
365 |
btime now_ = current_time(); |
|
363 | 366 |
|
364 | 367 |
WALK_LIST(ifa, p->interfaces) |
365 | 368 |
{ |
366 | 369 |
WALK_LIST_DELSAFE(nbr, nbx, ifa->neigh_list) |
367 | 370 |
{ |
368 |
if (nbr->ihu_expiry && nbr->ihu_expiry <= now) |
|
371 |
if (nbr->ihu_expiry && nbr->ihu_expiry <= now_)
|
|
369 | 372 |
babel_expire_ihu(nbr); |
370 | 373 |
|
371 |
if (nbr->hello_expiry && nbr->hello_expiry <= now) |
|
374 |
if (nbr->hello_expiry && nbr->hello_expiry <= now_)
|
|
372 | 375 |
babel_expire_hello(nbr); |
373 | 376 |
} |
374 | 377 |
} |
... | ... | |
546 | 549 |
e->n.addr, cur->router_id, cur->metric); |
547 | 550 |
|
548 | 551 |
e->selected_in = cur; |
549 |
e->updated = now;
|
|
552 |
e->updated = current_time();
|
|
550 | 553 |
babel_announce_rte(p, e); |
551 | 554 |
} |
552 | 555 |
else if (!cur || cur->metric == BABEL_INFINITY) |
... | ... | |
562 | 565 |
e->n.addr); |
563 | 566 |
|
564 | 567 |
e->selected_in->metric = BABEL_INFINITY; |
565 |
e->updated = now;
|
|
568 |
e->updated = current_time();
|
|
566 | 569 |
|
567 | 570 |
babel_send_seqno_request(e); |
568 | 571 |
babel_announce_rte(p, e); |
... | ... | |
580 | 583 |
TRACE(D_EVENTS, "Flushing route for prefix %N", e->n.addr); |
581 | 584 |
|
582 | 585 |
e->selected_in = NULL; |
583 |
e->updated = now;
|
|
586 |
e->updated = current_time();
|
|
584 | 587 |
babel_announce_rte(p, e); |
585 | 588 |
} |
586 | 589 |
} |
... | ... | |
614 | 617 |
msg->ihu.rxcost = babel_compute_rxcost(n); |
615 | 618 |
msg->ihu.interval = ifa->cf->ihu_interval; |
616 | 619 |
|
617 |
TRACE(D_PACKETS, "Sending IHU for %I with rxcost %d interval %d",
|
|
618 |
msg->ihu.addr, msg->ihu.rxcost, msg->ihu.interval); |
|
620 |
TRACE(D_PACKETS, "Sending IHU for %I with rxcost %d interval %t",
|
|
621 |
msg->ihu.addr, msg->ihu.rxcost, (btime) msg->ihu.interval);
|
|
619 | 622 |
} |
620 | 623 |
|
621 | 624 |
static void |
... | ... | |
648 | 651 |
msg.hello.seqno = ifa->hello_seqno++; |
649 | 652 |
msg.hello.interval = ifa->cf->hello_interval; |
650 | 653 |
|
651 |
TRACE(D_PACKETS, "Sending hello on %s with seqno %d interval %d",
|
|
652 |
ifa->ifname, msg.hello.seqno, msg.hello.interval); |
|
654 |
TRACE(D_PACKETS, "Sending hello on %s with seqno %d interval %t",
|
|
655 |
ifa->ifname, msg.hello.seqno, (btime) msg.hello.interval);
|
|
653 | 656 |
|
654 | 657 |
babel_enqueue(&msg, ifa); |
655 | 658 |
|
... | ... | |
750 | 753 |
* transmitted entry is updated. |
751 | 754 |
*/ |
752 | 755 |
static void |
753 |
babel_send_update_(struct babel_iface *ifa, bird_clock_t changed, struct fib *rtable)
|
|
756 |
babel_send_update_(struct babel_iface *ifa, btime changed, struct fib *rtable)
|
|
754 | 757 |
{ |
755 | 758 |
struct babel_proto *p = ifa->proto; |
756 | 759 |
|
... | ... | |
766 | 769 |
if ((r->router_id == p->router_id) && (r->seqno < p->update_seqno)) |
767 | 770 |
{ |
768 | 771 |
r->seqno = p->update_seqno; |
769 |
e->updated = now;
|
|
772 |
e->updated = current_time();
|
|
770 | 773 |
} |
771 | 774 |
|
772 | 775 |
/* Skip routes that weren't updated since 'changed' time */ |
... | ... | |
793 | 796 |
if (!OUR_ROUTE(r)) |
794 | 797 |
{ |
795 | 798 |
struct babel_source *s = babel_get_source(e, r->router_id); |
796 |
s->expires = now + BABEL_GARBAGE_INTERVAL;
|
|
799 |
s->expires = current_time() + BABEL_GARBAGE_INTERVAL;
|
|
797 | 800 |
|
798 | 801 |
if ((msg.update.seqno > s->seqno) || |
799 | 802 |
((msg.update.seqno == s->seqno) && (msg.update.metric < s->metric))) |
... | ... | |
807 | 810 |
} |
808 | 811 |
|
809 | 812 |
static void |
810 |
babel_send_update(struct babel_iface *ifa, bird_clock_t changed)
|
|
813 |
babel_send_update(struct babel_iface *ifa, btime changed)
|
|
811 | 814 |
{ |
812 | 815 |
struct babel_proto *p = ifa->proto; |
813 | 816 |
|
... | ... | |
827 | 830 |
TRACE(D_EVENTS, "Scheduling triggered updates for %s seqno %d", |
828 | 831 |
ifa->iface->name, p->update_seqno); |
829 | 832 |
|
830 |
ifa->want_triggered = now;
|
|
833 |
ifa->want_triggered = current_time();
|
|
831 | 834 |
babel_iface_kick_timer(ifa); |
832 | 835 |
} |
833 | 836 |
|
... | ... | |
887 | 890 |
|
888 | 891 |
/* Update hello history according to Appendix A1 of the RFC */ |
889 | 892 |
static void |
890 |
babel_update_hello_history(struct babel_neighbor *n, u16 seqno, u16 interval)
|
|
893 |
babel_update_hello_history(struct babel_neighbor *n, u16 seqno, uint interval)
|
|
891 | 894 |
{ |
892 | 895 |
/* |
893 | 896 |
* Compute the difference between expected and received seqno (modulo 2^16). |
... | ... | |
925 | 928 |
n->hello_map = (n->hello_map << 1) | 1; |
926 | 929 |
n->next_hello_seqno = seqno+1; |
927 | 930 |
if (n->hello_cnt < 16) n->hello_cnt++; |
928 |
n->hello_expiry = now + BABEL_HELLO_EXPIRY_FACTOR(interval);
|
|
931 |
n->hello_expiry = current_time() + BABEL_HELLO_EXPIRY_FACTOR(interval);
|
|
929 | 932 |
} |
930 | 933 |
|
931 | 934 |
static void |
932 | 935 |
babel_expire_seqno_requests(struct babel_proto *p) |
933 | 936 |
{ |
937 |
btime now_ = current_time(); |
|
938 |
|
|
934 | 939 |
struct babel_seqno_request *n, *nx; |
935 | 940 |
WALK_LIST_DELSAFE(n, nx, p->seqno_cache) |
936 | 941 |
{ |
937 |
if ((n->updated + BABEL_SEQNO_REQUEST_EXPIRY) <= now) |
|
942 |
if ((n->updated + BABEL_SEQNO_REQUEST_EXPIRY) <= now_)
|
|
938 | 943 |
{ |
939 | 944 |
rem_node(NODE n); |
940 | 945 |
sl_free(p->seqno_slab, n); |
... | ... | |
963 | 968 |
net_copy(&r->net, n); |
964 | 969 |
r->router_id = router_id; |
965 | 970 |
r->seqno = seqno; |
966 |
r->updated = now;
|
|
971 |
r->updated = current_time();
|
|
967 | 972 |
add_tail(&p->seqno_cache, NODE r); |
968 | 973 |
|
969 | 974 |
return 1; |
... | ... | |
1013 | 1018 |
struct babel_proto *p = ifa->proto; |
1014 | 1019 |
struct babel_msg_ack_req *msg = &m->ack_req; |
1015 | 1020 |
|
1016 |
TRACE(D_PACKETS, "Handling ACK request nonce %d interval %d",
|
|
1017 |
msg->nonce, msg->interval); |
|
1021 |
TRACE(D_PACKETS, "Handling ACK request nonce %d interval %t",
|
|
1022 |
msg->nonce, (btime) msg->interval);
|
|
1018 | 1023 |
|
1019 | 1024 |
babel_send_ack(ifa, msg->sender, msg->nonce); |
1020 | 1025 |
} |
... | ... | |
1025 | 1030 |
struct babel_proto *p = ifa->proto; |
1026 | 1031 |
struct babel_msg_hello *msg = &m->hello; |
1027 | 1032 |
|
1028 |
TRACE(D_PACKETS, "Handling hello seqno %d interval %d",
|
|
1029 |
msg->seqno, msg->interval); |
|
1033 |
TRACE(D_PACKETS, "Handling hello seqno %d interval %t",
|
|
1034 |
msg->seqno, (btime) msg->interval);
|
|
1030 | 1035 |
|
1031 | 1036 |
struct babel_neighbor *n = babel_get_neighbor(ifa, msg->sender); |
1032 | 1037 |
babel_update_hello_history(n, msg->seqno, msg->interval); |
... | ... | |
1044 | 1049 |
if ((msg->ae != BABEL_AE_WILDCARD) && !ipa_equal(msg->addr, ifa->addr)) |
1045 | 1050 |
return; |
1046 | 1051 |
|
1047 |
TRACE(D_PACKETS, "Handling IHU rxcost %d interval %d",
|
|
1048 |
msg->rxcost, msg->interval); |
|
1052 |
TRACE(D_PACKETS, "Handling IHU rxcost %d interval %t",
|
|
1053 |
msg->rxcost, (btime) msg->interval);
|
|
1049 | 1054 |
|
1050 | 1055 |
struct babel_neighbor *n = babel_get_neighbor(ifa, msg->sender); |
1051 | 1056 |
n->txcost = msg->rxcost; |
1052 |
n->ihu_expiry = now + BABEL_IHU_EXPIRY_FACTOR(msg->interval);
|
|
1057 |
n->ihu_expiry = current_time() + BABEL_IHU_EXPIRY_FACTOR(msg->interval);
|
|
1053 | 1058 |
} |
1054 | 1059 |
|
1055 | 1060 |
/** |
... | ... | |
1214 | 1219 |
r->seqno = msg->seqno; |
1215 | 1220 |
|
1216 | 1221 |
r->expiry_interval = BABEL_ROUTE_EXPIRY_FACTOR(msg->interval); |
1217 |
r->expires = now + r->expiry_interval;
|
|
1222 |
r->expires = current_time() + r->expiry_interval;
|
|
1218 | 1223 |
if (r->expiry_interval > BABEL_ROUTE_REFRESH_INTERVAL) |
1219 |
r->refresh_time = now + r->expiry_interval - BABEL_ROUTE_REFRESH_INTERVAL;
|
|
1224 |
r->refresh_time = current_time() + r->expiry_interval - BABEL_ROUTE_REFRESH_INTERVAL;
|
|
1220 | 1225 |
|
1221 | 1226 |
/* If the route is not feasible at this point, it means it is from another |
1222 | 1227 |
neighbour than the one currently selected; so send a unicast seqno |
... | ... | |
1256 | 1261 |
else |
1257 | 1262 |
{ |
1258 | 1263 |
babel_trigger_iface_update(ifa); |
1259 |
e->updated = now;
|
|
1264 |
e->updated = current_time();
|
|
1260 | 1265 |
} |
1261 | 1266 |
} |
1262 | 1267 |
|
... | ... | |
1283 | 1288 |
if ((r->router_id != msg->router_id) || ge_mod64k(r->seqno, msg->seqno)) |
1284 | 1289 |
{ |
1285 | 1290 |
babel_trigger_iface_update(ifa); |
1286 |
e->updated = now;
|
|
1291 |
e->updated = current_time();
|
|
1287 | 1292 |
return; |
1288 | 1293 |
} |
1289 | 1294 |
|
... | ... | |
1333 | 1338 |
{ |
1334 | 1339 |
struct babel_iface *ifa = t->data; |
1335 | 1340 |
struct babel_proto *p = ifa->proto; |
1336 |
bird_clock_t hello_period = ifa->cf->hello_interval; |
|
1337 |
bird_clock_t update_period = ifa->cf->update_interval; |
|
1341 |
btime hello_period = ifa->cf->hello_interval; |
|
1342 |
btime update_period = ifa->cf->update_interval; |
|
1343 |
btime now_ = current_time(); |
|
1338 | 1344 |
|
1339 |
if (now >= ifa->next_hello) |
|
1345 |
if (now_ >= ifa->next_hello)
|
|
1340 | 1346 |
{ |
1341 | 1347 |
babel_send_hello(ifa, (ifa->cf->type == BABEL_IFACE_TYPE_WIRELESS || |
1342 | 1348 |
ifa->hello_seqno % BABEL_IHU_INTERVAL_FACTOR == 0)); |
1343 |
ifa->next_hello += hello_period * (1 + (now - ifa->next_hello) / hello_period);
|
|
1349 |
ifa->next_hello += hello_period * (1 + (now_ - ifa->next_hello) / hello_period);
|
|
1344 | 1350 |
} |
1345 | 1351 |
|
1346 |
if (now >= ifa->next_regular) |
|
1352 |
if (now_ >= ifa->next_regular)
|
|
1347 | 1353 |
{ |
1348 | 1354 |
TRACE(D_EVENTS, "Sending regular updates on %s", ifa->ifname); |
1349 | 1355 |
babel_send_update(ifa, 0); |
1350 |
ifa->next_regular += update_period * (1 + (now - ifa->next_regular) / update_period); |
|
1356 |
ifa->next_regular += update_period * (1 + (now_ - ifa->next_regular) / update_period);
|
|
1351 | 1357 |
ifa->want_triggered = 0; |
1352 | 1358 |
p->triggered = 0; |
1353 | 1359 |
} |
1354 |
else if (ifa->want_triggered && (now >= ifa->next_triggered)) |
|
1360 |
else if (ifa->want_triggered && (now_ >= ifa->next_triggered))
|
|
1355 | 1361 |
{ |
1356 | 1362 |
TRACE(D_EVENTS, "Sending triggered updates on %s", ifa->ifname); |
1357 | 1363 |
babel_send_update(ifa, ifa->want_triggered); |
1358 |
ifa->next_triggered = now + MIN(5, update_period / 2 + 1);
|
|
1364 |
ifa->next_triggered = now_ + MIN(5 S, update_period / 2);
|
|
1359 | 1365 |
ifa->want_triggered = 0; |
1360 | 1366 |
p->triggered = 0; |
1361 | 1367 |
} |
1362 | 1368 |
|
1363 |
bird_clock_t next_event = MIN(ifa->next_hello, ifa->next_regular); |
|
1364 |
tm_start(ifa->timer, ifa->want_triggered ? 1 : (next_event - now)); |
|
1369 |
btime next_event = MIN(ifa->next_hello, ifa->next_regular); |
|
1370 |
if (ifa->want_triggered) next_event = MIN(next_event, ifa->next_triggered); |
|
1371 |
tm2_set(ifa->timer, next_event); |
|
1365 | 1372 |
} |
1366 | 1373 |
|
1367 | 1374 |
static inline void |
1368 | 1375 |
babel_iface_kick_timer(struct babel_iface *ifa) |
1369 | 1376 |
{ |
1370 |
if (ifa->timer->expires TO_S > (now + 1))
|
|
1371 |
tm_start(ifa->timer, 1);
|
|
1377 |
if (ifa->timer->expires > (current_time() + 100 MS))
|
|
1378 |
tm2_start(ifa->timer, 100 MS);
|
|
1372 | 1379 |
} |
1373 | 1380 |
|
1374 | 1381 |
static void |
... | ... | |
1378 | 1385 |
|
1379 | 1386 |
TRACE(D_EVENTS, "Starting interface %s", ifa->ifname); |
1380 | 1387 |
|
1381 |
ifa->next_hello = now + (random() % ifa->cf->hello_interval) + 1;
|
|
1382 |
ifa->next_regular = now + (random() % ifa->cf->update_interval) + 1;
|
|
1383 |
ifa->next_triggered = now + MIN(5, ifa->cf->update_interval / 2 + 1);
|
|
1388 |
ifa->next_hello = current_time() + (random() % ifa->cf->hello_interval);
|
|
1389 |
ifa->next_regular = current_time() + (random() % ifa->cf->update_interval);
|
|
1390 |
ifa->next_triggered = current_time() + MIN(5 S, ifa->cf->update_interval / 2);
|
|
1384 | 1391 |
ifa->want_triggered = 0; /* We send an immediate update (below) */ |
1385 |
tm_start(ifa->timer, 1);
|
|
1392 |
tm2_start(ifa->timer, 100 MS);
|
|
1386 | 1393 |
ifa->up = 1; |
1387 | 1394 |
|
1388 | 1395 |
babel_send_hello(ifa, 0); |
... | ... | |
1398 | 1405 |
struct babel_neighbor *nbr; |
1399 | 1406 |
struct babel_route *r; |
1400 | 1407 |
node *n; |
1408 |
btime now_ = current_time(); |
|
1401 | 1409 |
|
1402 | 1410 |
TRACE(D_EVENTS, "Stopping interface %s", ifa->ifname); |
1403 | 1411 |
|
... | ... | |
1412 | 1420 |
{ |
1413 | 1421 |
r = SKIP_BACK(struct babel_route, neigh_route, n); |
1414 | 1422 |
r->metric = BABEL_INFINITY; |
1415 |
r->expires = now + r->expiry_interval; |
|
1423 |
r->expires = now_ + r->expiry_interval;
|
|
1416 | 1424 |
babel_select_route(r->e); |
1417 | 1425 |
} |
1418 | 1426 |
} |
1419 | 1427 |
|
1420 |
tm_stop(ifa->timer); |
|
1428 |
tm2_stop(ifa->timer);
|
|
1421 | 1429 |
ifa->up = 0; |
1422 | 1430 |
} |
1423 | 1431 |
|
... | ... | |
1515 | 1523 |
init_list(&ifa->neigh_list); |
1516 | 1524 |
ifa->hello_seqno = 1; |
1517 | 1525 |
|
1518 |
ifa->timer = tm_new_set(ifa->pool, babel_iface_timer, ifa, 0, 0);
|
|
1526 |
ifa->timer = tm2_new_init(ifa->pool, babel_iface_timer, ifa, 0, 0);
|
|
1519 | 1527 |
|
1520 | 1528 |
init_list(&ifa->msg_queue); |
1521 | 1529 |
ifa->send_event = ev_new(ifa->pool); |
... | ... | |
1614 | 1622 |
if (ipa_zero(ifa->next_hop_ip4) && p->ip4_channel) |
1615 | 1623 |
log(L_WARN "%s: Cannot find IPv4 next hop addr on %s", p->p.name, ifa->ifname); |
1616 | 1624 |
|
1617 |
if (ifa->next_hello > (now + new->hello_interval))
|
|
1618 |
ifa->next_hello = now + (random() % new->hello_interval) + 1;
|
|
1625 |
if (ifa->next_hello > (current_time() + new->hello_interval))
|
|
1626 |
ifa->next_hello = current_time() + (random() % new->hello_interval);
|
|
1619 | 1627 |
|
1620 |
if (ifa->next_regular > (now + new->update_interval))
|
|
1621 |
ifa->next_regular = now + (random() % new->update_interval) + 1;
|
|
1628 |
if (ifa->next_regular > (current_time() + new->update_interval))
|
|
1629 |
ifa->next_regular = current_time() + (random() % new->update_interval);
|
|
1622 | 1630 |
|
1623 | 1631 |
if ((new->tx_length != old->tx_length) || (new->rx_buffer != old->rx_buffer)) |
1624 | 1632 |
babel_iface_update_buffers(ifa); |
... | ... | |
1680 | 1688 |
static void |
1681 | 1689 |
babel_dump_source(struct babel_source *s) |
1682 | 1690 |
{ |
1683 |
debug("Source router_id %lR seqno %d metric %d expires %d\n", |
|
1684 |
s->router_id, s->seqno, s->metric, s->expires ? s->expires-now : 0); |
|
1691 |
debug("Source router_id %lR seqno %d metric %d expires %t\n", |
|
1692 |
s->router_id, s->seqno, s->metric, |
|
1693 |
s->expires ? s->expires - current_time() : 0); |
|
1685 | 1694 |
} |
1686 | 1695 |
|
1687 | 1696 |
static void |
1688 | 1697 |
babel_dump_route(struct babel_route *r) |
1689 | 1698 |
{ |
1690 |
debug("Route neigh %I if %s seqno %d metric %d/%d router_id %lR expires %d\n",
|
|
1699 |
debug("Route neigh %I if %s seqno %d metric %d/%d router_id %lR expires %t\n",
|
|
1691 | 1700 |
r->neigh ? r->neigh->addr : IPA_NONE, |
1692 | 1701 |
r->neigh ? r->neigh->ifa->ifname : "(none)", |
1693 |
r->seqno, r->advert_metric, r->metric, |
|
1694 |
r->router_id, r->expires ? r->expires-now : 0);
|
|
1702 |
r->seqno, r->advert_metric, r->metric, r->router_id,
|
|
1703 |
r->expires ? r->expires - current_time() : 0);
|
|
1695 | 1704 |
} |
1696 | 1705 |
|
1697 | 1706 |
static void |
... | ... | |
1717 | 1726 |
static void |
1718 | 1727 |
babel_dump_neighbor(struct babel_neighbor *n) |
1719 | 1728 |
{ |
1720 |
debug("Neighbor %I txcost %d hello_map %x next seqno %d expires %d/%d\n",
|
|
1729 |
debug("Neighbor %I txcost %d hello_map %x next seqno %d expires %t/%t\n",
|
|
1721 | 1730 |
n->addr, n->txcost, n->hello_map, n->next_hello_seqno, |
1722 |
n->hello_expiry ? n->hello_expiry - now : 0,
|
|
1723 |
n->ihu_expiry ? n->ihu_expiry - now : 0);
|
|
1731 |
n->hello_expiry ? n->hello_expiry - current_time() : 0,
|
|
1732 |
n->ihu_expiry ? n->ihu_expiry - current_time() : 0);
|
|
1724 | 1733 |
} |
1725 | 1734 |
|
1726 | 1735 |
static void |
... | ... | |
1728 | 1737 |
{ |
1729 | 1738 |
struct babel_neighbor *n; |
1730 | 1739 |
|
1731 |
debug("Babel: Interface %s addr %I rxcost %d type %d hello seqno %d intervals %d %d",
|
|
1740 |
debug("Babel: Interface %s addr %I rxcost %d type %d hello seqno %d intervals %t %t",
|
|
1732 | 1741 |
ifa->ifname, ifa->addr, ifa->cf->rxcost, ifa->cf->type, ifa->hello_seqno, |
1733 | 1742 |
ifa->cf->hello_interval, ifa->cf->update_interval); |
1734 | 1743 |
debug(" next hop v4 %I next hop v6 %I\n", ifa->next_hop_ip4, ifa->next_hop_ip6); |
... | ... | |
1803 | 1812 |
} |
1804 | 1813 |
|
1805 | 1814 |
cli_msg(-1023, "%s:", p->p.name); |
1806 |
cli_msg(-1023, "%-10s %-6s %7s %6s %6s %-15s %s",
|
|
1815 |
cli_msg(-1023, "%-10s %-6s %7s %6s %7s %-15s %s",
|
|
1807 | 1816 |
"Interface", "State", "RX cost", "Nbrs", "Timer", |
1808 | 1817 |
"Next hop (v4)", "Next hop (v6)"); |
1809 | 1818 |
|
... | ... | |
1816 | 1825 |
WALK_LIST(nbr, ifa->neigh_list) |
1817 | 1826 |
nbrs++; |
1818 | 1827 |
|
1819 |
int timer = MIN(ifa->next_regular, ifa->next_hello) - now;
|
|
1820 |
cli_msg(-1023, "%-10s %-6s %7u %6u %6u %-15I %I",
|
|
1828 |
btime timer = MIN(ifa->next_regular, ifa->next_hello) - current_time();
|
|
1829 |
cli_msg(-1023, "%-10s %-6s %7u %6u %7t %-15I %I",
|
|
1821 | 1830 |
ifa->iface->name, (ifa->up ? "Up" : "Down"), |
1822 | 1831 |
ifa->cf->rxcost, nbrs, MAX(timer, 0), |
1823 | 1832 |
ifa->next_hop_ip4, ifa->next_hop_ip6); |
... | ... | |
1842 | 1851 |
} |
1843 | 1852 |
|
1844 | 1853 |
cli_msg(-1024, "%s:", p->p.name); |
1845 |
cli_msg(-1024, "%-25s %-10s %6s %6s %10s",
|
|
1846 |
"IP address", "Interface", "Metric", "Routes", "Next hello");
|
|
1854 |
cli_msg(-1024, "%-25s %-10s %6s %6s %6s %7s",
|
|
1855 |
"IP address", "Interface", "Metric", "Routes", "Hellos", "Expires");
|
|
1847 | 1856 |
|
1848 | 1857 |
WALK_LIST(ifa, p->interfaces) |
1849 | 1858 |
{ |
... | ... | |
1856 | 1865 |
WALK_LIST(r, n->routes) |
1857 | 1866 |
rts++; |
1858 | 1867 |
|
1859 |
int timer = n->hello_expiry - now; |
|
1860 |
cli_msg(-1024, "%-25I %-10s %6u %6u %10u", |
|
1861 |
n->addr, ifa->iface->name, n->txcost, rts, MAX(timer, 0)); |
|
1868 |
uint hellos = u32_popcount(n->hello_map); |
|
1869 |
btime timer = n->hello_expiry - current_time(); |
|
1870 |
cli_msg(-1024, "%-25I %-10s %6u %6u %6u %7t", |
|
1871 |
n->addr, ifa->iface->name, n->txcost, rts, hellos, MAX(timer, 0)); |
|
1862 | 1872 |
} |
1863 | 1873 |
} |
1864 | 1874 |
|
... | ... | |
1888 | 1898 |
else |
1889 | 1899 |
bsprintf(ridbuf, "%lR", r->router_id); |
1890 | 1900 |
|
1891 |
int time = r->expires ? r->expires - now : 0;
|
|
1892 |
cli_msg(-1025, "%-29N %-23s %6u %5u %7u %7u",
|
|
1901 |
btime time = r->expires ? r->expires - current_time() : 0;
|
|
1902 |
cli_msg(-1025, "%-29N %-23s %6u %5u %7t %7u",
|
|
1893 | 1903 |
e->n.addr, ridbuf, r->metric, r->seqno, MAX(time, 0), srcs); |
1894 | 1904 |
} |
1895 | 1905 |
else |
... | ... | |
1948 | 1958 |
static inline void |
1949 | 1959 |
babel_kick_timer(struct babel_proto *p) |
1950 | 1960 |
{ |
1951 |
if (p->timer->expires TO_S > (now + 1))
|
|
1952 |
tm_start(p->timer, 1);
|
|
1961 |
if (p->timer->expires > (current_time() + 100 MS))
|
|
1962 |
tm2_start(p->timer, 100 MS);
|
|
1953 | 1963 |
} |
1954 | 1964 |
|
1955 | 1965 |
|
... | ... | |
2032 | 2042 |
|
2033 | 2043 |
if (r != e->selected_out) |
2034 | 2044 |
{ |
2035 |
e->selected_out = r; |
|
2036 |
e->updated = now; |
|
2037 | 2045 |
babel_trigger_update(p); |
2046 |
e->updated = current_time(); |
|
2047 |
e->selected_out = r; |
|
2038 | 2048 |
} |
2039 | 2049 |
} |
2040 | 2050 |
else |
... | ... | |
2051 | 2061 |
* expiry time. This causes a retraction to be sent, and later the route |
2052 | 2062 |
* to be flushed once the hold time has passed. |
2053 | 2063 |
*/ |
2054 |
e->selected_out->metric = BABEL_INFINITY; |
|
2055 |
e->selected_out->expires = now + BABEL_HOLD_TIME; |
|
2056 |
e->updated = now; |
|
2057 | 2064 |
babel_trigger_update(p); |
2065 |
e->updated = current_time(); |
|
2066 |
e->selected_out->metric = BABEL_INFINITY; |
|
2067 |
e->selected_out->expires = current_time() + BABEL_HOLD_TIME; |
|
2058 | 2068 |
} |
2059 | 2069 |
else |
2060 | 2070 |
{ |
... | ... | |
2121 | 2131 |
OFFSETOF(struct babel_entry, n), 0, babel_init_entry); |
2122 | 2132 |
|
2123 | 2133 |
init_list(&p->interfaces); |
2124 |
p->timer = tm_new_set(P->pool, babel_timer, p, 0, 1);
|
|
2125 |
tm_start(p->timer, 2);
|
|
2134 |
p->timer = tm2_new_init(P->pool, babel_timer, p, 1 S, 0);
|
|
2135 |
tm2_start(p->timer, 1 S);
|
|
2126 | 2136 |
p->update_seqno = 1; |
2127 | 2137 |
p->router_id = proto_get_router_id(&cf->c); |
2128 | 2138 |
|
Also available in: Unified diff