RPL: if a neighbor is unreachable, remove routes via this neighbor

This commit is contained in:
Simon Duquennoy 2015-11-30 19:17:17 +01:00 committed by Simon Duquennoy
parent b73b6082fc
commit 797bead5e5
4 changed files with 46 additions and 0 deletions

View file

@ -210,6 +210,23 @@ rpl_parent_is_fresh(rpl_parent_t *p)
return link_stats_is_fresh(stats);
}
/*---------------------------------------------------------------------------*/
int
rpl_parent_is_reachable(rpl_parent_t *p) {
if(p == NULL || p->dag == NULL || p->dag->instance == NULL || p->dag->instance->of == NULL) {
return 0;
} else {
#ifndef UIP_CONF_ND6_SEND_NA
uip_ds6_nbr_t *nbr = rpl_get_nbr(p);
/* Exclude links to a neighbor that is not reachable at a NUD level */
if(nbr == NULL || nbr->state != NBR_REACHABLE) {
return 0;
}
#endif /* UIP_CONF_ND6_SEND_NA */
/* If we don't have fresh link information, assume the parent is reachable. */
return !rpl_parent_is_fresh(p) || p->dag->instance->of->parent_has_usable_link(p);
}
}
/*---------------------------------------------------------------------------*/
static void
rpl_set_preferred_parent(rpl_dag_t *dag, rpl_parent_t *p)
{
@ -1316,6 +1333,13 @@ rpl_process_parent_event(rpl_instance_t *instance, rpl_parent_t *p)
return_value = 1;
if(uip_ds6_route_is_nexthop(rpl_get_parent_ipaddr(p)) && !rpl_parent_is_reachable(p)) {
PRINTF("RPL: Unacceptable link %u, removing routes via: ", rpl_get_parent_link_metric(p));
PRINT6ADDR(rpl_get_parent_ipaddr(p));
PRINTF("\n");
rpl_remove_routes_by_nexthop(rpl_get_parent_ipaddr(p), p->dag);
}
if(!acceptable_rank(p->dag, p->rank)) {
/* The candidate parent is no longer valid: the rank increase resulting
from the choice of it as a parent would be too high. */