Send announce request before expiry

This commit is contained in:
Matthias Schiffer 2012-10-08 01:59:06 +02:00
parent 15fbb0adbd
commit 46a05f9664
3 changed files with 24 additions and 6 deletions

View file

@ -27,6 +27,8 @@
#include "ffd.h" #include "ffd.h"
#include "neigh.h" #include "neigh.h"
#include <stdio.h>
static void maintain_nexthops(ffd_announce_t *announce) { static void maintain_nexthops(ffd_announce_t *announce) {
ffd_nexthop_t **cur, **next; ffd_nexthop_t **cur, **next;
@ -37,6 +39,16 @@ static void maintain_nexthops(ffd_announce_t *announce) {
if (!nexthop->neigh) /* local */ if (!nexthop->neigh) /* local */
continue; 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 (timespec_diff(&now, &nexthop->last_update) > FFD_UPDATE_TIMEOUT(nexthop->interval)) {
if (nexthop->metric_seqno.metric == 0xffff) { if (nexthop->metric_seqno.metric == 0xffff) {
*cur = *next; *cur = *next;
@ -54,10 +66,12 @@ static void maintain_nexthops(ffd_announce_t *announce) {
add_interval(&nexthop->last_update, FFD_UPDATE_TIMEOUT(nexthop->interval)); add_interval(&nexthop->last_update, FFD_UPDATE_TIMEOUT(nexthop->interval));
} }
} }
else if (!nexthop->neigh->iface && nexthop->metric_seqno.metric != 0xffff) { else if (timespec_diff(&now, &nexthop->last_update) > FFD_UPDATE_REQUEST_TIMEOUT(nexthop->interval) && announce->selected == nexthop) {
nexthop->metric_seqno.metric = 0xffff; if (!nexthop->requested_update) {
nexthop->last_update = now; fprintf(stderr, "info: announce about to expire, requesting update\n");
add_interval(&nexthop->last_update, FFD_UPDATE_TIMEOUT(nexthop->interval)); 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) { 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->metric_seqno = ms;
nexthop->interval = interval; nexthop->interval = interval;
nexthop->requested_update = false;
if (ms.metric != 0xffff) if (ms.metric != 0xffff)
nexthop->last_update = now; nexthop->last_update = now;

View file

@ -43,7 +43,9 @@
#define FFD_HELLO_TIMEOUT(interval) (16*(interval)) #define FFD_HELLO_TIMEOUT(interval) (16*(interval))
#define FFD_IHU_TIMEOUT(interval) ((interval)*7/2) #define FFD_IHU_TIMEOUT(interval) ((interval)*7/2)
#define FFD_UPDATE_TIMEOUT(interval) ((interval)*7/2) #define FFD_UPDATE_TIMEOUT(interval) ((interval)*7/2) /* 3.5 intervals */
#define FFD_UPDATE_REQUEST_TIMEOUT(interval) ((interval)*13/4) /* 3.25 intervals */
#define FFD_MAINTENANCE_INTERVAL FFD_HELLO_INTERVAL #define FFD_MAINTENANCE_INTERVAL FFD_HELLO_INTERVAL
@ -68,6 +70,7 @@ typedef struct _ffd_nexthop_t {
struct timespec last_update; struct timespec last_update;
uint16_t interval; uint16_t interval;
bool requested_update;
} ffd_nexthop_t; } ffd_nexthop_t;
typedef struct _ffd_announce_t { typedef struct _ffd_announce_t {

View file

@ -172,7 +172,7 @@ static bool add_update(ffd_packet_t *packet, size_t max_len, ffd_node_id_t *node
update->type = htons(announce->type); update->type = htons(announce->type);
update->key = htons(announce->key); update->key = htons(announce->key);
if (announce->len) { if (announce->len && announce->metric.metric != 0xff) {
update->flags |= FFD_UPDATE_WITH_DATA; update->flags |= FFD_UPDATE_WITH_DATA;
if (with_data) { if (with_data) {