Skip to content

Commit 51a498b

Browse files
author
Mika Tervonen
committed
reset Dodag if global address is lost.
If we lose the dodag_id address we need to restart Border router
1 parent 0ec37a6 commit 51a498b

File tree

5 files changed

+48
-3
lines changed

5 files changed

+48
-3
lines changed

source/6LoWPAN/ws/ws_bbr_api.c

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@
4141

4242
#ifdef HAVE_WS
4343

44+
static uint8_t static_dodag_prefix[8] = {0xfd,0x00,0x61, 0x72, 0x6d};
45+
static uint8_t static_dodag_id[16] = {0};
46+
4447
static void ws_bbr_rpl_root_activate(uint8_t *dodag_prefix, uint8_t *dodag_id)
4548
{
4649
tr_debug("RPL root Activate");
@@ -61,10 +64,18 @@ static void ws_bbr_rpl_root_activate(uint8_t *dodag_prefix, uint8_t *dodag_id)
6164
};
6265

6366
rpl_data_init_root();
67+
68+
if (protocol_6lowpan_rpl_root_dodag) {
69+
rpl_control_delete_dodag_root(protocol_6lowpan_rpl_domain, protocol_6lowpan_rpl_root_dodag);
70+
protocol_6lowpan_rpl_root_dodag = NULL;
71+
}
72+
6473
protocol_6lowpan_rpl_root_dodag = rpl_control_create_dodag_root(protocol_6lowpan_rpl_domain, RPL_INSTANCE_ID, dodag_id, &new_conf, new_conf.min_hop_rank_increase, RPL_GROUNDED | RPL_MODE_NON_STORING | RPL_DODAG_PREF(0));
6574
if (!protocol_6lowpan_rpl_root_dodag) {
6675
tr_err("RPL dodag init failed");
76+
return;
6777
}
78+
memcpy(static_dodag_id,dodag_id,16);
6879

6980
// RPL memory limits set larger for Border router
7081
rpl_control_set_memory_limits(64*1024, 0);
@@ -76,8 +87,6 @@ static void ws_bbr_rpl_root_activate(uint8_t *dodag_prefix, uint8_t *dodag_id)
7687
rpl_control_update_dodag_route(protocol_6lowpan_rpl_root_dodag, NULL, 0, 0, 0xffffffff, false);
7788
}
7889

79-
static uint8_t static_dodag_prefix[8] = {0xfd,0x00,0x61, 0x72, 0x6d};
80-
8190
static void ws_bbr_root_start(protocol_interface_info_entry_t *cur)
8291
{
8392
uint8_t *bbr_prefix_ptr = NULL;
@@ -119,6 +128,15 @@ void ws_bbr_seconds_timer(protocol_interface_info_entry_t *cur, uint32_t seconds
119128
return;
120129
}
121130

131+
if (protocol_6lowpan_rpl_root_dodag){
132+
// Border router is active
133+
if (0 != protocol_interface_address_compare(static_dodag_id)) {
134+
// Dodag has become invalid need to delete
135+
tr_info("RPL dodag not valid anymore");
136+
rpl_control_delete_dodag_root(protocol_6lowpan_rpl_domain, protocol_6lowpan_rpl_root_dodag);
137+
protocol_6lowpan_rpl_root_dodag = NULL;
138+
}
139+
}
122140
if (!protocol_6lowpan_rpl_root_dodag) {
123141
// RPL configured
124142
// 1. Wait for backend connection

source/RPL/rpl_control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@ void rpl_control_delete_dodag_root(rpl_domain_t *domain, rpl_dodag_t *dodag)
455455
{
456456
(void)domain;
457457

458-
rpl_delete_dodag(dodag);
458+
rpl_delete_dodag_root(dodag);
459459
}
460460

461461
void rpl_control_update_dodag_route(rpl_dodag_t *dodag, const uint8_t *prefix, uint8_t prefix_len, uint8_t flags, uint32_t lifetime, bool age)

source/RPL/rpl_upward.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -542,6 +542,14 @@ void rpl_delete_dodag_version(rpl_dodag_version_t *version)
542542
rpl_dodag_t *dodag = version->dodag;
543543
rpl_instance_t *instance = dodag->instance;
544544

545+
if (instance->current_dodag_version == version) {
546+
// Don't call rpl_instance_set_dodag_version(NULL) - that would pre-empt parent reselection,
547+
// triggering poison immediately.
548+
// Give parent selection a chance to select another version (but will it have any info on-hand?)
549+
instance->current_dodag_version = NULL;
550+
rpl_instance_trigger_parent_selection(instance, 5);
551+
}
552+
545553
ns_list_foreach_safe(rpl_neighbour_t, neighbour, &instance->candidate_neighbours) {
546554
if (neighbour->dodag_version == version) {
547555
rpl_delete_neighbour(instance, neighbour);
@@ -649,6 +657,21 @@ void rpl_delete_dodag(rpl_dodag_t *dodag)
649657
rpl_free(dodag, sizeof(*dodag));
650658
}
651659

660+
void rpl_delete_dodag_root(rpl_dodag_t *dodag)
661+
{
662+
// This should trigger immediate poison
663+
rpl_instance_set_dodag_version(dodag->instance, NULL, RPL_RANK_INFINITE);
664+
// Deleting DODAG is not ideal - we will just pick up adverts from our
665+
// former children, and recreate, possibly violating the MaxRankIncrease.
666+
// Should retain DODAG version info and just unset root flag, which will
667+
// limit what happens when we hear adverts.
668+
// Problem is rpl_control_create_dodag_root which can't handle the
669+
// case where DODAG already exists. This would always be a problem if
670+
// we'd heard adverts in between delete and create, but would be an instant
671+
// problem without this delete. Need to fix.
672+
rpl_delete_dodag(dodag);
673+
}
674+
652675
/* Convert RPL configuration to generic trickle parameters. Returns true if
653676
* the value in the generic object has changed.
654677
*/

source/RPL/rpl_upward.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ void rpl_instance_slow_timer(rpl_instance_t *instance, uint16_t seconds);
8888
rpl_dodag_t *rpl_lookup_dodag(const rpl_instance_t *instance, const uint8_t *dodagid);
8989
rpl_dodag_t *rpl_create_dodag(rpl_instance_t *instance, const uint8_t *dodagid, uint8_t g_mop_prf);
9090
void rpl_delete_dodag(rpl_dodag_t *dodag);
91+
void rpl_delete_dodag_root(rpl_dodag_t *dodag);
9192
uint8_t rpl_dodag_mop(const rpl_dodag_t *dodag);
9293
void rpl_dodag_set_root(rpl_dodag_t *dodag, bool root);
9394
#ifdef HAVE_RPL_ROOT

test/nanostack/unittest/stub/rpl_upward_stub.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ rpl_dodag_version_t *rpl_create_dodag_version(rpl_dodag_t *dodag, uint8_t versio
238238
void rpl_delete_dodag_version(rpl_dodag_version_t *version)
239239
{
240240
}
241+
void rpl_delete_dodag_root(rpl_dodag_t *dodag)
242+
{
243+
}
241244

242245
bool rpl_dodag_version_is_current(const rpl_dodag_version_t *version)
243246
{

0 commit comments

Comments
 (0)