Add PMKSA-CACHE-ADDED/REMOVED events to wpa_supplicant

These allow external program to monitor PMKSA cache updates in
preparation to enable external persistent storage of PMKSA cache.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2016-12-12 20:59:41 +02:00 committed by Jouni Malinen
parent 655dc4a432
commit c579312736
6 changed files with 49 additions and 13 deletions

View file

@ -288,6 +288,11 @@ extern "C" {
/* BSS Transition Management Request received with MBO transition reason */
#define MBO_TRANSITION_REASON "MBO-TRANSITION-REASON "
/* PMKSA cache entry added; parameters: <BSSID> <network_id> */
#define PMKSA_CACHE_ADDED "PMKSA-CACHE-ADDED "
/* PMKSA cache entry removed; parameters: <BSSID> <network_id> */
#define PMKSA_CACHE_REMOVED "PMKSA-CACHE-REMOVED "
/* BSS command information masks */
#define WPA_BSS_MASK_ALL 0xFFFDFFFF

View file

@ -43,7 +43,8 @@ static void pmksa_cache_free_entry(struct rsn_pmksa_cache *pmksa,
struct rsn_pmksa_cache_entry *entry,
enum pmksa_free_reason reason)
{
wpa_sm_remove_pmkid(pmksa->sm, entry->aa, entry->pmkid);
wpa_sm_remove_pmkid(pmksa->sm, entry->network_ctx, entry->aa,
entry->pmkid);
pmksa->pmksa_count--;
pmksa->free_cb(entry, pmksa->ctx, reason);
_pmksa_cache_free_entry(entry);
@ -245,7 +246,7 @@ pmksa_cache_add(struct rsn_pmksa_cache *pmksa, const u8 *pmk, size_t pmk_len,
pmksa->pmksa_count++;
wpa_printf(MSG_DEBUG, "RSN: Added PMKSA cache entry for " MACSTR
" network_ctx=%p", MAC2STR(entry->aa), network_ctx);
wpa_sm_add_pmkid(pmksa->sm, entry->aa, entry->pmkid);
wpa_sm_add_pmkid(pmksa->sm, network_ctx, entry->aa, entry->pmkid);
return entry;
}

View file

@ -342,7 +342,7 @@ void rsn_preauth_candidate_process(struct wpa_sm *sm)
/* Some drivers (e.g., NDIS) expect to get notified about the
* PMKIDs again, so report the existing data now. */
if (p) {
wpa_sm_add_pmkid(sm, candidate->bssid, p->pmkid);
wpa_sm_add_pmkid(sm, NULL, candidate->bssid, p->pmkid);
}
dl_list_del(&candidate->list);

View file

@ -38,8 +38,10 @@ struct wpa_sm_ctx {
void (*cancel_auth_timeout)(void *ctx);
u8 * (*alloc_eapol)(void *ctx, u8 type, const void *data, u16 data_len,
size_t *msg_len, void **data_pos);
int (*add_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
int (*remove_pmkid)(void *ctx, const u8 *bssid, const u8 *pmkid);
int (*add_pmkid)(void *ctx, void *network_ctx, const u8 *bssid,
const u8 *pmkid);
int (*remove_pmkid)(void *ctx, void *network_ctx, const u8 *bssid,
const u8 *pmkid);
void (*set_config_blob)(void *ctx, struct wpa_config_blob *blob);
const struct wpa_config_blob * (*get_config_blob)(void *ctx,
const char *name);

View file

@ -219,18 +219,18 @@ static inline u8 * wpa_sm_alloc_eapol(struct wpa_sm *sm, u8 type,
msg_len, data_pos);
}
static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, const u8 *bssid,
const u8 *pmkid)
static inline int wpa_sm_add_pmkid(struct wpa_sm *sm, void *network_ctx,
const u8 *bssid, const u8 *pmkid)
{
WPA_ASSERT(sm->ctx->add_pmkid);
return sm->ctx->add_pmkid(sm->ctx->ctx, bssid, pmkid);
return sm->ctx->add_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid);
}
static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, const u8 *bssid,
const u8 *pmkid)
static inline int wpa_sm_remove_pmkid(struct wpa_sm *sm, void *network_ctx,
const u8 *bssid, const u8 *pmkid)
{
WPA_ASSERT(sm->ctx->remove_pmkid);
return sm->ctx->remove_pmkid(sm->ctx->ctx, bssid, pmkid);
return sm->ctx->remove_pmkid(sm->ctx->ctx, network_ctx, bssid, pmkid);
}
static inline int wpa_sm_mlme_setprotection(struct wpa_sm *sm, const u8 *addr,

View file

@ -513,16 +513,44 @@ static int wpa_supplicant_mlme_setprotection(void *wpa_s, const u8 *addr,
}
static int wpa_supplicant_add_pmkid(void *wpa_s,
static struct wpa_ssid * wpas_get_network_ctx(struct wpa_supplicant *wpa_s,
void *network_ctx)
{
struct wpa_ssid *ssid;
for (ssid = wpa_s->conf->ssid; ssid; ssid = ssid->next) {
if (network_ctx == ssid)
return ssid;
}
return NULL;
}
static int wpa_supplicant_add_pmkid(void *_wpa_s, void *network_ctx,
const u8 *bssid, const u8 *pmkid)
{
struct wpa_supplicant *wpa_s = _wpa_s;
struct wpa_ssid *ssid;
ssid = wpas_get_network_ctx(wpa_s, network_ctx);
if (ssid)
wpa_msg(wpa_s, MSG_INFO, PMKSA_CACHE_ADDED MACSTR " %d",
MAC2STR(bssid), ssid->id);
return wpa_drv_add_pmkid(wpa_s, bssid, pmkid);
}
static int wpa_supplicant_remove_pmkid(void *wpa_s,
static int wpa_supplicant_remove_pmkid(void *_wpa_s, void *network_ctx,
const u8 *bssid, const u8 *pmkid)
{
struct wpa_supplicant *wpa_s = _wpa_s;
struct wpa_ssid *ssid;
ssid = wpas_get_network_ctx(wpa_s, network_ctx);
if (ssid)
wpa_msg(wpa_s, MSG_INFO, PMKSA_CACHE_REMOVED MACSTR " %d",
MAC2STR(bssid), ssid->id);
return wpa_drv_remove_pmkid(wpa_s, bssid, pmkid);
}