Skip to content

Commit e656190

Browse files
author
Juha Heiskanen
committed
Wi-SUN neighbour allocate update
Wi-SUN table clean remove oldest temporary when all neigh entriess are used.
1 parent 799f837 commit e656190

File tree

5 files changed

+34
-21
lines changed

5 files changed

+34
-21
lines changed

source/6LoWPAN/ws/ws_bootstrap.c

Lines changed: 31 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,11 @@ static void ws_bootsrap_create_ll_address(uint8_t *ll_address, const uint8_t *ma
138138
ll_address[8] ^= 2;
139139
}
140140

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

143-
{
144-
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), src64, MAC_ADDR_MODE_64_BIT);
145-
if (neighbor) {
146-
return neighbor;
147-
}
148142

149-
neighbor = mac_neighbor_table_entry_allocate(mac_neighbor_info(interface), src64);
143+
static mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_allocate(struct protocol_interface_info_entry *interface, const uint8_t *src64)
144+
{
145+
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_entry_allocate(mac_neighbor_info(interface), src64);
150146
if (!neighbor) {
151147
return NULL;
152148
}
@@ -160,6 +156,17 @@ mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_add(struct protocol_interf
160156
return neighbor;
161157
}
162158

159+
mac_neighbor_table_entry_t *ws_bootstrap_mac_neighbor_add(struct protocol_interface_info_entry *interface, const uint8_t *src64)
160+
161+
{
162+
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), src64, MAC_ADDR_MODE_64_BIT);
163+
if (neighbor) {
164+
return neighbor;
165+
}
166+
167+
return ws_bootstrap_mac_neighbor_allocate(interface, src64);
168+
}
169+
163170
void ws_bootstrap_neighbor_set_stable(struct protocol_interface_info_entry *interface, const uint8_t *src64)
164171
{
165172
mac_neighbor_table_entry_t *neighbor = mac_neighbor_table_address_discover(mac_neighbor_info(interface), src64, MAC_ADDR_MODE_64_BIT);
@@ -200,13 +207,13 @@ static void ws_bootstap_eapol_neigh_entry_allocate(struct protocol_interface_inf
200207
if (!mac_entry) {
201208
return;
202209
}
203-
ws_bootstrap_neighbor_set_stable(interface, mac_64);
204210
mac_entry->lifetime = 0xffffffff;
205211
mac_entry->link_lifetime = 0xffffffff;
206212
ws_neighbor_class_entry_t *ws_neigh = ws_neighbor_class_entry_get(&interface->ws_info->neighbor_storage, mac_entry->index);
207213
if (!ws_neigh) {
208214
return;
209215
}
216+
210217
interface->ws_info->eapol_tx_index = mac_entry->index;
211218
}
212219

@@ -1990,6 +1997,13 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
19901997
// Enough neighbor entries
19911998
return;
19921999
}
2000+
uint32_t temp_link_min_timeout;
2001+
if (mac_neighbor_info(interface)->neighbour_list_size == mac_neighbor_info(interface)->list_total_size) {
2002+
temp_link_min_timeout = 1; //Accept 1 second time from last
2003+
} else {
2004+
temp_link_min_timeout = interface->ws_info->cfg->timing.temp_link_min_timeout;
2005+
}
2006+
19932007
memcpy(ll_target, ADDR_LINK_LOCAL_PREFIX, 8);
19942008

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

2005-
if (cur->link_lifetime < WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
2006-
continue;
2007-
}
2008-
20092019
if (cur->link_role == PRIORITY_PARENT_NEIGHBOUR) {
20102020
//This is our primary parent we cannot delete
20112021
continue;
20122022
}
20132023

2014-
if (cur->nud_active || ws_neighbor->negative_aro_send) {
2024+
if (cur->nud_active) {
20152025
//If NUD process is active do not trig
2026+
// or Negative ARO is active
20162027
continue;
20172028
}
20182029

@@ -2021,6 +2032,11 @@ static void ws_bootstrap_neighbor_table_clean(struct protocol_interface_info_ent
20212032
continue;
20222033
}
20232034

2035+
if (cur->link_lifetime > WS_NEIGHBOUR_TEMPORARY_ENTRY_LIFETIME && cur->link_lifetime <= WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
2036+
//Do not permit to remove configured temp life time
2037+
continue;
2038+
}
2039+
20242040
if (cur->trusted_device) {
20252041

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

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

2137-
if (!entry_ptr->trusted_device || !ws_neighbor || !etx_entry || ws_neighbor->negative_aro_send || entry_ptr->link_lifetime < WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
2153+
if (!entry_ptr->trusted_device || !ws_neighbor || !etx_entry || entry_ptr->link_lifetime <= WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME) {
21382154
return false;
21392155
}
21402156

source/6LoWPAN/ws/ws_cfg_settings.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1449,7 +1449,7 @@ uint32_t ws_cfg_neighbour_temporary_lifetime_get(void)
14491449
}
14501450
void ws_cfg_neighbour_temporary_lifetime_set(uint32_t lifetime)
14511451
{
1452-
if (lifetime >= WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME || lifetime == 0) {
1452+
if (lifetime > WS_NEIGHBOUR_TEMPORARY_NEIGH_MAX_LIFETIME || lifetime == 0) {
14531453
if (lifetime > WS_NEIGHBOR_LINK_TIMEOUT) {
14541454
lifetime = WS_NEIGHBOR_LINK_TIMEOUT;
14551455
}

source/6LoWPAN/ws/ws_common.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,7 @@ bool ws_common_negative_aro_mark(protocol_interface_info_entry_t *interface, con
639639
return false;
640640
}
641641

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

source/6LoWPAN/ws/ws_llc_data_service.c

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

source/6LoWPAN/ws/ws_neighbor_class.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ typedef struct ws_neighbor_class_entry {
3333
bool broadcast_timing_info_stored: 1;
3434
bool broadcast_shedule_info_stored: 1;
3535
bool synch_done : 1;
36-
bool negative_aro_send : 1;
3736
bool unicast_data_rx : 1;
3837
} ws_neighbor_class_entry_t;
3938

0 commit comments

Comments
 (0)