]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Allow OKC to be enabled by default
authorJouni Malinen <jouni@qca.qualcomm.com>
Mon, 12 Nov 2012 18:07:53 +0000 (20:07 +0200)
committerJouni Malinen <j@w1.fi>
Mon, 12 Nov 2012 18:07:53 +0000 (20:07 +0200)
Previously, OKC (opportunistic key caching, a.k.a. proactive key
caching) could be enabled only with a per-network parameter
(proactive_key_caching). The new global parameter (okc) can now be used
to change the default behavior to be OKC enabled (okc=1) for network
blocks that do not override this with the proactive_key_caching
parameter.

Signed-hostap: Jouni Malinen <jouni@qca.qualcomm.com>

wpa_supplicant/config.c
wpa_supplicant/config.h
wpa_supplicant/config_file.c
wpa_supplicant/config_ssid.h
wpa_supplicant/config_winreg.c
wpa_supplicant/sme.c
wpa_supplicant/wpa_supplicant.c
wpa_supplicant/wpa_supplicant.conf
wpa_supplicant/wpas_glue.c

index 736bf0dde84298f825bdacc5e5dc86cc3e1172dc..a927f1cf6f98f95168756c05d4764ada53f95e07 100644 (file)
@@ -2041,6 +2041,7 @@ void wpa_config_set_network_defaults(struct wpa_ssid *ssid)
        ssid->ampdu_factor = DEFAULT_AMPDU_FACTOR;
        ssid->ampdu_density = DEFAULT_AMPDU_DENSITY;
 #endif /* CONFIG_HT_OVERRIDES */
+       ssid->proactive_key_caching = -1;
 }
 
 
@@ -3033,6 +3034,7 @@ static const struct global_parse_data global_fields[] = {
        { STR(ext_password_backend), CFG_CHANGED_EXT_PW_BACKEND },
        { INT(p2p_go_max_inactivity), 0 },
        { INT_RANGE(auto_interworking, 0, 1), 0 },
+       { INT(okc), 0 },
 };
 
 #undef FUNC
index fd2a628577b2cc112af491a452aff420c2ecf95c..3dbb4a080d58cf2e781f221cdaecf5a933898590 100644 (file)
@@ -773,6 +773,15 @@ struct wpa_config {
         * also for the group operation.
         */
        int p2p_no_group_iface;
+
+       /**
+        * okc - Whether to enable opportunistic key caching by default
+        *
+        * By default, OKC is disabled unless enabled by the per-network
+        * proactive_key_caching=1 parameter. okc=1 can be used to change this
+        * default behavior.
+        */
+       int okc;
 };
 
 
index c473891cd6615e021bc8b515587b2586aa0eb356..c25b4af6a76618ceb7c91349d7bf5e0d14131392 100644 (file)
@@ -676,7 +676,7 @@ static void wpa_config_write_network(FILE *f, struct wpa_ssid *ssid)
        INT_DEFe(fragment_size, DEFAULT_FRAGMENT_SIZE);
 #endif /* IEEE8021X_EAPOL */
        INT(mode);
-       INT(proactive_key_caching);
+       write_int(f, "proactive_key_caching", ssid->proactive_key_caching, -1);
        INT(disabled);
        INT(peerkey);
 #ifdef CONFIG_IEEE80211W
@@ -926,6 +926,8 @@ static void wpa_config_write_global(FILE *f, struct wpa_config *config)
        if (config->auto_interworking)
                fprintf(f, "auto_interworking=%d\n",
                        config->auto_interworking);
+       if (config->okc)
+               fprintf(f, "okc=%d\n", config->okc);
 }
 
 #endif /* CONFIG_NO_CONFIG_WRITE */
index be83cc28ea2b2f3c35a9b2e9eeff5095275d82f6..2d4d91453f266f8725eb53a15434c9eb655ba5c7 100644 (file)
@@ -228,13 +228,18 @@ struct wpa_ssid {
         *
         * This field can be used to enable proactive key caching which is also
         * known as opportunistic PMKSA caching for WPA2. This is disabled (0)
-        * by default. Enable by setting this to 1.
+        * by default unless default value is changed with the global okc=1
+        * parameter. Enable by setting this to 1.
         *
         * Proactive key caching is used to make supplicant assume that the APs
         * are using the same PMK and generate PMKSA cache entries without
         * doing RSN pre-authentication. This requires support from the AP side
         * and is normally used with wireless switches that co-locate the
         * authenticator.
+        *
+        * Internally, special value -1 is used to indicate that the parameter
+        * was not specified in the configuration (i.e., default behavior is
+        * followed).
         */
        int proactive_key_caching;
 
index 6d9876cc163e3ec2a4bb95a5457b205eaf4cfa04..48a1a9469adb4f884e44bd5747a90e76d0162715 100644 (file)
@@ -271,6 +271,8 @@ static int wpa_config_read_global(struct wpa_config *config, HKEY hk)
        wpa_config_read_reg_dword(hk, TEXT("disassoc_low_ack"),
                                  (int *) &config->disassoc_low_ack);
 
+       wpa_config_read_reg_dword(hk, TEXT("okc"), &config->okc);
+
        return errors ? -1 : 0;
 }
 
@@ -609,6 +611,8 @@ static int wpa_config_write_global(struct wpa_config *config, HKEY hk)
        wpa_config_write_reg_dword(hk, TEXT("disassoc_low_ack"),
                                   config->disassoc_low_ack, 0);
 
+       wpa_config_write_reg_dword(hk, TEXT("okc"), config->okc, 0);
+
        return 0;
 }
 
@@ -904,7 +908,8 @@ static int wpa_config_write_network(HKEY hk, struct wpa_ssid *ssid, int id)
        INT_DEFe(fragment_size, DEFAULT_FRAGMENT_SIZE);
 #endif /* IEEE8021X_EAPOL */
        INT(mode);
-       INT(proactive_key_caching);
+       write_int(netw, "proactive_key_caching", ssid->proactive_key_caching,
+                 -1);
        INT(disabled);
        INT(peerkey);
 #ifdef CONFIG_IEEE80211W
index 7d863fd3629595181c228f9fb871b795eb0c09de..f6e106c88d12438e3c56b49d515defdc5ec27954 100644 (file)
@@ -171,7 +171,9 @@ void sme_send_authentication(struct wpa_supplicant *wpa_s,
             wpa_bss_get_ie(bss, WLAN_EID_RSN)) &&
            wpa_key_mgmt_wpa(ssid->key_mgmt)) {
                int try_opportunistic;
-               try_opportunistic = ssid->proactive_key_caching &&
+               try_opportunistic = (ssid->proactive_key_caching < 0 ?
+                                    wpa_s->conf->okc :
+                                    ssid->proactive_key_caching) &&
                        (ssid->proto & WPA_PROTO_RSN);
                if (pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid,
                                            wpa_s->current_ssid,
index ee283b777e749a968b70f8b51bf11f110c442944..1a153f6febb9d37a26856f0224737edccb403af1 100644 (file)
@@ -1355,7 +1355,9 @@ void wpa_supplicant_associate(struct wpa_supplicant *wpa_s,
                    wpa_bss_get_ie(bss, WLAN_EID_RSN)) &&
            wpa_key_mgmt_wpa(ssid->key_mgmt)) {
                int try_opportunistic;
-               try_opportunistic = ssid->proactive_key_caching &&
+               try_opportunistic = (ssid->proactive_key_caching < 0 ?
+                                    wpa_s->conf->okc :
+                                    ssid->proactive_key_caching) &&
                        (ssid->proto & WPA_PROTO_RSN);
                if (pmksa_cache_set_current(wpa_s->wpa, NULL, bss->bssid,
                                            wpa_s->current_ssid,
index 0b0ea88d7862f05e4fd4787f8f74a8c8860485d2..e1000feb5edb3c75f7302495b6a19364b4e15139 100644 (file)
@@ -265,6 +265,13 @@ fast_reauth=1
 # inactive stations.
 #p2p_go_max_inactivity=300
 
+# Opportunistic Key Caching (also known as Proactive Key Caching) default
+# This parameter can be used to set the default behavior for the
+# proactive_key_caching parameter. By default, OKC is disabled unless enabled
+# with the global okc=1 parameter or with the per-network
+# proactive_key_caching=1 parameter. With okc=1, OKC is enabled by default, but
+# can be disabled with per-network proactive_key_caching=0 parameter.
+#okc=0
 
 # Interworking (IEEE 802.11u)
 
@@ -548,7 +555,7 @@ fast_reauth=1
 #
 # proactive_key_caching:
 # Enable/disable opportunistic PMKSA caching for WPA2.
-# 0 = disabled (default)
+# 0 = disabled (default unless changed with the global okc parameter)
 # 1 = enabled
 #
 # wep_key0..3: Static WEP key (ASCII in double quotation, e.g. "abcde" or
index aec639a316544f47225984223e4f39bea54496d6..1ba4c92bcaf433843fac1958779786d0498ecdde 100644 (file)
@@ -880,7 +880,8 @@ void wpa_supplicant_rsn_supp_set_config(struct wpa_supplicant *wpa_s,
                conf.peerkey_enabled = ssid->peerkey;
                conf.allowed_pairwise_cipher = ssid->pairwise_cipher;
 #ifdef IEEE8021X_EAPOL
-               conf.proactive_key_caching = ssid->proactive_key_caching;
+               conf.proactive_key_caching = ssid->proactive_key_caching < 0 ?
+                       wpa_s->conf->okc : ssid->proactive_key_caching;
                conf.eap_workaround = ssid->eap_workaround;
                conf.eap_conf_ctx = &ssid->eap;
 #endif /* IEEE8021X_EAPOL */