Routing API: added toplogy repair

This commit is contained in:
Simon Duquennoy 2017-12-09 08:45:10 -08:00
parent 4cab396d48
commit 53facf941e
10 changed files with 61 additions and 27 deletions

View File

@ -75,14 +75,7 @@ tsch_rpl_callback_joining_network(void)
void void
tsch_rpl_callback_leaving_network(void) tsch_rpl_callback_leaving_network(void)
{ {
rpl_dag_t *dag = rpl_get_any_dag(); NETSTACK_ROUTING.local_repair("TSCH leaving");
if(dag != NULL) {
#if UIP_CONF_IPV6_RPL_LITE
rpl_local_repair("TSCH leaving");
#else
rpl_local_repair(dag->instance);
#endif
}
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
/* Set TSCH EB period based on current RPL DIO period. /* Set TSCH EB period based on current RPL DIO period.

View File

@ -58,11 +58,23 @@ root_start(void)
return 0; return 0;
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void
global_repair(const char *str)
{
}
/*---------------------------------------------------------------------------*/
static void
local_repair(const char *str)
{
}
/*---------------------------------------------------------------------------*/
const struct routing_driver nullrouting_driver = { const struct routing_driver nullrouting_driver = {
"Null Routing", "Null Routing",
init, init,
root_set_prefix, root_set_prefix,
root_start, root_start,
global_repair,
local_repair
}; };
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -65,6 +65,19 @@ struct routing_driver {
* \return 0 in case of success, -1 otherwise * \return 0 in case of success, -1 otherwise
*/ */
int (* root_start)(void); int (* root_start)(void);
/**
* Triggers a global topology repair
*
* \param str A textual description of the cause for triggering a repair
*/
void (* global_repair)(const char *str);
/**
* Triggers a RPL local topology repair
*
* \param str A textual description of the cause for triggering a repair
*/
void (* local_repair)(const char *str);
}; };
#endif /* ROUTING_H_ */ #endif /* ROUTING_H_ */

View File

@ -353,11 +353,31 @@ init(void)
#endif /* RPL_WITH_NON_STORING */ #endif /* RPL_WITH_NON_STORING */
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static void
global_repair(const char *str)
{
rpl_dag_t *dag = rpl_get_any_dag();
if(dag != NULL && dag->instance != NULL) {
rpl_repair_root(dag->instance->instance_id);
}
}
/*---------------------------------------------------------------------------*/
static void
local_repair(const char *str)
{
rpl_dag_t *dag = rpl_get_any_dag();
if(dag != NULL) {
rpl_local_repair(dag->instance);
}
}
/*---------------------------------------------------------------------------*/
const struct routing_driver rpl_classic_driver = { const struct routing_driver rpl_classic_driver = {
"RPL Classic", "RPL Classic",
init, init,
rpl_dag_root_set_prefix, rpl_dag_root_set_prefix,
rpl_dag_root_start, rpl_dag_root_start,
global_repair,
local_repair,
}; };
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -169,11 +169,11 @@ find_objective_function(rpl_ocp_t ocp)
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void
rpl_global_repair(void) rpl_global_repair(const char *str)
{ {
if(rpl_dag_root_is_root()) { if(rpl_dag_root_is_root()) {
LOG_WARN("initiating global repair, version %u, rank %u)\n", LOG_WARN("initiating global repair (%s), version %u, rank %u)\n",
curr_instance.dag.version, curr_instance.dag.rank); str, curr_instance.dag.version, curr_instance.dag.rank);
#if LOG_INFO_ENABLED #if LOG_INFO_ENABLED
rpl_neighbor_print_list("Global repair (before)"); rpl_neighbor_print_list("Global repair (before)");
#endif /* LOG_INFO_ENABLED */ #endif /* LOG_INFO_ENABLED */
@ -391,7 +391,7 @@ process_dio_from_current_dag(uip_ipaddr_t *from, rpl_dio_t *dio)
LOG_ERR("inconsistent DIO version (current: %u, received: %u), initiate global repair\n", LOG_ERR("inconsistent DIO version (current: %u, received: %u), initiate global repair\n",
curr_instance.dag.version, dio->version); curr_instance.dag.version, dio->version);
curr_instance.dag.version = dio->version; /* Update version and trigger global repair */ curr_instance.dag.version = dio->version; /* Update version and trigger global repair */
rpl_global_repair(); rpl_global_repair("Inconsistent DIO version");
} else { } else {
LOG_WARN("new DIO version (current: %u, received: %u), apply global repair\n", LOG_WARN("new DIO version (current: %u, received: %u), apply global repair\n",
curr_instance.dag.version, dio->version); curr_instance.dag.version, dio->version);

View File

@ -78,8 +78,10 @@ void rpl_dag_periodic(unsigned seconds);
/** /**
* Triggers a RPL global repair * Triggers a RPL global repair
*
* \param str A textual description of the cause for triggering a repair
*/ */
void rpl_global_repair(void); void rpl_global_repair(const char *str);
/** /**
* Triggers a RPL local repair * Triggers a RPL local repair

View File

@ -198,6 +198,8 @@ const struct routing_driver rpl_lite_driver = {
init, init,
rpl_dag_root_set_prefix, rpl_dag_root_set_prefix,
rpl_dag_root_start, rpl_dag_root_start,
rpl_global_repair,
rpl_local_repair,
}; };
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/

View File

@ -88,11 +88,7 @@ PROCESS_THREAD(border_router_process, ev, data)
PROCESS_YIELD(); PROCESS_YIELD();
if(ev == sensors_event && data == &button_sensor) { if(ev == sensors_event && data == &button_sensor) {
LOG_INFO("Initiating global repair\n"); LOG_INFO("Initiating global repair\n");
#if UIP_CONF_IPV6_RPL_LITE NETSTACK_ROUTING.global_repair("Button press");
rpl_global_repair();
#else
rpl_repair_root(RPL_DEFAULT_INSTANCE);
#endif
} }
} }

View File

@ -121,11 +121,7 @@ border_router_cmd_handler(const uint8_t *data, int len)
case 'G': case 'G':
/* This is supposed to be from stdin */ /* This is supposed to be from stdin */
printf("Performing Global Repair...\n"); printf("Performing Global Repair...\n");
#if UIP_CONF_IPV6_RPL_LITE NETSTACK_ROUTING.global_repair("Command");
rpl_global_repair();
#else
rpl_repair_root(RPL_DEFAULT_INSTANCE);
#endif
return 1; return 1;
case 'C': { case 'C': {
/* send on a set-param thing! */ /* send on a set-param thing! */

View File

@ -395,8 +395,8 @@ PT_THREAD(cmd_rpl_global_repair(struct pt *pt, shell_output_func output, char *a
{ {
PT_BEGIN(pt); PT_BEGIN(pt);
SHELL_OUTPUT(output, "Triggering RPL global repair\n") SHELL_OUTPUT(output, "Triggering routing global repair\n")
rpl_global_repair(); NETSTACK_ROUTING.global_repair("Shell");
PT_END(pt); PT_END(pt);
} }
@ -406,8 +406,8 @@ PT_THREAD(cmd_rpl_local_repair(struct pt *pt, shell_output_func output, char *ar
{ {
PT_BEGIN(pt); PT_BEGIN(pt);
SHELL_OUTPUT(output, "Triggering RPL local repair\n"); SHELL_OUTPUT(output, "Triggering routing local repair\n");
rpl_local_repair("Shell"); NETSTACK_ROUTING.local_repair("Shell");
PT_END(pt); PT_END(pt);
} }