fixed RPL to handle inifinite rank better
This commit is contained in:
parent
f603c965c1
commit
02fcf5835a
2 changed files with 11 additions and 3 deletions
|
@ -342,13 +342,20 @@ rpl_select_parent(rpl_dag_t *dag)
|
||||||
|
|
||||||
best = NULL;
|
best = NULL;
|
||||||
for(p = list_head(dag->parents); p != NULL; p = p->next) {
|
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;
|
best = p;
|
||||||
} else {
|
} else {
|
||||||
best = dag->of->best_parent(best, p);
|
best = dag->of->best_parent(best, p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(best == NULL) {
|
||||||
|
/* need to handle update of best... */
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(dag->preferred_parent != best) {
|
if(dag->preferred_parent != best) {
|
||||||
dag->preferred_parent = best; /* Cache the value. */
|
dag->preferred_parent = best; /* Cache the value. */
|
||||||
dag->of->update_metric_container(dag);
|
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);
|
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
|
/* 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. */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
#include "net/uip-ds6.h"
|
#include "net/uip-ds6.h"
|
||||||
#include "net/uip-packetqueue.h"
|
#include "net/uip-packetqueue.h"
|
||||||
|
|
||||||
#define DEBUG DEBUG_ANNOTATE
|
#define DEBUG DEBUG_NONE
|
||||||
#include "net/uip-debug.h"
|
#include "net/uip-debug.h"
|
||||||
|
|
||||||
#ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
|
#ifdef UIP_CONF_DS6_NEIGHBOR_STATE_CHANGED
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue