Skip to content

Commit

Permalink
cleared neighbours with child address that are not ours (ARMmbed#1549)
Browse files Browse the repository at this point in the history
when a new router id is received from the leader upon
merging to a new partition.
  • Loading branch information
deepakvenugopal committed Feb 1, 2018
1 parent 80b4d72 commit c727295
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
34 changes: 27 additions & 7 deletions source/6LoWPAN/Thread/thread_router_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,6 +949,11 @@ static int thread_attach_parent_response_build(protocol_interface_info_entry_t *

void thread_router_bootstrap_child_information_clear(protocol_interface_info_entry_t *cur)
{

/*the default routerShortAddress if nothing is requested is 0xfffe so eliminate this case
Also make sure that the child info (from previous partition if any)
is cleared if no router address is got from leader */

if (!cur->thread_info) {
return;
}
Expand Down Expand Up @@ -976,6 +981,26 @@ void thread_router_bootstrap_child_information_clear(protocol_interface_info_ent
}

}
static void thread_router_bootstrap_invalid_child_information_clear(protocol_interface_info_entry_t *cur, uint16_t router_rloc)
{

tr_debug("Thread Short address changed old: %x new: %x", cur->thread_info->routerShortAddress, router_rloc);

mle_neigh_table_list_t *entry_list = mle_class_active_list_get(cur->id);
if (!entry_list) {
return;
}

// scrub neighbours with child addresses that are not ours
ns_list_foreach_safe(mle_neigh_table_entry_t, table_entry, entry_list) {
if (table_entry->short_adr < 0xfffe &&
!thread_is_router_addr(table_entry->short_adr) &&
thread_router_addr_from_addr(table_entry->short_adr) != router_rloc) {
ipv6_neighbour_delete_registered_by_eui64(&cur->ipv6_neighbour_cache, table_entry->mac64);
mle_class_remove_entry(cur->id, table_entry);
}
}
}

static void thread_bootstrap_client_router_id_cb(int8_t interface_id, int8_t status, uint16_t router_rloc, const uint8_t router_mask_ptr[9])
{
Expand Down Expand Up @@ -1011,13 +1036,8 @@ static void thread_bootstrap_client_router_id_cb(int8_t interface_id, int8_t sta
parent_router_id = cur->thread_info->thread_endnode_parent->router_id;
}

tr_info("Thread Short address changed old: %x new: %x", cur->thread_info->routerShortAddress, router_rloc);
/*the default routerShortAddress if nothing is requested is 0xfffe so eliminate this case
Also make sure that the child info (from previous partition if any)
is cleared if the router address requested is not what is got from leader */
if ( cur->thread_info->routerShortAddress != router_rloc) {
thread_router_bootstrap_child_information_clear(cur);
}
thread_router_bootstrap_invalid_child_information_clear(cur,router_rloc);

// Release network data from old address
cur->thread_info->localServerDataBase.release_old_address = true;

Expand Down
9 changes: 9 additions & 0 deletions source/ipv6_stack/ipv6_routing_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,15 @@ void ipv6_neighbour_invalidate_ll_addr(ipv6_neighbour_cache_t *cache, addrtype_t
}
}

void ipv6_neighbour_delete_registered_by_eui64(ipv6_neighbour_cache_t *cache, const uint8_t *eui64)
{
ns_list_foreach_safe(ipv6_neighbour_t, cur, &cache->list) {
if (cur->type != IP_NEIGHBOUR_GARBAGE_COLLECTIBLE && memcmp(ipv6_neighbour_eui64(cache, cur), eui64, 8) == 0) {
ipv6_neighbour_entry_remove(cache, cur);
}
}
}

void ipv6_neighbour_set_state(ipv6_neighbour_cache_t *cache, ipv6_neighbour_t *entry, ip_neighbour_cache_state_t state)
{
if (!ipv6_neighbour_state_is_probably_reachable(entry->state) &&
Expand Down
1 change: 1 addition & 0 deletions source/ipv6_stack/ipv6_routing_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ extern bool ipv6_neighbour_is_probably_reachable(ipv6_neighbour_cache_t *cache,
extern bool ipv6_neighbour_addr_is_probably_reachable(ipv6_neighbour_cache_t *cache, const uint8_t *address);
extern bool ipv6_neighbour_ll_addr_match(const ipv6_neighbour_t *entry, addrtype_t ll_type, const uint8_t *ll_address);
extern void ipv6_neighbour_invalidate_ll_addr(ipv6_neighbour_cache_t *cache, addrtype_t ll_type, const uint8_t *ll_address);
extern void ipv6_neighbour_delete_registered_by_eui64(ipv6_neighbour_cache_t *cache, const uint8_t *eui64);
extern void ipv6_neighbour_entry_update_unsolicited(ipv6_neighbour_cache_t *cache, ipv6_neighbour_t *entry, addrtype_t type, const uint8_t *ll_address/*, bool tentative*/);
extern ipv6_neighbour_t *ipv6_neighbour_update_unsolicited(ipv6_neighbour_cache_t *cache, const uint8_t *ip_address, addrtype_t ll_type, const uint8_t *ll_address);
extern void ipv6_neighbour_reachability_confirmation(const uint8_t ip_address[__static 16], int8_t interface_id);
Expand Down

0 comments on commit c727295

Please sign in to comment.