From 02fcf5835a77c1169f8840dde0f7ce949d34e7d6 Mon Sep 17 00:00:00 2001 From: Joakim Eriksson Date: Thu, 7 Apr 2011 17:44:07 +0200 Subject: [PATCH] fixed RPL to handle inifinite rank better --- core/net/rpl/rpl-dag.c | 12 ++++++++++-- core/net/uip-ds6.c | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index bcd16a514..664422f0a 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -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; diff --git a/core/net/uip-ds6.c b/core/net/uip-ds6.c index 9d794cc17..7e3cf1882 100644 --- a/core/net/uip-ds6.c +++ b/core/net/uip-ds6.c @@ -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