Skip to content

Commit cfea7b2

Browse files
BBR route for added with preference. Route info updated. (ARMmbed#1888)
1 parent dc404c4 commit cfea7b2

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

source/6LoWPAN/Thread/thread_bbr_api.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ static NS_LIST_DEFINE(bbr_instance_list, thread_bbr_t, link);
102102

103103
struct ipv6_route *thread_bbr_dua_entry_find(int8_t interface_id, const uint8_t *addr_data_ptr) {
104104
ipv6_route_t *route = ipv6_route_choose_next_hop(addr_data_ptr, interface_id, NULL);
105+
105106
if (!route || route->prefix_len < 128 || !route->on_link || route->info.source != ROUTE_THREAD_PROXIED_DUA_HOST ) {
106107
//Not found
107108
return NULL;
@@ -999,22 +1000,22 @@ int thread_bbr_dua_entry_add (int8_t interface_id, const uint8_t *addr_data_ptr,
9991000
goto error;
10001001
}
10011002
// We are using route info field to store BBR MLEID map
1002-
route = ipv6_route_add_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, map, 0, lifetime, 0);
1003+
route = ipv6_route_add_with_info(addr_data_ptr, 128, interface_id, NULL, ROUTE_THREAD_PROXIED_DUA_HOST, NULL, 0, lifetime, 1);
10031004
if (!route) {
10041005
// Direct route to host allows ND proxying to work
10051006
ns_dyn_mem_free(map);
10061007
goto error;
10071008
}
10081009
// Route info autofreed
10091010
route->info_autofree = true;
1011+
route->info.info = map;
10101012
}
10111013

1012-
map = route->info.info;
1013-
memcpy(map->mleid_ptr, mleid_ptr, 8);
1014-
map->last_contact_time = protocol_core_monotonic_time;
1015-
route->info.info = map;
1016-
1017-
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;
10181019
// send NA
10191020
thread_bbr_na_send(this->backbone_interface_id, addr_data_ptr);
10201021

source/ipv6_stack/ipv6_routing_table.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,6 +1589,12 @@ 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;
1597+
15921598
}
15931599

15941600
if (changed_info != UNCHANGED) {

0 commit comments

Comments
 (0)