Skip to content

Commit

Permalink
Reverted commit ARMmbed#1888 and fixed thread_bbr_dua_entry_find (ARM…
Browse files Browse the repository at this point in the history
  • Loading branch information
deepakvenugopal authored Nov 2, 2018
1 parent 628fa27 commit dde9e61
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
24 changes: 6 additions & 18 deletions source/6LoWPAN/Thread/thread_bbr_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,6 @@ typedef struct {
#define RFC6106_DNS_SEARCH_LIST_OPTION 31
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;
}
return route;
}

static thread_bbr_t *thread_bbr_find_by_interface(int8_t interface_id)
{
thread_bbr_t *this = NULL;
Expand Down Expand Up @@ -993,29 +983,27 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
if (!this || this->backbone_interface_id < 0) {
return -1;
}
ipv6_route_t *route = thread_bbr_dua_entry_find(this->interface_id, addr_data_ptr);
ipv6_route_t *route = ipv6_route_lookup_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0);
if (!route){
map = ns_dyn_mem_alloc(sizeof(thread_pbbr_dua_info_t));
if (!map) {
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, NULL, 0, lifetime, 1);
route = ipv6_route_add_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, map, 0, lifetime, 0);
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
7 changes: 0 additions & 7 deletions source/6LoWPAN/Thread/thread_bbr_api_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,20 +117,13 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
*/
int thread_bbr_na_send(int8_t interface_id, const uint8_t target[static 16]);

/**
* \brief Find if bbr has dua entry
*
* \param interface_id addr_data_ptr
*/
struct ipv6_route *thread_bbr_dua_entry_find(int8_t interface_id, const uint8_t *addr_data_ptr);

#else
#define thread_bbr_proxy_state_update(caller_interface_id , handler_interface_id, status) (NULL)
#define thread_bbr_routing_enabled(cur) false
#define thread_bbr_network_data_update_notify(cur)
#define thread_bbr_nd_entry_add(interface_id, addr_data_ptr, lifetime, info) (0)
#define thread_bbr_dua_entry_add(interface_id, addr_data_ptr, lifetime, mleid_ptr) (0)
#define thread_bbr_dua_entry_find(interface_id, addr_data_ptr) (NULL)
#define thread_bbr_na_send(interface_id, target) (0)
#endif //HAVE_THREAD_BORDER_ROUTER

Expand Down
4 changes: 2 additions & 2 deletions source/6LoWPAN/Thread/thread_extension_bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ static void thread_pbbr_pro_bb_ntf_process(protocol_interface_info_entry_t *cur,
if (!this) {
return;
}
ipv6_route_t *route = thread_bbr_dua_entry_find(cur->id, addr_data_ptr);
ipv6_route_t *route = ipv6_route_lookup_with_info(addr_data_ptr, 128, this->interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0);
if (!route || !route->info.info) {
return;
}
Expand Down Expand Up @@ -899,7 +899,7 @@ static int thread_extension_bbr_dua_cb(int8_t service_id, uint8_t source_address
tr_debug("DUA.req addr:%s ml_eid:%s", trace_array(addr_data_ptr, addr_len), trace_array(ml_eid_ptr, ml_eid_len));

entry_keep_alive = false;
ipv6_route_t *route = thread_bbr_dua_entry_find(this->interface_id, addr_data_ptr);
ipv6_route_t *route = ipv6_route_lookup_with_info(addr_data_ptr, 128, this->interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0);

// new device has generated duplicate dua
if (route != NULL && route->info.info != NULL && memcmp(((thread_pbbr_dua_info_t *)route->info.info)->mleid_ptr,ml_eid_ptr,8) != 0) {
Expand Down
5 changes: 0 additions & 5 deletions source/ipv6_stack/ipv6_routing_table.c
Original file line number Diff line number Diff line change
Expand Up @@ -1589,11 +1589,6 @@ 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;

}

Expand Down

0 comments on commit dde9e61

Please sign in to comment.