From a79fa138052d31bbc7bc8c8fcf0a616c3e163c04 Mon Sep 17 00:00:00 2001 From: Laurent Deru Date: Thu, 7 Dec 2017 14:52:37 +0100 Subject: [PATCH] Additional cleanup when becoming DODAG Root (rpl-classic) --- os/net/rpl-classic/rpl-dag.c | 8 ++++++++ os/net/rpl-classic/rpl-icmp6.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/os/net/rpl-classic/rpl-dag.c b/os/net/rpl-classic/rpl-dag.c index e4f4191b1..96f086b8d 100644 --- a/os/net/rpl-classic/rpl-dag.c +++ b/os/net/rpl-classic/rpl-dag.c @@ -370,6 +370,7 @@ rpl_set_root(uint8_t instance_id, uip_ipaddr_t *dag_id) } if(dag == dag->instance->current_dag) { PRINTF("RPL: Dropping a joined DAG when setting this node as root"); + rpl_set_default_route(instance, NULL); dag->instance->current_dag = NULL; } else { PRINTF("RPL: Dropping a DAG when setting this node as root"); @@ -665,6 +666,10 @@ rpl_free_dag(rpl_dag_t *dag) if(RPL_IS_STORING(dag->instance)) { rpl_remove_routes(dag); } + /* Stop the DAO retransmit timer */ +#if RPL_WITH_DAO_ACK + ctimer_stop(&dag->instance->dao_retransmit_timer); +#endif /* RPL_WITH_DAO_ACK */ /* Remove autoconfigured address */ if((dag->prefix_info.flags & UIP_ND6_RA_FLAG_AUTONOMOUS)) { @@ -1323,6 +1328,9 @@ rpl_local_repair(rpl_instance_t *instance) /* no downward route anymore */ instance->has_downward_route = 0; +#if RPL_WITH_DAO_ACK + ctimer_stop(&instance->dao_retransmit_timer); +#endif /* RPL_WITH_DAO_ACK */ rpl_reset_dio_timer(instance); if(RPL_IS_STORING(instance)) { diff --git a/os/net/rpl-classic/rpl-icmp6.c b/os/net/rpl-classic/rpl-icmp6.c index 6da3c2656..c5114fd14 100644 --- a/os/net/rpl-classic/rpl-icmp6.c +++ b/os/net/rpl-classic/rpl-icmp6.c @@ -1282,6 +1282,12 @@ dao_ack_input(void) parent = NULL; } + if(instance->current_dag->rank == ROOT_RANK(instance)) { + PRINTF("RPL: DODAG root received a DAO ACK, ignoring it\n"); + uip_clear_buf(); + return; + } + PRINTF("RPL: Received a DAO %s with sequence number %d (%d) and status %d from ", status < 128 ? "ACK" : "NACK", sequence, instance->my_dao_seqno, status);