Skip to content

Commit

Permalink
BBR route for added with preference. Route info updated. (ARMmbed#1888)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakvenugopal authored Nov 1, 2018
1 parent dc404c4 commit cfea7b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
15 changes: 8 additions & 7 deletions source/6LoWPAN/Thread/thread_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ static NS_LIST_DEFINE(bbr_instance_list, thread_bbr_t, link);

struct ipv6_route *thread_bbr_dua_entry_find(int8_t interface_id, const uint8_t *addr_data_ptr) {
ipv6_route_t *route = ipv6_route_choose_next_hop(addr_data_ptr, interface_id, NULL);

if (!route || route->prefix_len < 128 || !route->on_link || route->info.source != ROUTE_THREAD_PROXIED_DUA_HOST ) {
//Not found
return NULL;
Expand Down Expand Up @@ -999,22 +1000,22 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
goto error;
}
// We are using route info field to store BBR MLEID map
route = ipv6_route_add_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, map, 0, lifetime, 0);
route = ipv6_route_add_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0, lifetime, 1);
if (!route) {
// Direct route to host allows ND proxying to work
ns_dyn_mem_free(map);
goto error;
}
// Route info autofreed
route->info_autofree = true;
route->info.info = map;
}

map = route->info.info;
memcpy(map->mleid_ptr, mleid_ptr, 8);
map->last_contact_time = protocol_core_monotonic_time;
route->info.info = map;


if(!route->info.info) {
goto error;
}
memcpy(((thread_pbbr_dua_info_t *)route->info.info)->mleid_ptr, mleid_ptr, 8);
((thread_pbbr_dua_info_t *)route->info.info)->last_contact_time = protocol_core_monotonic_time;
// send NA
thread_bbr_na_send(this->backbone_interface_id, addr_data_ptr);

Expand Down
6 changes: 6 additions & 0 deletions source/ipv6_stack/ipv6_routing_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -1589,6 +1589,12 @@ ipv6_route_t *ipv6_route_add_metric(const uint8_t *prefix, uint8_t prefix_len, i
route->metric = metric;
changed_info = UPDATED;
}
// if we are updating the info. we need to delete the previous data
if(route->info.info != info && route->info.info && route->info_autofree) {
ns_dyn_mem_free(route->info.info);
}
route->info.info = info;

}

if (changed_info != UNCHANGED) {
Expand Down

0 comments on commit cfea7b2

Please sign in to comment.