summaryrefslogtreecommitdiffstats
path: root/ffd/announce.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffd/announce.c')
-rw-r--r--ffd/announce.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/ffd/announce.c b/ffd/announce.c
index 62e876a..151d1b3 100644
--- a/ffd/announce.c
+++ b/ffd/announce.c
@@ -27,6 +27,8 @@
#include "ffd.h"
#include "neigh.h"
+#include <stdio.h>
+
static void maintain_nexthops(ffd_announce_t *announce) {
ffd_nexthop_t **cur, **next;
@@ -37,6 +39,16 @@ static void maintain_nexthops(ffd_announce_t *announce) {
if (!nexthop->neigh) /* local */
continue;
+ if (!nexthop->neigh->iface) {
+ if (nexthop->metric_seqno.metric != 0xffff) {
+ nexthop->metric_seqno.metric = 0xffff;
+ nexthop->last_update = now;
+ add_interval(&nexthop->last_update, FFD_UPDATE_TIMEOUT(nexthop->interval));
+ }
+
+ continue;
+ }
+
if (timespec_diff(&now, &nexthop->last_update) > FFD_UPDATE_TIMEOUT(nexthop->interval)) {
if (nexthop->metric_seqno.metric == 0xffff) {
*cur = *next;
@@ -54,10 +66,12 @@ static void maintain_nexthops(ffd_announce_t *announce) {
add_interval(&nexthop->last_update, FFD_UPDATE_TIMEOUT(nexthop->interval));
}
}
- else if (!nexthop->neigh->iface && nexthop->metric_seqno.metric != 0xffff) {
- nexthop->metric_seqno.metric = 0xffff;
- nexthop->last_update = now;
- add_interval(&nexthop->last_update, FFD_UPDATE_TIMEOUT(nexthop->interval));
+ else if (timespec_diff(&now, &nexthop->last_update) > FFD_UPDATE_REQUEST_TIMEOUT(nexthop->interval) && announce->selected == nexthop) {
+ if (!nexthop->requested_update) {
+ fprintf(stderr, "info: announce about to expire, requesting update\n");
+ ffd_send_announce_request(nexthop->neigh->iface, nexthop->neigh, announce->node, announce->type, announce->key, false);
+ nexthop->requested_update = true;
+ }
}
}
}
@@ -106,6 +120,7 @@ void ffd_announce_update(ffd_announce_t *announce) {
void ffd_announce_update_nexthop(ffd_announce_t *announce, ffd_nexthop_t *nexthop, ffd_metric_seqno_t ms, uint16_t interval) {
nexthop->metric_seqno = ms;
nexthop->interval = interval;
+ nexthop->requested_update = false;
if (ms.metric != 0xffff)
nexthop->last_update = now;