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); 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 static void
rpl_set_preferred_parent(rpl_dag_t *dag, rpl_parent_t *p) 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; 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)) { if(!acceptable_rank(p->dag, p->rank)) {
/* The candidate parent is no longer valid: the rank increase resulting /* The candidate parent is no longer valid: the rank increase resulting
from the choice of it as a parent would be too high. */ from the choice of it as a parent would be too high. */

View file

@ -185,6 +185,14 @@ parent_is_acceptable(rpl_parent_t *p)
return link_metric <= MAX_LINK_METRIC && path_cost <= MAX_PATH_COST; return link_metric <= MAX_LINK_METRIC && path_cost <= MAX_PATH_COST;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int
parent_has_usable_link(rpl_parent_t *p)
{
uint16_t link_metric = parent_link_metric(p);
/* Exclude links with too high link metrics */
return link_metric <= MAX_LINK_METRIC;
}
/*---------------------------------------------------------------------------*/
static rpl_parent_t * static rpl_parent_t *
best_parent(rpl_parent_t *p1, rpl_parent_t *p2) best_parent(rpl_parent_t *p1, rpl_parent_t *p2)
{ {
@ -296,6 +304,7 @@ rpl_of_t rpl_mrhof = {
dao_ack_callback, dao_ack_callback,
#endif #endif
parent_link_metric, parent_link_metric,
parent_has_usable_link,
parent_path_cost, parent_path_cost,
rank_via_parent, rank_via_parent,
best_parent, best_parent,

View file

@ -155,6 +155,12 @@ parent_is_acceptable(rpl_parent_t *p)
&& STEP_OF_RANK(p) <= MAX_STEP_OF_RANK; && STEP_OF_RANK(p) <= MAX_STEP_OF_RANK;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int
parent_has_usable_link(rpl_parent_t *p)
{
return parent_is_acceptable(p);
}
/*---------------------------------------------------------------------------*/
static rpl_parent_t * static rpl_parent_t *
best_parent(rpl_parent_t *p1, rpl_parent_t *p2) best_parent(rpl_parent_t *p1, rpl_parent_t *p2)
{ {
@ -220,6 +226,7 @@ rpl_of_t rpl_of0 = {
dao_ack_callback, dao_ack_callback,
#endif #endif
parent_link_metric, parent_link_metric,
parent_has_usable_link,
parent_path_cost, parent_path_cost,
rank_via_parent, rank_via_parent,
best_parent, best_parent,

View file

@ -162,6 +162,10 @@ typedef struct rpl_instance rpl_instance_t;
* *
* Returns the link metric of a parent * Returns the link metric of a parent
* *
* parent_has_usable_link(parent)
*
* Returns 1 iff we have a usable link to this parent
*
* parent_path_cost(parent) * parent_path_cost(parent)
* *
* Returns the path cost of a parent * Returns the path cost of a parent
@ -200,6 +204,7 @@ struct rpl_of {
void (*dao_ack_callback)(rpl_parent_t *, int status); void (*dao_ack_callback)(rpl_parent_t *, int status);
#endif #endif
uint16_t (*parent_link_metric)(rpl_parent_t *); uint16_t (*parent_link_metric)(rpl_parent_t *);
int (*parent_has_usable_link)(rpl_parent_t *);
uint16_t (*parent_path_cost)(rpl_parent_t *); uint16_t (*parent_path_cost)(rpl_parent_t *);
rpl_rank_t (*rank_via_parent)(rpl_parent_t *); rpl_rank_t (*rank_via_parent)(rpl_parent_t *);
rpl_parent_t *(*best_parent)(rpl_parent_t *, rpl_parent_t *); rpl_parent_t *(*best_parent)(rpl_parent_t *, rpl_parent_t *);
@ -276,6 +281,7 @@ void rpl_remove_header(void);
uint8_t rpl_invert_header(void); uint8_t rpl_invert_header(void);
const struct link_stats *rpl_get_parent_link_stats(rpl_parent_t *p); const struct link_stats *rpl_get_parent_link_stats(rpl_parent_t *p);
int rpl_parent_is_fresh(rpl_parent_t *p); int rpl_parent_is_fresh(rpl_parent_t *p);
int rpl_parent_is_reachable(rpl_parent_t *p);
uint16_t rpl_get_parent_link_metric(rpl_parent_t *p); uint16_t rpl_get_parent_link_metric(rpl_parent_t *p);
rpl_rank_t rpl_rank_via_parent(rpl_parent_t *p); rpl_rank_t rpl_rank_via_parent(rpl_parent_t *p);
const linkaddr_t *rpl_get_parent_lladdr(rpl_parent_t *p); const linkaddr_t *rpl_get_parent_lladdr(rpl_parent_t *p);