Fix expiration logic for the first PTKSA cache entry

When an entry is added to the PTKSA cache, timer expiration is not set.
Check the list and set the timer expiration when the list is empty also.
When another entry is added to the list, it is placed before the relavant
entry in the order of expiry time of all entries present in the list.

Fixes: a4e3691616 ("WPA: Add PTKSA cache implementation")
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
This commit is contained in:
Vinay Gannevaram 2022-07-21 20:17:26 +05:30 committed by Jouni Malinen
parent 85e28a79ba
commit 6f8af5974c

View file

@ -281,6 +281,7 @@ struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa,
{
struct ptksa_cache_entry *entry, *tmp, *tmp2 = NULL;
struct os_reltime now;
bool set_expiry = false;
if (!ptksa || !ptk || !addr || !life_time || cipher == WPA_CIPHER_NONE)
return NULL;
@ -317,6 +318,8 @@ struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa,
}
}
if (dl_list_empty(&entry->list))
set_expiry = true;
/*
* If the expiration is later then all other or the list is empty
* entries, add it to the end of the list;
@ -332,5 +335,8 @@ struct ptksa_cache_entry * ptksa_cache_add(struct ptksa_cache *ptksa,
"Added PTKSA cache entry addr=" MACSTR " cipher=%u",
MAC2STR(addr), cipher);
if (set_expiry)
ptksa_cache_set_expiration(ptksa);
return entry;
}