Skip to content

Commit

Permalink
Wi-SUN neighbour allocate update
Browse files Browse the repository at this point in the history
Wi-SUN table clean remove oldest temporary when all neigh entriess are used.
  • Loading branch information
Juha Heiskanen committed Mar 9, 2021
1 parent 799f837 commit e656190
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
46 changes: 31 additions & 15 deletions source/6LoWPAN/ws/ws_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,11 @@ static void ws_bootsrap_create_ll_address(uint8_t *ll_address, const uint8_t *ma
ll_address[8] ^= 2;
}

mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)

{
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), src64, MAC_ADDR_MODE_64_BIT);
if (neighbor) {
return neighbor;
}

neighbor = mac_neighbor_table_entry_allocate(mac_neighbor_info(interface), src64);
static mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_allocate(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_entry_allocate(mac_neighbor_info(interface), src64);
if (!neighbor) {
return NULL;
}
Expand All @@ -160,6 +156,17 @@ mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_add(struct protocol_interf
return neighbor;
}

mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)

{
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), src64, MAC_ADDR_MODE_64_BIT);
if (neighbor) {
return neighbor;
}

return ws_bootstrap_mac_neighbor_allocate(interface, src64);
}

void ws_bootstrap_neighbor_set_stable(struct protocol_interface_info_entry *interface, const uint8_t *src64)
{
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), src64, MAC_ADDR_MODE_64_BIT);
Expand Down Expand Up @@ -200,13 +207,13 @@ static void ws_bootstap_eapol_neigh_entry_allocate(struct protocol_interface_inf
if (!mac_entry) {
return;
}
ws_bootstrap_neighbor_set_stable(interface, mac_64);
mac_entry->lifetime = 0xffffffff;
mac_entry->link_lifetime = 0xffffffff;
ws_neighbor_class_entry_t *ws_neigh = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, mac_entry->index);
if (!ws_neigh) {
return;
}

interface->ws_info->eapol_tx_index = mac_entry->index;
}

Expand Down Expand Up @@ -1990,6 +1997,13 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
// Enough neighbor entries
return;
}
uint32_t temp_link_min_timeout;
if (mac_neighbor_info(interface)->neighbour_list_size == mac_neighbor_info(interface)->list_total_size) {
temp_link_min_timeout = 1; //Accept 1 second time from last
} else {
temp_link_min_timeout = interface->ws_info->cfg->timing.temp_link_min_timeout;
}

memcpy(ll_target, ADDR_LINK_LOCAL_PREFIX, 8);

uint32_t current_time_stamp = ns_sw_mac_read_current_timestamp(interface->mac_api);
Expand All @@ -2002,17 +2016,14 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
continue;
}

if (cur->link_lifetime < WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
continue;
}

if (cur->link_role == PRIORITY_PARENT_NEIGHBOUR) {
//This is our primary parent we cannot delete
continue;
}

if (cur->nud_active || ws_neighbor->negative_aro_send) {
if (cur->nud_active) {
//If NUD process is active do not trig
// or Negative ARO is active
continue;
}

Expand All @@ -2021,6 +2032,11 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
continue;
}

if (cur->link_lifetime > WS_NEIGHBOUR_TEMPORARY_ENTRY_LIFETIME && cur->link_lifetime <= WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
//Do not permit to remove configured temp life time
continue;
}

if (cur->trusted_device) {

if (ipv6_neighbour_has_registered_by_eui64(&interface->ipv6_neighbour_cache, cur->mac64)) {
Expand All @@ -2039,7 +2055,7 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent

//Read current timestamp
uint32_t time_from_last_unicast_shedule = ws_time_from_last_unicast_traffic(current_time_stamp, ws_neighbor);
if (time_from_last_unicast_shedule > interface->ws_info->cfg->timing.temp_link_min_timeout) {
if (time_from_last_unicast_shedule >= temp_link_min_timeout) {
//Accept only Enough Old Device
if (!neighbor_entry_ptr) {
//Accept first compare
Expand Down Expand Up @@ -2134,7 +2150,7 @@ static bool ws_neighbor_entry_nud_notify(mac_neighbor_table_entry_t *entry_ptr,
ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&cur->ws_info->neighbor_storage, entry_ptr->index);
etx_storage_t *etx_entry = etx_storage_entry_get(cur->id, entry_ptr->index);

if (!entry_ptr->trusted_device || !ws_neighbor || !etx_entry || ws_neighbor->negative_aro_send || entry_ptr->link_lifetime < WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
if (!entry_ptr->trusted_device || !ws_neighbor || !etx_entry || entry_ptr->link_lifetime <= WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/ws/ws_cfg_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1449,7 +1449,7 @@ uint32_t ws_cfg_neighbour_temporary_lifetime_get(void)
}
void ws_cfg_neighbour_temporary_lifetime_set(uint32_t lifetime)
{
if (lifetime >= WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME || lifetime == 0) {
if (lifetime > WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME || lifetime == 0) {
if (lifetime > WS_NEIGHBOR_LINK_TIMEOUT) {
lifetime = WS_NEIGHBOR_LINK_TIMEOUT;
}
Expand Down
4 changes: 1 addition & 3 deletions source/6LoWPAN/ws/ws_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -639,9 +639,7 @@ bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, con
return false;
}

ws_neighbor_class_entry_t *ws_neighbor = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, neighbour->index);
ws_neighbor->negative_aro_send = true;
neighbour->lifetime = WS_NEIGHBOR_TEMPORARY_LINK_MIN_TIMEOUT_SMALL; //Remove anyway if Packet is freed before MAC push
ws_bootstrap_mac_neighbor_short_time_set(interface, eui64, WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion source/6LoWPAN/ws/ws_llc_data_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ static void ws_llc_mac_confirm_cb(const mac_api_t *api, const mcps_data_conf_t *
ws_llc_mpx_eapol_send(base, message);
}
} else {
if (neighbor_info.ws_neighbor && neighbor_info.neighbor && neighbor_info.neighbor->link_lifetime <= WS_NEIGHBOUR_DHCP_ENTRY_LIFETIME) {
if (neighbor_info.ws_neighbor && neighbor_info.neighbor && neighbor_info.neighbor->link_lifetime <= WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
//Remove temp neighbour
tr_debug("Remove Temp Entry by TX confirm");
mac_neighbor_table_neighbor_remove(mac_neighbor_info(interface), neighbor_info.neighbor);
Expand Down
1 change: 0 additions & 1 deletion source/6LoWPAN/ws/ws_neighbor_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ typedef struct ws_neighbor_class_entry {
bool broadcast_timing_info_stored: 1;
bool broadcast_shedule_info_stored: 1;
bool synch_done : 1;
bool negative_aro_send : 1;
bool unicast_data_rx : 1;
} ws_neighbor_class_entry_t;

Expand Down

0 comments on commit e656190

Please sign in to comment.