summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Schiffer <mschiffer@universe-factory.net>2013-08-04 01:20:18 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2013-08-04 01:20:18 +0200
commit8c439585116b30cbbdf405d2001e21bc4998c154 (patch)
treed36be5dc4af19e516c5cfff251a8ec5797741991 /src
parenta8873733dcbca6f5f83dcdae1ccfefb95bcb18ab (diff)
downloadbabel-8c439585116b30cbbdf405d2001e21bc4998c154.tar
babel-8c439585116b30cbbdf405d2001e21bc4998c154.zip
Delete nexthop entries when a neighbour is reset
Diffstat (limited to 'src')
-rw-r--r--src/babel.h1
-rw-r--r--src/neigh.c13
-rw-r--r--src/route.c17
3 files changed, 23 insertions, 8 deletions
diff --git a/src/babel.h b/src/babel.h
index 0e1ebb9..46c19e4 100644
--- a/src/babel.h
+++ b/src/babel.h
@@ -139,6 +139,7 @@ void gp_babel_route_free(gmrf_context_t *ctx, gp_babel_route_t *route);
gp_babel_nexthop_t* gp_babel_route_nexthop_new(gp_babel_route_t *route, gp_babel_neigh_t *neigh);
gp_babel_nexthop_t* gp_babel_route_nexthop_find(const gp_babel_route_t *route, gp_babel_neigh_t *neigh);
+void gp_babel_route_nexthop_delete(gmrf_context_t *ctx, gp_babel_route_t *route, gp_babel_nexthop_t *nexthop);
void gp_babel_route_update_nexthop(gmrf_context_t *ctx, gp_babel_route_t *route, gp_babel_nexthop_t *nexthop, gp_babel_metric_seqno_t ms, uint16_t interval);
diff --git a/src/neigh.c b/src/neigh.c
index b97540d..86f8189 100644
--- a/src/neigh.c
+++ b/src/neigh.c
@@ -107,5 +107,18 @@ 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) {
+ gmrf_logf(ctx->gmrf, LOG_DEBUG, "resetting neighbour %02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x[%s].",
+ 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, neigh->iface->gmrf_iface));
+
+ gp_babel_route_t *route;
+ for (route = ctx->routes; route; route = route->next) {
+ gp_babel_nexthop_t *nexthop = gp_babel_route_nexthop_find(route, neigh);
+
+ if (nexthop)
+ gp_babel_route_nexthop_delete(ctx, route, nexthop);
+ }
+
gp_babel_send_route_request(ctx, iface, neigh, NULL);
}
diff --git a/src/route.c b/src/route.c
index ccb2d84..4daea64 100644
--- a/src/route.c
+++ b/src/route.c
@@ -32,14 +32,15 @@
gp_babel_route_t* gp_babel_route_new(gmrf_context_t *ctx) {
- gp_babel_route_t *a = calloc(1, sizeof(gp_babel_route_t));
+ gp_babel_route_t *route = calloc(1, sizeof(gp_babel_route_t));
- a->metric.metric = a->feasibility_distance.metric = a->last_metric = GP_BABEL_INFINITY;
+ route->metric.metric = route->feasibility_distance.metric = route->last_metric = GP_BABEL_INFINITY;
+ route->last_nexthop = gmrf_time_unspec;
- a->next = ctx->routes;
- ctx->routes = a;
+ route->next = ctx->routes;
+ ctx->routes = route;
- return a;
+ return route;
}
gp_babel_route_t* gp_babel_route_find(gmrf_context_t *ctx, const gp_babel_node_id_t *node) {
@@ -93,7 +94,7 @@ static inline bool nexthop_has_expired(gmrf_context_t *ctx, gp_babel_nexthop_t *
return (gp_babel_since(ctx, nexthop->last_update) > GP_BABEL_UPDATE_TIMEOUT(nexthop->interval));
}
-static void nexthop_delete(gmrf_context_t *ctx, gp_babel_route_t *route, gp_babel_nexthop_t *nexthop) {
+void gp_babel_route_nexthop_delete(gmrf_context_t *ctx, gp_babel_route_t *route, gp_babel_nexthop_t *nexthop) {
gp_babel_nexthop_t **nexthopp;
for (nexthopp = &route->nexthops; *nexthopp; nexthopp = &(*nexthopp)->next) {
if (*nexthopp == nexthop)
@@ -117,7 +118,7 @@ static void maintain_nexthop(gmrf_context_t *ctx, gp_babel_route_t *route, gp_ba
return;
if (nexthop_has_expired(ctx, nexthop)) {
- nexthop_delete(ctx, route, nexthop);
+ gp_babel_route_nexthop_delete(ctx, route, nexthop);
return;
}
@@ -194,7 +195,7 @@ void gp_babel_route_update(gmrf_context_t *ctx, gp_babel_route_t *route) {
void gp_babel_route_update_nexthop(gmrf_context_t *ctx, gp_babel_route_t *route, gp_babel_nexthop_t *nexthop, gp_babel_metric_seqno_t ms, uint16_t interval) {
if (ms.metric == GP_BABEL_INFINITY) {
gmrf_logf(ctx->gmrf, LOG_DEBUG, "retract received, deleting nexthop");
- nexthop_delete(ctx, route, nexthop);
+ gp_babel_route_nexthop_delete(ctx, route, nexthop);
gp_babel_route_update(ctx, route);
return;
}