rpl-lite: forget all link-statistics when leaving DAG

This commit is contained in:
Simon Duquennoy 2017-06-27 18:59:38 +02:00
parent 5df65382b3
commit dd85a89fbd
3 changed files with 19 additions and 1 deletions

View File

@ -201,6 +201,18 @@ periodic(void *ptr)
}
}
/*---------------------------------------------------------------------------*/
/* Resets link-stats module */
void
link_stats_reset(void)
{
struct link_stats *stats;
stats = nbr_table_head(link_stats);
while(stats != NULL) {
nbr_table_remove(link_stats, stats);
stats = nbr_table_next(link_stats, stats);
}
}
/*---------------------------------------------------------------------------*/
/* Initializes link-stats module */
void
link_stats_init(void)

View File

@ -54,7 +54,8 @@ struct link_stats {
const struct link_stats *link_stats_from_lladdr(const linkaddr_t *lladdr);
/* Are the statistics fresh? */
int link_stats_is_fresh(const struct link_stats *stats);
/* Resets link-stats module */
void link_stats_reset(void);
/* Initializes link-stats module */
void link_stats_init(void);
/* Packet sent callback. Updates statistics for transmissions on a given link */

View File

@ -46,6 +46,7 @@
#include "net/rpl-lite/rpl.h"
#include "net/nbr-table.h"
#include "net/link-stats.h"
/* Log configuration */
#include "sys/log.h"
@ -90,6 +91,9 @@ rpl_dag_leave(void)
RPL_LOLLIPOP_INCREMENT(curr_instance.dag.dao_curr_seqno);
rpl_icmp6_dao_output(0);
/* Forget past link statistics */
link_stats_reset();
/* Remove all neighbors */
rpl_neighbor_remove_all();
@ -195,6 +199,7 @@ rpl_local_repair(const char *str)
LOG_WARN("local repair (%s)\n", str);
curr_instance.of->reset(); /* Reset OF */
curr_instance.dag.state = DAG_INITIALIZED; /* Reset DAG state */
link_stats_reset(); /* Forget past link statistics */
rpl_neighbor_remove_all(); /* Remove all neighbors */
rpl_timers_dio_reset("Local repair"); /* Reset Trickle timer */
rpl_timers_schedule_state_update();