[PATCH] Make proactive key caching working again

Michael Bernhard michael.bernhard
Wed Jul 2 06:41:57 PDT 2008


Signed-off-by: Michael Bernhard <michael.bernhard at bfh.ch>
---
Function 'wpa_sm_set_config' used the argument 'config' as the network context which is
a pointer to a local variable of the function 'wpa_supplicant_rsn_supp_set_config'.

This is one reason why no proactive key was generated. This network context never matched
with the network context saved in the pmksa cache entries.

The structure 'rsn_supp_config' has already a member 'network_ctx' which is now filled in
by this patch with 'ssid'.

The second reason no proactive key was generated is, that each time 'wpa_sm_set_config'
was called the network context in all pmkasa cache entries was cleared.

To avoid this problem, a check is made if the new network context differs from the saved
network context (in sm->network_ctx) before copying the data.

This approach could raise the problem that a new configuration is not activated if the
ssid did not change.

The following patch is more or less a hack because I don't have enough knowledge why it
is implemented that way.

 src/rsn_supp/wpa.c         |    7 ++++++-
 wpa_supplicant/wpas_glue.c |    1 +
 2 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/src/rsn_supp/wpa.c b/src/rsn_supp/wpa.c
index d1b93eb..8ba5710 100644
--- a/src/rsn_supp/wpa.c
+++ b/src/rsn_supp/wpa.c
@@ -1993,8 +1993,12 @@ void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config)
 	if (!sm)
 		return;
 
-	sm->network_ctx = config;
+	if(config && config->network_ctx && 
+	   sm->network_ctx == config->network_ctx)
+		return;
+
 	if (config) {
+		sm->network_ctx = config->network_ctx;
 		sm->peerkey_enabled = config->peerkey_enabled;
 		sm->allowed_pairwise_cipher = config->allowed_pairwise_cipher;
 		sm->proactive_key_caching = config->proactive_key_caching;
@@ -2006,6 +2010,7 @@ void wpa_sm_set_config(struct wpa_sm *sm, struct rsn_supp_config *config)
 		} else
 			sm->ssid_len = 0;
 	} else {
+		sm->network_ctx = NULL;
 		sm->peerkey_enabled = 0;
 		sm->allowed_pairwise_cipher = 0;
 		sm->proactive_key_caching = 0;
diff --git a/wpa_supplicant/wpas_glue.c b/wpa_supplicant/wpas_glue.c
index 913de2c..6efcbdc 100644
--- a/wpa_supplicant/wpas_glue.c
+++ b/wpa_supplicant/wpas_glue.c
@@ -604,6 +604,7 @@ void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
 	struct rsn_supp_config conf;
 	if (ssid) {
 		os_memset(&conf, 0, sizeof(conf));
+		conf.network_ctx = ssid;
 		conf.peerkey_enabled = ssid->peerkey;
 		conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
 #ifdef IEEE8021X_EAPOL
-- 
1.5.4.3




More information about the Hostap mailing list