From b63b1bef96a3a089c5a95b47161dc620a6f82545 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sat, 3 Aug 2013 03:18:54 +0200 Subject: Add a neighbour packet timeout to prevent new neighbours to be purged right after a route request has been received --- src/babel.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/babel.c') diff --git a/src/babel.c b/src/babel.c index 06c972f..3c0e219 100644 --- a/src/babel.c +++ b/src/babel.c @@ -60,7 +60,15 @@ static void maintain_neighbours(gmrf_context_t *ctx) { gp_babel_neigh_t *neigh = *cur; next = &neigh->next; - if (gp_babel_neigh_get_rxcost(ctx, neigh) == GP_BABEL_INFINITY && gp_babel_neigh_get_txcost(ctx, neigh) == GP_BABEL_INFINITY && !neigh->ref) { + if ((gp_babel_neigh_get_rxcost(ctx, neigh) == GP_BABEL_INFINITY) + && (gp_babel_neigh_get_txcost(ctx, neigh) == GP_BABEL_INFINITY) + && (gp_babel_since(ctx, neigh->last_packet) > GP_BABEL_NEIGH_PACKET_TIMEOUT) + && !neigh->ref) { + gmrf_logf(ctx->gmrf, LOG_DEBUG, "maintenance: %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x[%s]: expired (%ims since last packet)", + 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->addr.d[6], neigh->addr.d[7], + gmrf_iface_get_name(ctx->gmrf, iface->gmrf_iface), (int)gp_babel_since(ctx, neigh->last_packet)*10); + *cur = *next; next = cur; free(neigh); -- cgit v1.2.3