fixed RPL to handle inifinite rank better

This commit is contained in:
Joakim Eriksson 2011-04-07 17:44:07 +02:00
parent f603c965c1
commit 02fcf5835a
2 changed files with 11 additions and 3 deletions

View file

@ -342,13 +342,20 @@ rpl_select_parent(rpl_dag_t *dag)
best = NULL;
for(p = list_head(dag->parents); p != NULL; p = p->next) {
if(best == NULL) {
if(p->rank == INFINITE_RANK) {
/* ignore this neighbor */
} else if(best == NULL) {
best = p;
} else {
best = dag->of->best_parent(best, p);
}
}
if(best == NULL) {
/* need to handle update of best... */
return NULL;
}
if(dag->preferred_parent != best) {
dag->preferred_parent = best; /* Cache the value. */
dag->of->update_metric_container(dag);
@ -642,7 +649,8 @@ rpl_process_parent_event(rpl_dag_t *dag, rpl_parent_t *p)
rpl_reset_dio_timer(dag, 1);
}
if(!acceptable_rank(dag, dag->of->calculate_rank(NULL, parent_rank))) {
if(parent_rank == INFINITE_RANK ||
!acceptable_rank(dag, dag->of->calculate_rank(NULL, parent_rank))) {
/* The candidate parent is no longer valid: the rank increase resulting
from the choice of it as a parent would be too high. */
return 0;

View file

@ -47,7 +47,7 @@
#include "net/uip-ds6.h"
#include "net/uip-packetqueue.h"
#define DEBUG DEBUG_ANNOTATE
#define DEBUG DEBUG_NONE
#include "net/uip-debug.h"
#ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED