diff --git a/core/net/rpl/rpl-dag.c b/core/net/rpl/rpl-dag.c index 89be40184..9d140fbd4 100644 --- a/core/net/rpl/rpl-dag.c +++ b/core/net/rpl/rpl-dag.c @@ -938,6 +938,15 @@ rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio) rpl_parent_t *p; rpl_of_t *of; + /* Determine the objective function by using the + objective code point of the DIO. */ + of = rpl_find_of(dio->ocp); + if(of == NULL) { + PRINTF("RPL: DIO for DAG instance %u does not specify a supported OF: %u\n", + dio->instance_id, dio->ocp); + return; + } + dag = rpl_alloc_dag(dio->instance_id, &dio->dag_id); if(dag == NULL) { PRINTF("RPL: Failed to allocate a DAG object!\n"); @@ -958,17 +967,6 @@ rpl_join_instance(uip_ipaddr_t *from, rpl_dio_t *dio) p->dtsn = dio->dtsn; PRINTF("succeeded\n"); - /* Determine the objective function by using the - objective code point of the DIO. */ - of = rpl_find_of(dio->ocp); - if(of == NULL) { - PRINTF("RPL: DIO for DAG instance %u does not specify a supported OF\n", - dio->instance_id); - rpl_remove_parent(p); - instance->used = 0; - return; - } - /* Autoconfigure an address if this node does not already have an address with this prefix. */ if(dio->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS) {