Skip to content

Commit c25df78

Browse files
author
Tero Heinonen
authored
Fix for Router advertisement process in REED (#1658)
Process router advertisements in REED mode, and merge partitions if needed.
1 parent f8b227f commit c25df78

File tree

2 files changed

+12
-26
lines changed

2 files changed

+12
-26
lines changed

source/6LoWPAN/Thread/thread_bootstrap.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -325,11 +325,7 @@ int thread_bootstrap_partition_process(protocol_interface_info_entry_t *cur, uin
325325
tr_debug("Dropping advertisement from old partition without sequence number increase");
326326
return -2;
327327
}
328-
if (heard_partition_routers == 0 && active_routers == 1) {
329-
//heard a REED and I am in a singleton partition so merge
330-
tr_debug("Heard a REED and I am a singleton - merge");
331-
return 2;
332-
}
328+
333329
/*Rule 0: If we are going to form Higher partition than heard we dont try to attach to lower ones
334330
*/
335331
if (thread_extension_enabled(cur) &&
@@ -343,6 +339,12 @@ int thread_bootstrap_partition_process(protocol_interface_info_entry_t *cur, uin
343339
}
344340
}
345341

342+
if ((heard_partition_routers == 0 && active_routers == 1) && thread_am_router(cur)) {
343+
//heard a REED and I am a lonely router in a singleton partition, so merge
344+
tr_debug("Heard a REED and I am a singleton - merge");
345+
return 2;
346+
}
347+
346348
//Rule 1: A non-singleton Thread Network Partition always has higher priority than a singleton Thread Network Partition
347349
if (heard_partition_routers > 1 && active_routers == 1) {
348350
tr_debug("Heard a nonsingleton and i am a singleton");

source/6LoWPAN/Thread/thread_mle_message_handler.c

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -249,25 +249,6 @@ static bool thread_heard_lower_partition(protocol_interface_info_entry_t *cur, t
249249
return false;
250250
}
251251

252-
static bool thread_reed_partitions_merge(protocol_interface_info_entry_t *cur, uint16_t shortAddress, thread_leader_data_t heard_partition_leader_data)
253-
{
254-
if (thread_is_router_addr(shortAddress)) {
255-
return false;
256-
}
257-
// lower weighting heard
258-
if (thread_info(cur)->thread_leader_data->weighting > heard_partition_leader_data.weighting) {
259-
return false;
260-
}
261-
// lower/same partition id heard
262-
if (thread_info(cur)->thread_leader_data->weighting == heard_partition_leader_data.weighting &&
263-
thread_info(cur)->thread_leader_data->partitionId >= heard_partition_leader_data.partitionId ) {
264-
return false;
265-
}
266-
// can merge to a higher weighting/partition id
267-
thread_bootstrap_connection_error(cur->id, CON_ERROR_PARTITION_MERGE, NULL);
268-
return true;
269-
}
270-
271252
static bool thread_router_advertiment_tlv_analyze(uint8_t *ptr, uint16_t data_length, thread_leader_data_t *leaderData, uint16_t *shortAddress, mle_tlv_info_t *routeTlv)
272253
{
273254
//Read Leader Data and verify connectivity
@@ -401,10 +382,13 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
401382
}
402383
/* Advertisement from higher / lower partition */
403384
} else {
404-
// process REED advertisement from higher partition
405-
if (thread_reed_partitions_merge(cur, shortAddress, leaderData)) {
385+
// Check if better partition is heard
386+
if (thread_bootstrap_partition_process(cur, thread_get_router_count_from_route_tlv(&routeTlv), &leaderData, &routeTlv) > 0) {
387+
tr_debug("Start Merge");
388+
thread_bootstrap_connection_error(cur->id, CON_ERROR_PARTITION_MERGE, NULL);
406389
return;
407390
}
391+
408392
// REED advertisement to lower partition to help merge faster
409393
if (thread_heard_lower_partition(cur,leaderData)) {
410394
thread_router_bootstrap_reed_merge_advertisement(cur);

0 commit comments

Comments
 (0)