From 2d3aff92f9038ce46c2d7f001b4ef02a01cc89e4 Mon Sep 17 00:00:00 2001 From: Arto Kinnunen Date: Mon, 21 May 2018 16:36:04 +0300 Subject: [PATCH] Delete parent mle-entry in case of parent lost or updated (#1707) -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 --- source/6LoWPAN/Thread/thread_host_bootstrap.c | 3 +-- source/6LoWPAN/Thread/thread_mle_message_handler.c | 2 ++ source/6LoWPAN/Thread/thread_router_bootstrap.c | 10 +++++++--- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/source/6LoWPAN/Thread/thread_host_bootstrap.c b/source/6LoWPAN/Thread/thread_host_bootstrap.c index ebeeadc457a..309ce0ffa33 100644 --- a/source/6LoWPAN/Thread/thread_host_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_host_bootstrap.c @@ -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); } } diff --git a/source/6LoWPAN/Thread/thread_mle_message_handler.c b/source/6LoWPAN/Thread/thread_mle_message_handler.c index 0032629cd94..722c28fddd6 100644 --- a/source/6LoWPAN/Thread/thread_mle_message_handler.c +++ b/source/6LoWPAN/Thread/thread_mle_message_handler.c @@ -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; } } @@ -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; } diff --git a/source/6LoWPAN/Thread/thread_router_bootstrap.c b/source/6LoWPAN/Thread/thread_router_bootstrap.c index abef79c8928..aead13e6a45 100644 --- a/source/6LoWPAN/Thread/thread_router_bootstrap.c +++ b/source/6LoWPAN/Thread/thread_router_bootstrap.c @@ -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; } @@ -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; @@ -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;