summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-03 03:18:54 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-03 03:18:54 +0200
commitb63b1bef96a3a089c5a95b47161dc620a6f82545 (patch)
treeb7f66fb4caa5fef3a4d797539938ba77b72c86e7 /src
parent48f77c26dcb4a9e8d09e718f1b16e6b97c04d9b9 (diff)
downloadbabel-b63b1bef96a3a089c5a95b47161dc620a6f82545.tar
babel-b63b1bef96a3a089c5a95b47161dc620a6f82545.zip
Add a neighbour packet timeout to prevent new neighbours to be purged right after a route request has been received
Diffstat (limited to 'src')
-rw-r--r--src/babel.c10
-rw-r--r--src/babel.h2
-rw-r--r--src/neigh.c4
-rw-r--r--src/tlv_types.c18
4 files changed, 24 insertions, 10 deletions
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);
diff --git a/src/babel.h b/src/babel.h
index 0b0b4d4..625b570 100644
--- a/src/babel.h
+++ b/src/babel.h
@@ -45,6 +45,7 @@
#define GP_BABEL_UPDATE_REQUEST_TIMEOUT(interval) ((interval)*13/4) /* 3.25 intervals */
#define GP_BABEL_MAINTENANCE_INTERVAL GP_BABEL_HELLO_INTERVAL
+#define GP_BABEL_NEIGH_PACKET_TIMEOUT 6000
#define GP_BABEL_SEQNO_REQ_HOP_LIMIT 127
@@ -75,6 +76,7 @@ struct gp_babel_neigh {
gp_babel_neigh_t *next;
unsigned ref;
+ gmrf_time_t last_packet;
gmrf_iface_state_t *iface;
gmrf_addr_t addr;
diff --git a/src/neigh.c b/src/neigh.c
index bffbaa4..a114181 100644
--- a/src/neigh.c
+++ b/src/neigh.c
@@ -36,6 +36,7 @@ gp_babel_neigh_t* gp_babel_neigh_get(gmrf_iface_state_t *iface, const gmrf_addr_
neigh->next = iface->neighbours;
neigh->iface = iface;
iface->neighbours = neigh;
+ neigh->last_packet = gmrf_time_unspec;
neigh->last_hello = gmrf_time_unspec;
neigh->last_ihu = gmrf_time_unspec;
neigh->addr = *addr;
@@ -106,5 +107,6 @@ uint16_t gp_babel_neigh_get_cost(gmrf_context_t *ctx, const gp_babel_neigh_t *ne
}
void gp_babel_neigh_reset(gmrf_context_t *ctx, gmrf_iface_state_t *iface, gp_babel_neigh_t *neigh) {
- gp_babel_send_route_request(ctx, iface, neigh, NULL);
+
+ //gp_babel_send_route_request(ctx, iface, neigh, NULL);
}
diff --git a/src/tlv_types.c b/src/tlv_types.c
index 12b7248..fd96e98 100644
--- a/src/tlv_types.c
+++ b/src/tlv_types.c
@@ -39,8 +39,10 @@ typedef struct handle_tlv_arg {
gp_babel_node_id_t node_id;
} handle_tlv_arg_t;
-static inline gp_babel_neigh_t* get_tlv_neigh(handle_tlv_arg_t *arg) {
- return gp_babel_neigh_get(arg->iface, arg->source);
+static inline gp_babel_neigh_t* get_tlv_neigh(gmrf_context_t *ctx, handle_tlv_arg_t *arg) {
+ gp_babel_neigh_t *neigh = gp_babel_neigh_get(arg->iface, arg->source);
+ neigh->last_packet = gmrf_now(ctx->gmrf);
+ return neigh;
}
static void handle_tlv_ack_req(gmrf_context_t *ctx, const gp_babel_tlv_ack_req_t *tlv, size_t len, handle_tlv_arg_t *arg) {
@@ -49,7 +51,7 @@ static void handle_tlv_ack_req(gmrf_context_t *ctx, const gp_babel_tlv_ack_req_t
return;
}
- gp_babel_send_ack(ctx, get_tlv_neigh(arg), ntohs(tlv->nonce));
+ gp_babel_send_ack(ctx, get_tlv_neigh(ctx, arg), ntohs(tlv->nonce));
}
static void handle_tlv_ack(gmrf_context_t *ctx, const gp_babel_tlv_ack_t *tlv, size_t len, handle_tlv_arg_t *arg) {
@@ -72,7 +74,7 @@ static void handle_tlv_hello(gmrf_context_t *ctx, const gp_babel_tlv_hello_t *tl
arg->source->d[4], arg->source->d[5], arg->source->d[6], arg->source->d[7],
gmrf_iface_get_name(ctx->gmrf, arg->iface->gmrf_iface), ntohs(tlv->seqno));
- gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
+ gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg);
uint16_t seqno = ntohs(tlv->seqno);
@@ -131,7 +133,7 @@ static void handle_tlv_ihu(gmrf_context_t *ctx, const gp_babel_tlv_ihu_t *tlv, s
return;
}
- gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
+ gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg);
neigh->ihu_interval = ntohs(tlv->interval);
neigh->last_ihu = gmrf_now(ctx->gmrf);
neigh->txcost = ntohs(tlv->rxcost);
@@ -177,7 +179,7 @@ static void handle_tlv_update(gmrf_context_t *ctx, const gp_babel_tlv_update_t *
bool feasible = gp_babel_is_feasible(route, ms);
- gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
+ gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg);
gp_babel_nexthop_t *nexthop = gp_babel_route_nexthop_find(route, neigh);
gmrf_logf(ctx->gmrf, LOG_DEBUG, "update received from %04x%04x, metric %u, seqno %04x.",
@@ -218,7 +220,7 @@ static void handle_tlv_route_req(gmrf_context_t *ctx, const gp_babel_tlv_route_r
return;
}
- gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
+ gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg);
if (gp_babel_node_id_is_unspec(&tlv->node)) {
gmrf_logf(ctx->gmrf, LOG_DEBUG, "received wildcard route request, dumping table.");
@@ -253,7 +255,7 @@ static void handle_tlv_seqno_req(gmrf_context_t *ctx, const gp_babel_tlv_seqno_r
ntohl(*(uint32_t*)tlv->node.id), ntohl(*(uint32_t*)(tlv->node.id+4)),
ntohs(tlv->seqno));
- gp_babel_neigh_t *neigh = get_tlv_neigh(arg);
+ gp_babel_neigh_t *neigh = get_tlv_neigh(ctx, arg);
if (!gp_babel_less(route->metric.seqno, ntohs(tlv->seqno))) {
/* local seqno is high enough */