]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Fix expiration logic for the first PTKSA cache entry
authorVinay Gannevaram <quic_vganneva@quicinc.com>
Thu, 21 Jul 2022 14:47:26 +0000 (20:17 +0530)
committerJouni Malinen <j@w1.fi>
Fri, 2 Sep 2022 14:10:58 +0000 (17:10 +0300)
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: a4e36916168a ("WPA: Add PTKSA cache implementation")
Signed-off-by: Jouni Malinen <quic_jouni@quicinc.com>
src/common/ptksa_cache.c

index d5f8b7805b505c9208e568b93ef1d0320c6fdc86..aacc42512e36e834f293addec01c4e1763c625d0 100644 (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;
 }