Skip to content

Commit 6926442

Browse files
author
Juha Heiuskanen
committed
Wi-SUN Aro registration temporary address registation bug fix.
Fixed That ARO lifetime 1 is not create temporary entry to normal neighbor.
1 parent d3170ed commit 6926442

File tree

6 files changed

+27
-13
lines changed

6 files changed

+27
-13
lines changed

source/6LoWPAN/ND/nd_router_object.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -930,7 +930,7 @@ bool nd_ns_aro_handler(protocol_interface_info_entry_t *cur_interface, const uin
930930
/* TODO - check hard upper limit on registrations? */
931931
if (ws_info(cur_interface)) {
932932

933-
aro_out->status = ws_common_allow_child_registration(cur_interface, aro_out->eui64);
933+
aro_out->status = ws_common_allow_child_registration(cur_interface, aro_out->eui64, aro_out->lifetime);
934934
if (aro_out->status != ARO_SUCCESS) {
935935
aro_out->present = true;
936936
return true;

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void ws_bootstrap_mac_neighbor_short_time_set(struct protocol_interface_info_ent
163163
{
164164
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), src64, MAC_ADDR_MODE_64_BIT);
165165

166-
if (neighbor && neighbor->link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT) {
166+
if (neighbor && neighbor->link_lifetime <= valid_time) {
167167
//mlme_device_descriptor_t device_desc;
168168
neighbor->lifetime = valid_time;
169169
neighbor->link_lifetime = valid_time;

source/6LoWPAN/ws/ws_common.c

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -390,38 +390,51 @@ uint8_t ws_common_temporary_entry_size(uint8_t mac_table_size)
390390
}
391391
}
392392

393-
static void ws_common_neighbour_address_reg_link_update(protocol_interface_info_entry_t *interface, const uint8_t *eui64)
393+
static void ws_common_neighbour_address_reg_link_update(protocol_interface_info_entry_t *interface, const uint8_t *eui64, uint32_t link_lifetime)
394394
{
395+
if (link_lifetime > WS_NEIGHBOR_LINK_TIMEOUT) {
396+
link_lifetime = WS_NEIGHBOR_LINK_TIMEOUT;
397+
}
395398
/*
396399
* ARO registration from child can update the link timeout so we don't need to send extra NUD if ARO received
397400
*/
398401
mac_neighbor_table_entry_t *mac_neighbor = mac_neighbor_entry_get_by_mac64(mac_neighbor_info(interface), eui64, false, false);
399402

400403
if (mac_neighbor) {
401-
if (mac_neighbor->link_lifetime != WS_NEIGHBOR_LINK_TIMEOUT) {
404+
if (mac_neighbor->link_lifetime < link_lifetime) {
402405
//Set Stable timeout for temporary entry here
406+
if (link_lifetime > WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME && mac_neighbor->link_lifetime < WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
407+
tr_info("Added new neighbor %s : index:%u", trace_array(eui64, 8), mac_neighbor->index);
408+
}
403409
mac_neighbor->link_lifetime = WS_NEIGHBOR_LINK_TIMEOUT;
404-
tr_info("Added new neighbor %s : index:%u", trace_array(eui64, 8), mac_neighbor->index);
410+
405411
}
406412
//Refresh
407413
mac_neighbor->lifetime = mac_neighbor->link_lifetime;
408414
}
409415
}
410416

411-
uint8_t ws_common_allow_child_registration(protocol_interface_info_entry_t *interface, const uint8_t *eui64)
417+
uint8_t ws_common_allow_child_registration(protocol_interface_info_entry_t *interface, const uint8_t *eui64, uint16_t aro_timeout)
412418
{
413419
uint8_t child_count = 0;
414420
uint8_t max_child_count = mac_neighbor_info(interface)->list_total_size - ws_common_temporary_entry_size(mac_neighbor_info(interface)->list_total_size);
415421

422+
if (aro_timeout == 0) {
423+
//DeRegister Address Reg
424+
return ARO_SUCCESS;
425+
}
426+
uint32_t link_lifetime = (aro_timeout * 60) + 1;
427+
416428
// Test API to limit child count
417429
if (test_max_child_count_override != 0xffff) {
418430
max_child_count = test_max_child_count_override;
419431
}
420432

421433
//Validate Is EUI64 already allocated for any address
422434
if (ipv6_neighbour_has_registered_by_eui64(&interface->ipv6_neighbour_cache, eui64)) {
423-
ws_common_neighbour_address_reg_link_update(interface, eui64);
435+
ws_common_neighbour_address_reg_link_update(interface, eui64, link_lifetime);
424436
tr_info("Child registration from old child");
437+
425438
return ARO_SUCCESS;
426439
}
427440

@@ -431,20 +444,21 @@ uint8_t ws_common_allow_child_registration(protocol_interface_info_entry_t *inte
431444
return ARO_TOPOLOGICALLY_INCORRECT;
432445
}
433446

434-
435447
ns_list_foreach_safe(mac_neighbor_table_entry_t, cur, &mac_neighbor_info(interface)->neighbour_list) {
436448

437449
if (ipv6_neighbour_has_registered_by_eui64(&interface->ipv6_neighbour_cache, cur->mac64)) {
438450
child_count++;
439451
}
440452
}
453+
441454
if (child_count >= max_child_count) {
442455
tr_warn("Child registration not allowed %d/%d, max:%d", child_count, max_child_count, mac_neighbor_info(interface)->list_total_size);
443456
return ARO_FULL;
444457
}
445458

446-
ws_common_neighbour_address_reg_link_update(interface, eui64);
459+
ws_common_neighbour_address_reg_link_update(interface, eui64, link_lifetime);
447460
tr_info("Child registration allowed %d/%d, max:%d", child_count, max_child_count, mac_neighbor_info(interface)->list_total_size);
461+
448462
return ARO_SUCCESS;
449463
}
450464

source/6LoWPAN/ws/ws_common.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ void ws_common_aro_failure(protocol_interface_info_entry_t *cur, const uint8_t *
148148

149149
void ws_common_neighbor_remove(protocol_interface_info_entry_t *cur, const uint8_t *ll_address);
150150

151-
uint8_t ws_common_allow_child_registration(protocol_interface_info_entry_t *cur, const uint8_t *eui64);
151+
uint8_t ws_common_allow_child_registration(protocol_interface_info_entry_t *cur, const uint8_t *eui64, uint16_t aro_timeout);
152152

153153
bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, const uint8_t *eui64);
154154

@@ -173,7 +173,7 @@ uint8_t ws_common_temporary_entry_size(uint8_t mac_table_size);
173173
#define ws_common_aro_failure(cur, ll_address)
174174
#define ws_common_neighbor_remove(cur, ll_address)
175175
#define ws_common_fast_timer(cur, ticks) ((void) 0)
176-
#define ws_common_allow_child_registration(cur, eui64) (2)
176+
#define ws_common_allow_child_registration(cur, eui64, aro_timeout) (2)
177177
#define ws_common_negative_aro_mark(interface, eui64)(false)
178178
#define ws_common_latency_estimate_get(cur) 0
179179
#define ws_common_datarate_get(cur) 0

source/6LoWPAN/ws/ws_llc_data_service.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ static void ws_llc_mac_confirm_cb(const mac_api_t *api, const mcps_data_conf_t *
537537
ws_llc_mpx_eapol_send(base, message);
538538
}
539539
} else {
540-
if (neighbor_info.ws_neighbor && neighbor_info.neighbor && neighbor_info.neighbor->link_lifetime < WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
540+
if (neighbor_info.ws_neighbor && neighbor_info.neighbor && neighbor_info.neighbor->link_lifetime <= WS_NEIGHBOUR_DHCP_ENTRY_LIFETIME) {
541541
//Remove temp neighbour
542542
tr_debug("Remove Temp Entry by TX confirm");
543543
mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), neighbor_info.neighbor);

test/nanostack/unittest/stub/ws_common_stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void ws_common_neighbor_update(protocol_interface_info_entry_t *cur, const uint8
6464
(void) cur;
6565
(void) ll_address;
6666
}
67-
uint8_t ws_common_allow_child_registration(protocol_interface_info_entry_t *interface, const uint8_t *eui64)
67+
uint8_t ws_common_allow_child_registration(protocol_interface_info_entry_t *interface, const uint8_t *eui64, uint16_t aro_timeout)
6868
{
6969
(void) interface;
7070
return 0;

0 commit comments

Comments
 (0)