Skip to content

Commit dde9e61

Browse files
Reverted commit ARMmbed#1888 and fixed thread_bbr_dua_entry_find (ARMmbed#1893)
1 parent 628fa27 commit dde9e61

File tree

4 files changed

+8
-32
lines changed

4 files changed

+8
-32
lines changed

source/6LoWPAN/Thread/thread_bbr_api.c

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,6 @@ typedef struct {
100100
#define RFC6106_DNS_SEARCH_LIST_OPTION 31
101101
static NS_LIST_DEFINE(bbr_instance_list, thread_bbr_t, link);
102102

103-
struct ipv6_route *thread_bbr_dua_entry_find(int8_t interface_id, const uint8_t *addr_data_ptr) {
104-
ipv6_route_t *route = ipv6_route_choose_next_hop(addr_data_ptr, interface_id, NULL);
105-
106-
if (!route || route->prefix_len < 128 || !route->on_link || route->info.source != ROUTE_THREAD_PROXIED_DUA_HOST ) {
107-
//Not found
108-
return NULL;
109-
}
110-
return route;
111-
}
112-
113103
static thread_bbr_t *thread_bbr_find_by_interface(int8_t interface_id)
114104
{
115105
thread_bbr_t *this = NULL;
@@ -993,29 +983,27 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
993983
if (!this || this->backbone_interface_id < 0) {
994984
return -1;
995985
}
996-
ipv6_route_t *route = thread_bbr_dua_entry_find(this->interface_id, addr_data_ptr);
986+
ipv6_route_t *route = ipv6_route_lookup_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0);
997987
if (!route){
998988
map = ns_dyn_mem_alloc(sizeof(thread_pbbr_dua_info_t));
999989
if (!map) {
1000990
goto error;
1001991
}
1002992
// We are using route info field to store BBR MLEID map
1003-
route = ipv6_route_add_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0, lifetime, 1);
993+
route = ipv6_route_add_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, map, 0, lifetime, 0);
1004994
if (!route) {
1005995
// Direct route to host allows ND proxying to work
1006996
ns_dyn_mem_free(map);
1007997
goto error;
1008998
}
1009999
// Route info autofreed
10101000
route->info_autofree = true;
1011-
route->info.info = map;
10121001
}
1002+
map = route->info.info;
1003+
memcpy(map->mleid_ptr, mleid_ptr, 8);
1004+
map->last_contact_time = protocol_core_monotonic_time;
1005+
route->info.info = map;
10131006

1014-
if(!route->info.info) {
1015-
goto error;
1016-
}
1017-
memcpy(((thread_pbbr_dua_info_t *)route->info.info)->mleid_ptr, mleid_ptr, 8);
1018-
((thread_pbbr_dua_info_t *)route->info.info)->last_contact_time = protocol_core_monotonic_time;
10191007
// send NA
10201008
thread_bbr_na_send(this->backbone_interface_id, addr_data_ptr);
10211009

source/6LoWPAN/Thread/thread_bbr_api_internal.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,20 +117,13 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
117117
*/
118118
int thread_bbr_na_send(int8_t interface_id, const uint8_t target[static 16]);
119119

120-
/**
121-
* \brief Find if bbr has dua entry
122-
*
123-
* \param interface_id addr_data_ptr
124-
*/
125-
struct ipv6_route *thread_bbr_dua_entry_find(int8_t interface_id, const uint8_t *addr_data_ptr);
126120

127121
#else
128122
#define thread_bbr_proxy_state_update(caller_interface_id , handler_interface_id, status) (NULL)
129123
#define thread_bbr_routing_enabled(cur) false
130124
#define thread_bbr_network_data_update_notify(cur)
131125
#define thread_bbr_nd_entry_add(interface_id, addr_data_ptr, lifetime, info) (0)
132126
#define thread_bbr_dua_entry_add(interface_id, addr_data_ptr, lifetime, mleid_ptr) (0)
133-
#define thread_bbr_dua_entry_find(interface_id, addr_data_ptr) (NULL)
134127
#define thread_bbr_na_send(interface_id, target) (0)
135128
#endif //HAVE_THREAD_BORDER_ROUTER
136129

source/6LoWPAN/Thread/thread_extension_bbr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ static void thread_pbbr_pro_bb_ntf_process(protocol_interface_info_entry_t *cur,
542542
if (!this) {
543543
return;
544544
}
545-
ipv6_route_t *route = thread_bbr_dua_entry_find(cur->id, addr_data_ptr);
545+
ipv6_route_t *route = ipv6_route_lookup_with_info(addr_data_ptr, 128, this->interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0);
546546
if (!route || !route->info.info) {
547547
return;
548548
}
@@ -899,7 +899,7 @@ static int thread_extension_bbr_dua_cb(int8_t service_id, uint8_t source_address
899899
tr_debug("DUA.req addr:%s ml_eid:%s", trace_array(addr_data_ptr, addr_len), trace_array(ml_eid_ptr, ml_eid_len));
900900

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

904904
// new device has generated duplicate dua
905905
if (route != NULL && route->info.info != NULL && memcmp(((thread_pbbr_dua_info_t *)route->info.info)->mleid_ptr,ml_eid_ptr,8) != 0) {

source/ipv6_stack/ipv6_routing_table.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,11 +1589,6 @@ ipv6_route_t *ipv6_route_add_metric(const uint8_t *prefix, uint8_t prefix_len, i
15891589
route->metric = metric;
15901590
changed_info = UPDATED;
15911591
}
1592-
// if we are updating the info. we need to delete the previous data
1593-
if(route->info.info != info && route->info.info && route->info_autofree) {
1594-
ns_dyn_mem_free(route->info.info);
1595-
}
1596-
route->info.info = info;
15971592

15981593
}
15991594

0 commit comments

Comments
 (0)