summaryrefslogtreecommitdiffstats
path: root/ffd/ffd.c
diff options
context:
space:
mode:
Diffstat (limited to 'ffd/ffd.c')
-rw-r--r--ffd/ffd.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/ffd/ffd.c b/ffd/ffd.c
index 7cc3d3f..f5b3271 100644
--- a/ffd/ffd.c
+++ b/ffd/ffd.c
@@ -170,8 +170,7 @@ static void update_netifs(void) {
if (iface->type == IF_UNSPEC) {
*cur = iface->next;
-
- ffd_neigh_free_list(iface->neigh_list);
+ ffd_neigh_unref_list(iface->neigh_list);
free(iface);
}
else {
@@ -320,7 +319,7 @@ static ffd_nexthop_t* new_nexthop(ffd_announce_t *announce, ffd_neigh_t *neigh)
nexthop->next = announce->nexthop_list;
announce->nexthop_list = nexthop;
- neigh->nexthop_refs++;
+ ffd_neigh_ref(neigh);
return nexthop;
}
@@ -475,6 +474,8 @@ static void send_updates(void) {
}
static void maintenance(void) {
+ update_netifs();
+
ffd_iface_t *iface;
for (iface = iface_list; iface; iface = iface->next) {
ffd_neigh_t **cur, **next;
@@ -482,7 +483,7 @@ static void maintenance(void) {
ffd_neigh_t *neigh = *cur;
next = &neigh->next;
- if (ffd_neigh_get_rxcost(neigh) == 0xffff && ffd_neigh_get_txcost(neigh) == 0xffff && !neigh->nexthop_refs) {
+ if (ffd_neigh_get_rxcost(neigh) == 0xffff && ffd_neigh_get_txcost(neigh) == 0xffff && !neigh->ref) {
*cur = *next;
next = cur;
free(neigh);
@@ -524,9 +525,10 @@ static void maintenance(void) {
continue;
}
- fprintf(stderr, "\tnexthop: %02x:%02x:%02x:%02x:%02x:%02x (%u, seqno=%04x, cost=%u%s)\n",
+ fprintf(stderr, "\tnexthop: %02x:%02x:%02x:%02x:%02x:%02x[%s] (%u, seqno=%04x, cost=%u%s)\n",
neigh->addr.d[0], neigh->addr.d[1], neigh->addr.d[2],
neigh->addr.d[3], neigh->addr.d[4], neigh->addr.d[5],
+ neigh->iface ? neigh->iface->name : NULL,
nexthop->metric_seqno.metric, nexthop->metric_seqno.seqno, ffd_neigh_get_cost(neigh),
(nexthop == announce->selected) ? ", selected" : "");
}
@@ -550,7 +552,12 @@ int main() {
struct timespec next_maintenance = now;
while (true) {
- update_netifs();
+ int maintenance_timeout = timespec_diff(&next_maintenance, &now);
+ if (maintenance_timeout <= 0) {
+ maintenance();
+
+ add_interval(&next_maintenance, FFD_MAINTENANCE_INTERVAL);
+ }
int hello_timeout = timespec_diff(&next_hello, &now);
if (hello_timeout <= 0) {
@@ -567,13 +574,6 @@ int main() {
add_interval(&next_update, FFD_UPDATE_INTERVAL);
}
- int maintenance_timeout = timespec_diff(&next_maintenance, &now);
- if (maintenance_timeout <= 0) {
- maintenance();
-
- add_interval(&next_maintenance, FFD_MAINTENANCE_INTERVAL);
- }
-
int timeout = min(min(hello_timeout, update_timeout), maintenance_timeout);
if (timeout <= 0)
continue;