Skip to content

Commit bf909d2

Browse files
author
Mika Tervonen
committed
Modified bbr restart mechanism when dodagid was lost
Instance id is only increased when bbr stop was called by application meaning it is only used in testing purposes dodag_root_delete now only removes us from root and allows information to be retained. rpl_dodag_was_root added to check if we were root before and ignore the dodag DIOs and advertisements Fixed compile problem in bootstrap
1 parent 0a6fb58 commit bf909d2

File tree

7 files changed

+33
-22
lines changed

7 files changed

+33
-22
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,6 @@ static void ws_bbr_rpl_root_start(uint8_t *dodag_id)
123123
if (protocol_6lowpan_rpl_root_dodag) {
124124
rpl_control_delete_dodag_root(protocol_6lowpan_rpl_domain, protocol_6lowpan_rpl_root_dodag);
125125
protocol_6lowpan_rpl_root_dodag = NULL;
126-
current_instance_id++;
127126
}
128127

129128
protocol_6lowpan_rpl_root_dodag = rpl_control_create_dodag_root(protocol_6lowpan_rpl_domain, current_instance_id, dodag_id, &rpl_conf, rpl_conf.min_hop_rank_increase, RPL_GROUNDED | RPL_MODE_NON_STORING | RPL_DODAG_PREF(0));
@@ -141,7 +140,6 @@ static void ws_bbr_rpl_root_stop(void)
141140
if (protocol_6lowpan_rpl_root_dodag) {
142141
rpl_control_delete_dodag_root(protocol_6lowpan_rpl_domain, protocol_6lowpan_rpl_root_dodag);
143142
protocol_6lowpan_rpl_root_dodag = NULL;
144-
current_instance_id++;
145143
}
146144
memset(current_local_prefix, 0, 8);
147145
memset(current_global_prefix, 0, 8);
@@ -610,12 +608,7 @@ void ws_bbr_stop(int8_t interface_id)
610608
(void)interface_id;
611609
backbone_interface_id = -1;
612610

613-
if (!protocol_6lowpan_rpl_domain) {
614-
return;
615-
}
616-
617-
rpl_control_delete_dodag_root(protocol_6lowpan_rpl_domain, protocol_6lowpan_rpl_root_dodag);
618-
protocol_6lowpan_rpl_root_dodag = NULL;
611+
ws_bbr_rpl_root_stop();
619612
current_instance_id++;
620613

621614
#else

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -896,6 +896,7 @@ static void ws_bootstrap_pan_advertisement_analyse_active(struct protocol_interf
896896
*/
897897

898898
#ifdef WISUN_1_0_ERRATA_FIX
899+
(void)pan_information;
899900
// All messages are considered as consistent only Solicit will cause inconsistent
900901
trickle_consistent_heard(&cur->ws_info->trickle_pan_advertisement);
901902
#else

source/RPL/rpl_control.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,13 @@ rpl_dodag_t *rpl_control_create_dodag_root(rpl_domain_t *domain, uint8_t instanc
495495

496496
rpl_dodag_t *dodag = rpl_lookup_dodag(instance, dodagid);
497497
if (dodag) {
498-
tr_error("Root DODAG already exists");
499-
return NULL;
498+
if (rpl_dodag_am_root(dodag)) {
499+
tr_error("Root DODAG already exists");
500+
return NULL;
501+
}
502+
503+
// Delete non root information and recreate dodag
504+
rpl_delete_dodag(dodag);
500505
}
501506
dodag = rpl_create_dodag(instance, dodagid, g_mop_prf);
502507
if (!dodag) {
@@ -975,8 +980,9 @@ static buffer_t *rpl_control_dio_handler(protocol_interface_info_entry_t *cur, r
975980
}
976981
}
977982

978-
/* Never listen to nodes in a DODAG we're rooting */
979-
if (rpl_dodag_am_root(dodag)) {
983+
/* Never listen to nodes in a DODAG we're rooting or were root*/
984+
if (rpl_dodag_am_root(dodag) ||
985+
rpl_dodag_was_root(dodag)) {
980986
/* TODO - if version is newer or unordered, increment our version to be higher? */
981987
/* Old code had this trick - actually, would need to go further. Want to listen first, then use a higher
982988
* than existing. */

source/RPL/rpl_structures.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ struct rpl_dodag {
8787
rpl_dodag_conf_t config; /* Configuration from DIO */
8888
uint8_t info_version; /* Version for g_mop_prf and config */
8989
bool root: 1; /* We are the root of this DODAG */
90+
bool was_root: 1; /* If we have ever been a root in this DODAG */
9091
bool leaf: 1; /* We are a leaf in this DODAG (by policy) */
9192
bool have_config: 1; /* We have the config */
9293
bool used: 1; /* We have ever been a member of this DODAG? */

source/RPL/rpl_upward.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,7 @@ rpl_dodag_t *rpl_create_dodag(rpl_instance_t *instance, const uint8_t *dodagid,
638638
memcpy(dodag->id, dodagid, 16);
639639
dodag->leaf = false;
640640
dodag->root = false;
641+
dodag->was_root = false;
641642
dodag->have_config = false;
642643
dodag->used = false;
643644
dodag->g_mop_prf = g_mop_prf;
@@ -678,15 +679,9 @@ void rpl_delete_dodag_root(rpl_dodag_t *dodag)
678679
{
679680
// This should trigger immediate poison
680681
rpl_instance_set_dodag_version(dodag->instance, NULL, RPL_RANK_INFINITE);
681-
// Deleting DODAG is not ideal - we will just pick up adverts from our
682-
// former children, and recreate, possibly violating the MaxRankIncrease.
683-
// Should retain DODAG version info and just unset root flag, which will
684-
// limit what happens when we hear adverts.
685-
// Problem is rpl_control_create_dodag_root which can't handle the
686-
// case where DODAG already exists. This would always be a problem if
687-
// we'd heard adverts in between delete and create, but would be an instant
688-
// problem without this delete. Need to fix.
689-
rpl_delete_dodag(dodag);
682+
// Retain DODAG version info and just unset root flag
683+
// We have was_root still set which will drop adverts for this dodag.
684+
dodag->root = false;
690685
}
691686

692687
/* Convert RPL configuration to generic trickle parameters. Returns true if
@@ -792,6 +787,7 @@ void rpl_dodag_set_root(rpl_dodag_t *dodag, bool root)
792787
dodag->root = root;
793788
if (root) {
794789
rpl_instance_remove_parents(dodag->instance);
790+
dodag->was_root = true;
795791
} else {
796792
rpl_instance_run_parent_selection(dodag->instance);
797793
}
@@ -803,6 +799,11 @@ bool rpl_dodag_am_root(const rpl_dodag_t *dodag)
803799
{
804800
return dodag->root;
805801
}
802+
803+
bool rpl_dodag_was_root(const rpl_dodag_t *dodag)
804+
{
805+
return dodag->was_root;
806+
}
806807
#endif
807808

808809
void rpl_dodag_set_leaf(rpl_dodag_t *dodag, bool leaf)
@@ -1381,7 +1382,8 @@ void rpl_instance_run_parent_selection(rpl_instance_t *instance)
13811382
return;
13821383
}
13831384

1384-
if (instance->current_dodag_version && instance->current_dodag_version->dodag->root) {
1385+
if (instance->current_dodag_version &&
1386+
(instance->current_dodag_version->dodag->root || instance->current_dodag_version->dodag->was_root)) {
13851387
return;
13861388
}
13871389

source/RPL/rpl_upward.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,10 @@ uint8_t rpl_dodag_mop(const rpl_dodag_t *dodag);
9797
void rpl_dodag_set_root(rpl_dodag_t *dodag, bool root);
9898
#ifdef HAVE_RPL_ROOT
9999
bool rpl_dodag_am_root(const rpl_dodag_t *dodag);
100+
bool rpl_dodag_was_root(const rpl_dodag_t *dodag);
100101
#else
101102
#define rpl_dodag_am_root(dodag) false
103+
#define rpl_dodag_was_root(dodag) false
102104
#endif
103105
uint8_t rpl_dodag_get_version_number_as_root(const rpl_dodag_t *dodag);
104106
void rpl_dodag_set_version_number_as_root(rpl_dodag_t *dodag, uint8_t number);

test/nanostack/unittest/stub/rpl_upward_stub.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ void rpl_dodag_set_root(rpl_dodag_t *dodag, bool root)
308308

309309
bool rpl_dodag_am_root(const rpl_dodag_t *dodag)
310310
{
311+
return true;
312+
}
313+
314+
bool rpl_dodag_was_root(const rpl_dodag_t *dodag)
315+
{
316+
return true;
311317
}
312318

313319
void rpl_dodag_set_leaf(rpl_dodag_t *dodag, bool leaf)

0 commit comments

Comments
 (0)