Always try to find the best dag
@@ -762,13 +762,10 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
old_rank = instance->current_dag->rank;
last_parent = instance->current_dag->preferred_parent;
- best_dag = instance->current_dag;
- if(best_dag->rank != ROOT_RANK(instance)) {
- if(rpl_select_parent(p->dag) != NULL) {
- if(p->dag != best_dag) {
- best_dag = instance->of->best_dag(best_dag, p->dag);
+ if(instance->current_dag->rank != ROOT_RANK(instance)) {
+ rpl_select_parent(p->dag);
}
- } else if(p->dag == best_dag) {
+
best_dag = NULL;
for(dag = &instance->dag_table[0], end = dag + RPL_MAX_DAG_PER_INSTANCE; dag < end; ++dag) {
if(dag->used && dag->preferred_parent != NULL && dag->preferred_parent->rank != RPL_INFINITE_RANK) {
@@ -779,8 +776,6 @@ rpl_select_dag(rpl_instance_t *instance, rpl_parent_t *p)
}
}
}
- }
- }
if(best_dag == NULL) {
/* No parent found: the calling function handle this problem. */
