Minor rpl-lite fixes for DAG leaving/joining
This commit is contained in:
parent
38ce63a614
commit
c6537820b1
@ -220,7 +220,7 @@ PT_THREAD(cmd_rpl_set_root(struct pt *pt, shell_output_func output, char *args))
|
|||||||
} else {
|
} else {
|
||||||
if(rpl_dag_root_is_root()) {
|
if(rpl_dag_root_is_root()) {
|
||||||
SHELL_OUTPUT(output, "Setting as non-root node: leaving DAG\n");
|
SHELL_OUTPUT(output, "Setting as non-root node: leaving DAG\n");
|
||||||
rpl_dag_leave();
|
rpl_dag_poison_and_leave();
|
||||||
} else {
|
} else {
|
||||||
SHELL_OUTPUT(output, "Node is not a DAG root\n");
|
SHELL_OUTPUT(output, "Node is not a DAG root\n");
|
||||||
}
|
}
|
||||||
|
@ -88,8 +88,10 @@ rpl_dag_leave(void)
|
|||||||
LOG_INFO_(", instance %u\n", curr_instance.instance_id);
|
LOG_INFO_(", instance %u\n", curr_instance.instance_id);
|
||||||
|
|
||||||
/* Issue a no-path DAO */
|
/* Issue a no-path DAO */
|
||||||
|
if(!rpl_dag_root_is_root()) {
|
||||||
RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_curr_seqno);
|
RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_curr_seqno);
|
||||||
rpl_icmp6_dao_output(0);
|
rpl_icmp6_dao_output(0);
|
||||||
|
}
|
||||||
|
|
||||||
/* Forget past link statistics */
|
/* Forget past link statistics */
|
||||||
link_stats_reset();
|
link_stats_reset();
|
||||||
@ -111,6 +113,13 @@ rpl_dag_leave(void)
|
|||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
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)
|
rpl_dag_periodic(unsigned seconds)
|
||||||
{
|
{
|
||||||
if(curr_instance.used) {
|
if(curr_instance.used) {
|
||||||
@ -223,11 +232,13 @@ rpl_dag_ready_to_advertise(void)
|
|||||||
void
|
void
|
||||||
rpl_dag_update_state(void)
|
rpl_dag_update_state(void)
|
||||||
{
|
{
|
||||||
if(curr_instance.used) {
|
rpl_rank_t old_rank;
|
||||||
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;
|
|
||||||
|
|
||||||
|
if(!curr_instance.used) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
old_rank = curr_instance.dag.rank;
|
||||||
/* Any scheduled state update is no longer needed */
|
/* Any scheduled state update is no longer needed */
|
||||||
rpl_timers_unschedule_state_update();
|
rpl_timers_unschedule_state_update();
|
||||||
|
|
||||||
@ -240,7 +251,8 @@ rpl_dag_update_state(void)
|
|||||||
rpl_timers_dio_reset("Poison routes");
|
rpl_timers_dio_reset("Poison routes");
|
||||||
rpl_timers_schedule_leaving();
|
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;
|
rpl_nbr_t *nbr;
|
||||||
|
|
||||||
/* Select and set preferred parent */
|
/* Select and set preferred parent */
|
||||||
@ -304,16 +316,14 @@ rpl_dag_update_state(void)
|
|||||||
rpl_timers_schedule_leaving();
|
rpl_timers_schedule_leaving();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if LOG_INFO_ENABLED
|
#if LOG_INFO_ENABLED
|
||||||
rpl_neighbor_print_list("Parent switch");
|
rpl_neighbor_print_list("Parent switch");
|
||||||
#endif /* LOG_INFO_ENABLED */
|
#endif /* LOG_INFO_ENABLED */
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finally, update metric container */
|
/* Finally, update metric container */
|
||||||
curr_instance.of->update_metric_container();
|
curr_instance.of->update_metric_container();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static rpl_nbr_t *
|
static rpl_nbr_t *
|
||||||
|
@ -57,6 +57,11 @@
|
|||||||
* \return The description string
|
* \return The description string
|
||||||
*/
|
*/
|
||||||
const char *rpl_dag_state_to_str(enum rpl_dag_state state);
|
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
|
* Leaves the current DAG
|
||||||
*
|
*
|
||||||
|
@ -557,10 +557,19 @@ rpl_icmp6_dao_output(uint8_t lifetime)
|
|||||||
/* Make sure we're up-to-date before sending data out */
|
/* Make sure we're up-to-date before sending data out */
|
||||||
rpl_dag_update_state();
|
rpl_dag_update_state();
|
||||||
|
|
||||||
if(!curr_instance.used || curr_instance.dag.preferred_parent == NULL
|
if(!curr_instance.used) {
|
||||||
|| prefix == NULL || parent_ipaddr == NULL || curr_instance.mop == RPL_MOP_NO_DOWNWARD_ROUTES) {
|
LOG_WARN("rpl_icmp6_dao_output: not in an instance, skip sending DAO\n");
|
||||||
LOG_WARN("rpl_icmp6_dao_output: node not ready to send a DAO (used %u, pref parent %u, prefix %u, mop %u)\n",
|
return;
|
||||||
curr_instance.used, curr_instance.dag.preferred_parent != NULL && parent_ipaddr != NULL, prefix != NULL, curr_instance.mop);
|
}
|
||||||
|
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user