Minor rpl-lite fixes for DAG leaving/joining

This commit is contained in:
Simon Duquennoy 2017-07-14 14:29:17 +02:00
parent 38ce63a614
commit c6537820b1
4 changed files with 114 additions and 90 deletions

View File

@ -220,7 +220,7 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args))
} else {
if(rpl_dag_root_is_root()) {
SHELL_OUTPUT(output, "Setting as non-root node: leaving DAG\n");
rpl_dag_leave();
rpl_dag_poison_and_leave();
} else {
SHELL_OUTPUT(output, "Node is not a DAG root\n");
}

View File

@ -88,8 +88,10 @@ rpl_dag_leave(void)
LOG_INFO_(", instance %u\n", curr_instance.instance_id);
/* Issue a no-path DAO */
if(!rpl_dag_root_is_root()) {
RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_curr_seqno);
rpl_icmp6_dao_output(0);
}
/* Forget past link statistics */
link_stats_reset();
@ -111,6 +113,13 @@ rpl_dag_leave(void)
}
/*---------------------------------------------------------------------------*/
void
rpl_dag_poison_and_leave(void)
{
curr_instance.dag.state = DAG_POISONING;
rpl_timers_schedule_state_update();
}
/*---------------------------------------------------------------------------*/
void
rpl_dag_periodic(unsigned seconds)
{
if(curr_instance.used) {
@ -223,11 +232,13 @@ rpl_dag_ready_to_advertise(void)
void
rpl_dag_update_state(void)
{
if(curr_instance.used) {
if(!rpl_dag_root_is_root()) {
rpl_nbr_t *old_parent = curr_instance.dag.preferred_parent;
rpl_rank_t old_rank = curr_instance.dag.rank;
rpl_rank_t old_rank;
if(!curr_instance.used) {
return;
}
old_rank = curr_instance.dag.rank;
/* Any scheduled state update is no longer needed */
rpl_timers_unschedule_state_update();
@ -240,7 +251,8 @@ rpl_dag_update_state(void)
rpl_timers_dio_reset("Poison routes");
rpl_timers_schedule_leaving();
}
} else {
} else if(!rpl_dag_root_is_root()) {
rpl_nbr_t *old_parent = curr_instance.dag.preferred_parent;
rpl_nbr_t *nbr;
/* Select and set preferred parent */
@ -309,12 +321,10 @@ rpl_dag_update_state(void)
#endif /* LOG_INFO_ENABLED */
}
}
}
/* Finally, update metric container */
curr_instance.of->update_metric_container();
}
}
/*---------------------------------------------------------------------------*/
static rpl_nbr_t *
update_nbr_from_dio(uip_ipaddr_t *from, rpl_dio_t *dio)

View File

@ -57,6 +57,11 @@
* \return The description string
*/
const char *rpl_dag_state_to_str(enum rpl_dag_state state);
/**
* Start poisoning and leave the DAG after a delay
*
*/
void rpl_dag_poison_and_leave(void);
/**
* Leaves the current DAG
*

View File

@ -557,10 +557,19 @@ rpl_icmp6_dao_output(uint8_t lifetime)
/* Make sure we're up-to-date before sending data out */
rpl_dag_update_state();
if(!curr_instance.used || curr_instance.dag.preferred_parent == NULL
|| prefix == NULL || parent_ipaddr == NULL || curr_instance.mop == RPL_MOP_NO_DOWNWARD_ROUTES) {
LOG_WARN("rpl_icmp6_dao_output: node not ready to send a DAO (used %u, pref parent %u, prefix %u, mop %u)\n",
curr_instance.used, curr_instance.dag.preferred_parent != NULL && parent_ipaddr != NULL, prefix != NULL, curr_instance.mop);
if(!curr_instance.used) {
LOG_WARN("rpl_icmp6_dao_output: not in an instance, skip sending DAO\n");
return;
}
if(curr_instance.dag.preferred_parent == NULL) {
LOG_WARN("rpl_icmp6_dao_output: no preferred parent, skip sending DAO\n");
return;
}
if(prefix == NULL || parent_ipaddr == NULL || curr_instance.mop == RPL_MOP_NO_DOWNWARD_ROUTES) {
LOG_WARN("rpl_icmp6_dao_output: node not ready to send a DAO (prefix %p, parent addr %p, mop %u)\n",
prefix, parent_ipaddr, curr_instance.mop);
return;
}