Skip to content

Commit

Permalink
Corrected BR removing of waiting list entry when supplicant is in key…
Browse files Browse the repository at this point in the history
… 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.
  • Loading branch information
Mika Leppänen authored and mikaleppanen committed Sep 20, 2021
1 parent 0d54d7a commit b8722e8
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions source/6LoWPAN/ws/ws_pae_auth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1153,27 +1153,36 @@ static bool ws_pae_auth_active_limit_reached(uint16_t active_supp, pae_auth_t *p
return pae_auth->congestion_get(pae_auth->interface_ptr, active_supp);
}

static void ws_pae_auth_waiting_supp_remove_oldest(pae_auth_t *pae_auth, const kmp_addr_t *addr)
{
supp_entry_t *delete_supp = ns_list_get_last(&pae_auth->waiting_supp_list);
if (!delete_supp) {
return;
}
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));
// Create new instance
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);
if (!new_kmp) {
return;
}
kmp_api_create_request(new_kmp, MSG_PROT, &delete_supp->addr, &delete_supp->sec_keys);
(void) ws_pae_lib_supp_list_remove(pae_auth, &pae_auth->waiting_supp_list, delete_supp, ws_pae_auth_waiting_supp_deleted);
}

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)
{
// Entry is already allocated
if (supp_entry) {
// If the waiting list if full removes the oldest entry from the list
if (pae_auth->waiting_supp_list_size >= WAITING_SUPPLICANT_LIST_MAX_SIZE) {
ws_pae_auth_waiting_supp_remove_oldest(pae_auth, addr);
}
ns_list_add_to_start(&pae_auth->waiting_supp_list, supp_entry);
pae_auth->waiting_supp_list_size++;
} else {
// If the waiting list if full removes the oldest entry from the list
if (pae_auth->waiting_supp_list_size >= WAITING_SUPPLICANT_LIST_MAX_SIZE) {
supp_entry_t *delete_supp = ns_list_get_last(&pae_auth->waiting_supp_list);
if (!delete_supp) {
return NULL;
}
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));
// Create new instance
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);
if (!new_kmp) {
return NULL;
}
kmp_api_create_request(new_kmp, MSG_PROT, &delete_supp->addr, &delete_supp->sec_keys);
(void) ws_pae_lib_supp_list_remove(pae_auth, &pae_auth->waiting_supp_list, delete_supp, ws_pae_auth_waiting_supp_deleted);
ws_pae_auth_waiting_supp_remove_oldest(pae_auth, addr);
}
supp_entry = ws_pae_lib_supp_list_add(&pae_auth->waiting_supp_list, addr);
if (!supp_entry) {
Expand Down

0 comments on commit b8722e8

Please sign in to comment.