diff options
Diffstat (limited to 'ffd/announce.c')
-rw-r--r-- | ffd/announce.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/ffd/announce.c b/ffd/announce.c index 99bf1aa..6b30ec6 100644 --- a/ffd/announce.c +++ b/ffd/announce.c @@ -28,6 +28,35 @@ #include "neigh.h" +static void maintain_nexthops(ffd_announce_t *announce) { + ffd_nexthop_t **cur, **next; + for (cur = &announce->nexthop_list; *cur; cur = next) { + ffd_nexthop_t *nexthop = *cur; + next = &nexthop->next; + + if (!nexthop->neigh) /* local */ + continue; + + if (timespec_diff(&now, &nexthop->last_update) > FFD_UPDATE_TIMEOUT(nexthop->interval)) { + if (nexthop->metric_seqno.metric == 0xffff) { + *cur = *next; + next = cur; + + if (announce->selected == nexthop) + announce->selected = NULL; + + nexthop->neigh->nexthop_refs--; + + free(nexthop); + } + else { + nexthop->metric_seqno.metric = 0xffff; + add_interval(&nexthop->last_update, FFD_UPDATE_TIMEOUT(nexthop->interval)); + } + } + } +} + static ffd_nexthop_t* select_nexthop(const ffd_announce_t *announce) { uint16_t ret_metric = 0xffff; ffd_nexthop_t *ret = NULL; @@ -63,6 +92,8 @@ ffd_metric_seqno_t get_metric(const ffd_announce_t *announce) { } void ffd_announce_update(ffd_announce_t *announce) { + maintain_nexthops(announce); + announce->selected = select_nexthop(announce); announce->metric = get_metric(announce); } |