Skip to content

Commit

Permalink
Delete parent mle-entry in case of parent lost or updated (ARMmbed#1707)
Browse files Browse the repository at this point in the history
-Delete scanned parent MLE entry in child_id_req timeout.
-Delete parent MLE entry if parent changed short address
-Delete parent MLE entry if REED receives child_id_req from own parent
-Delete parent MLE entry if child_update_req contains error status
  • Loading branch information
Arto Kinnunen authored May 21, 2018
1 parent b43db5f commit 2d3aff9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
3 changes: 1 addition & 2 deletions source/6LoWPAN/Thread/thread_host_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1026,13 +1026,12 @@ static bool thread_child_id_req_timeout(int8_t interface_id, uint16_t msgId, boo

entry_temp = mle_class_get_entry_by_ll64(cur->id, scanned_parent->linkMarginToParent, ll64, false, NULL);
if (entry_temp) {
mle_class_remove_entry(cur->id, entry_temp);
if (thread_check_is_this_my_parent(cur, entry_temp)) {
tr_debug("No parent resp - any-attach");
thread_bootstrap_connection_error(interface_id, CON_ERROR_NETWORK_ATTACH_FAIL, NULL);
goto exit;
}
// remove scanned_parent mle-entry as it was not my parent
mle_class_remove_entry(cur->id, entry_temp);
}
}

Expand Down
2 changes: 2 additions & 0 deletions source/6LoWPAN/Thread/thread_mle_message_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ static void thread_parse_advertisement(protocol_interface_info_entry_t *cur, mle
/* Check parent status */
if (!thread_attach_active_router(cur) && my_parent) {
if (!thread_parse_advertisement_from_parent(cur, &leaderData, shortAddress)) {
mle_class_remove_entry(cur->id, entry_temp);
return;
}
}
Expand Down Expand Up @@ -770,6 +771,7 @@ static void thread_parse_child_update_response(protocol_interface_info_entry_t *
if (mle_tlv_read_8_bit_tlv(MLE_TYPE_STATUS, mle_msg->data_ptr, mle_msg->data_length, &status) &&
status == 1 && thread_check_is_this_my_parent(cur, entry_temp)) {
tr_debug("parent has connection error");
mle_class_remove_entry(cur->id, entry_temp);
thread_bootstrap_connection_error(cur->id, CON_PARENT_CONNECT_DOWN, NULL);
return;
}
Expand Down
10 changes: 7 additions & 3 deletions source/6LoWPAN/Thread/thread_router_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -1571,10 +1571,14 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t *
return;
}

// If we are in REED mode and receive child IR request from our parent, call connection error.
// If we are in REED mode and receive child ID request from our parent, call connection error.
if (thread_am_reed(cur)) {
if (thread_router_parent_address_check(cur, mle_msg->packet_src_address)) {
tr_debug("Child ID req from own parent -> connection error");
entry_temp = mle_class_get_entry_by_ll64(cur->id, linkMargin, mle_msg->packet_src_address, false, NULL);
if (entry_temp) {
mle_class_remove_entry(cur->id, entry_temp);
}
thread_bootstrap_connection_error(cur->id, CON_PARENT_CONNECT_DOWN, NULL);
return;
}
Expand Down Expand Up @@ -1903,7 +1907,8 @@ void thread_router_bootstrap_mle_receive_cb(int8_t interface_id, mle_message_t *

if (mle_tlv_read_8_bit_tlv(MLE_TYPE_STATUS, mle_msg->data_ptr, mle_msg->data_length, &status)) {
if (1 == status && thread_check_is_this_my_parent(cur, entry_temp)) {
tr_debug("parent has removed REED");
tr_debug("Parent has removed REED");
mle_class_remove_entry(cur->id, entry_temp);
thread_bootstrap_connection_error(cur->id, CON_PARENT_CONNECT_DOWN, NULL);
}
return;
Expand Down Expand Up @@ -2251,7 +2256,6 @@ int thread_router_bootstrap_route_tlv_push(protocol_interface_info_entry_t *cur,
thread_routing_leader_connection_validate(cur->thread_info,routing->networkFragmentationTimer);
routing->networkFragmentationTimer = 0;
if (thread_validate_own_routeid_from_new_mask(router_id_mask, thread_router_id_from_addr(mac16)) != 0) {

tr_debug("RouterID not valid any More");
thread_bootstrap_connection_error(cur->id, CON_ERROR_NETWORK_KICK, NULL);
return 0;
Expand Down

0 comments on commit 2d3aff9

Please sign in to comment.