Skip to content

Commit b8722e8

Browse files
Mika Leppänenmikaleppanen
authored andcommitted
Corrected BR removing of waiting list entry when supplicant is in key storage
When supplicant data was fetched from key storage, the oldest waiting list entry was not removed. This caused list to grow beyond the defined maximum size.
1 parent 0d54d7a commit b8722e8

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

source/6LoWPAN/ws/ws_pae_auth.c

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,27 +1153,36 @@ static bool ws_pae_auth_active_limit_reached(uint16_t active_supp, pae_auth_t *p
11531153
return pae_auth->congestion_get(pae_auth->interface_ptr, active_supp);
11541154
}
11551155

1156+
static void ws_pae_auth_waiting_supp_remove_oldest(pae_auth_t *pae_auth, const kmp_addr_t *addr)
1157+
{
1158+
supp_entry_t *delete_supp = ns_list_get_last(&pae_auth->waiting_supp_list);
1159+
if (!delete_supp) {
1160+
return;
1161+
}
1162+
tr_info("PAE: waiting list full, eui-64: %s, deleted eui-64: %s", trace_array(addr->eui_64, 8), trace_array(delete_supp->addr.eui_64, 8));
1163+
// Create new instance
1164+
kmp_api_t *new_kmp = ws_pae_auth_kmp_create_and_start(pae_auth->kmp_service, MSG_PROT, pae_auth->relay_socked_msg_if_instance_id, delete_supp, pae_auth->sec_cfg);
1165+
if (!new_kmp) {
1166+
return;
1167+
}
1168+
kmp_api_create_request(new_kmp, MSG_PROT, &delete_supp->addr, &delete_supp->sec_keys);
1169+
(void) ws_pae_lib_supp_list_remove(pae_auth, &pae_auth->waiting_supp_list, delete_supp, ws_pae_auth_waiting_supp_deleted);
1170+
}
1171+
11561172
static supp_entry_t *ws_pae_auth_waiting_supp_list_add(pae_auth_t *pae_auth, supp_entry_t *supp_entry, const kmp_addr_t *addr)
11571173
{
11581174
// Entry is already allocated
11591175
if (supp_entry) {
1176+
// If the waiting list if full removes the oldest entry from the list
1177+
if (pae_auth->waiting_supp_list_size >= WAITING_SUPPLICANT_LIST_MAX_SIZE) {
1178+
ws_pae_auth_waiting_supp_remove_oldest(pae_auth, addr);
1179+
}
11601180
ns_list_add_to_start(&pae_auth->waiting_supp_list, supp_entry);
11611181
pae_auth->waiting_supp_list_size++;
11621182
} else {
11631183
// If the waiting list if full removes the oldest entry from the list
11641184
if (pae_auth->waiting_supp_list_size >= WAITING_SUPPLICANT_LIST_MAX_SIZE) {
1165-
supp_entry_t *delete_supp = ns_list_get_last(&pae_auth->waiting_supp_list);
1166-
if (!delete_supp) {
1167-
return NULL;
1168-
}
1169-
tr_info("PAE: waiting list full, eui-64: %s, deleted eui-64: %s", trace_array(addr->eui_64, 8), trace_array(delete_supp->addr.eui_64, 8));
1170-
// Create new instance
1171-
kmp_api_t *new_kmp = ws_pae_auth_kmp_create_and_start(pae_auth->kmp_service, MSG_PROT, pae_auth->relay_socked_msg_if_instance_id, delete_supp, pae_auth->sec_cfg);
1172-
if (!new_kmp) {
1173-
return NULL;
1174-
}
1175-
kmp_api_create_request(new_kmp, MSG_PROT, &delete_supp->addr, &delete_supp->sec_keys);
1176-
(void) ws_pae_lib_supp_list_remove(pae_auth, &pae_auth->waiting_supp_list, delete_supp, ws_pae_auth_waiting_supp_deleted);
1185+
ws_pae_auth_waiting_supp_remove_oldest(pae_auth, addr);
11771186
}
11781187
supp_entry = ws_pae_lib_supp_list_add(&pae_auth->waiting_supp_list, addr);
11791188
if (!supp_entry) {

0 commit comments

Comments
 (0)