Skip to content

Commit f39312b

Browse files
REED and FED links removed (ARMmbed#1796)
Removed old partition links from REED and FED when moving to new partition.
1 parent b162d7b commit f39312b

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

source/6LoWPAN/Thread/thread_bootstrap.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,6 +1190,31 @@ void thread_neighbor_list_clean(struct protocol_interface_info_entry *cur)
11901190
}
11911191
}
11921192

1193+
void thread_reed_fed_neighbour_links_clean(struct protocol_interface_info_entry *cur)
1194+
{
1195+
mac_neighbor_table_list_t *mac_table_list = &mac_neighbor_info(cur)->neighbour_list;
1196+
1197+
if (thread_i_am_router(cur)) {
1198+
return;
1199+
}
1200+
1201+
if (thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_END_DEVICE ||
1202+
thread_info(cur)->thread_device_mode == THREAD_DEVICE_MODE_SLEEPY_END_DEVICE) {
1203+
return;
1204+
}
1205+
1206+
if (!thread_info(cur)->thread_endnode_parent) {
1207+
return;
1208+
}
1209+
ns_list_foreach_safe(mac_neighbor_table_entry_t, cur_entry, mac_table_list) {
1210+
// do not remove parent entry
1211+
if (memcmp(cur_entry->mac64, thread_info(cur)->thread_endnode_parent->mac64, 8) != 0) {
1212+
tr_debug("Free short addr: %x", cur_entry->mac16);
1213+
mac_neighbor_table_neighbor_remove(mac_neighbor_info(cur), cur_entry);
1214+
}
1215+
}
1216+
}
1217+
11931218
void thread_clean_old_16_bit_address_based_addresses(protocol_interface_info_entry_t *cur)
11941219
{
11951220
uint8_t static_address[16];

source/6LoWPAN/Thread/thread_bootstrap.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,9 @@ void thread_general_mle_receive_cb(int8_t interface_id, mle_message_t *mle_msg,
106106
void thread_bootstrap_ready(struct protocol_interface_info_entry *cur);
107107
int thread_bootstrap_reset(struct protocol_interface_info_entry *cur);
108108
void thread_neighbor_list_clean(struct protocol_interface_info_entry *cur);
109+
110+
/* Function to remove linked neighbours for REEDs and FEDs */
111+
void thread_reed_fed_neighbour_links_clean(struct protocol_interface_info_entry *cur);
109112
bool thread_bootstrap_request_network_data(struct protocol_interface_info_entry *cur, struct thread_leader_data_s *leaderData, uint16_t short_address);
110113
bool thread_check_is_this_my_parent(struct protocol_interface_info_entry *cur, struct mac_neighbor_table_entry *entry_temp);
111114
void thread_clean_old_16_bit_address_based_addresses(struct protocol_interface_info_entry *cur);

source/6LoWPAN/Thread/thread_common.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,9 @@ void thread_partition_data_purge(protocol_interface_info_entry_t *cur)
19831983
/* Flush address cache */
19841984
ipv6_neighbour_cache_flush(&cur->ipv6_neighbour_cache);
19851985

1986+
/* Remove linked neighbours for REEDs and FEDs */
1987+
thread_reed_fed_neighbour_links_clean(cur);
1988+
19861989
}
19871990

19881991
bool thread_partition_match(protocol_interface_info_entry_t *cur, thread_leader_data_t *leaderData)

source/6LoWPAN/Thread/thread_host_bootstrap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,11 @@ static void thread_network_data_clean(protocol_interface_info_entry_t *cur)
121121

122122
static void thread_merge_prepare(protocol_interface_info_entry_t *cur)
123123
{
124+
thread_partition_data_purge(cur);
124125
thread_clean_old_16_bit_address_based_addresses(cur);
125126
mpl_clear_realm_scope_seeds(cur);
126127
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_PROXIED_HOST, NULL);
127128
ipv6_route_table_remove_info(cur->id, ROUTE_THREAD_PROXIED_DUA_HOST, NULL);
128-
thread_partition_data_purge(cur);
129129
thread_network_data_clean(cur);
130130
cur->nwk_mode = ARM_NWK_GP_IP_MODE;
131131
}

test/nanostack/unittest/stub/thread_bootstrap_stub.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ void thread_clean_old_16_bit_address_based_addresses(protocol_interface_info_ent
8888
{
8989
}
9090

91+
void thread_reed_fed_neighbour_links_clean(struct protocol_interface_info_entry *cur)
92+
{
93+
}
9194

9295
void thread_bootstrap_ready(protocol_interface_info_entry_t *cur)
9396
{

0 commit comments

Comments
 (0)