~ubuntu-branches/ubuntu/precise/wpasupplicant/precise-proposed

« back to all changes in this revision

Viewing changes to src/rsn_supp/wpa.c

  • Committer: Package Import Robot
  • Author(s): Mathieu Trudel-Lapierre
  • Date: 2013-06-12 15:57:50 UTC
  • Revision ID: package-import@ubuntu.com-20130612155750-go9lgylcef8n3f2f
Tags: 0.7.3-6ubuntu2.2
* Multiple patches to reduce the number of disconnections for WPA Enterprise
  roaming and Opportunistic Key Caching. (LP: #1187524)
* In debian/patches:
  0001-sme-fix-retry-after-auth-assoc-timeout-failure.patch,
  0002-sme-optimize-recovery-from-common-load-balancing-mechanisms.patch,
  0003-sme-blacklist-bss-on-first-failure-if-only-a-*.patch,
  0004-sme-extend-load-balancing-optimization-in-bss-blacklisting.patch,
  0005-sme-optimize-recovery-from-association-command-failures.patch,
  0006-sme-add-timers-for-authentication-and-association.patch,
  0007-sme-nl80211-set-cipher-suites.patch:
  Cherry-pick patches fixing SME (Session Management Entity) for the nl80211
  driver, which works as a basis for the OKC patches.
* In debian/patches:
  0001-pmkokc-Set-portValid-TRUE-on-association-for-driver-based-4.patch,
  0002-pmkokc-Clear-WPA-and-EAPOL-state-machine-config-pointer-on-.patch,
  0003-pmkokc-Clear-driver-PMKSA-cache-entry-on-PMKSA-cache-expira.patch,
  0004-pmkokc-Flush-PMKSA-cache-entries-and-invalidate-EAP-state-o.patch,
  0005-pmkokc-Fix-proactive_key_caching-configuration-to-WPA-code.patch,
  0006-pmkokc-RSN-Add-a-debug-message-when-considing-addition-of-O.patch,
  0007-pmkokc-Clear-OKC-based-PMKSA-caching-entries-if-PMK-is-chan.patch,
  0008-pmkokc-Move-wpa_sm_remove_pmkid-call-to-PMKSA-cache-entry-f.patch,
  0009-pmkokc-Use-PMKSA-cache-entries-with-only-a-single-network-c.patch,
  0010-pmkokc-PMKSA-Do-not-evict-active-cache-entry-when-adding-ne.patch,
  0011-pmkokc-PMKSA-Set-cur_pmksa-pointer-during-initial-associati.patch,
  0012-pmkokc-PMKSA-make-deauthentication-due-to-cache-entry-remov.patch,
  0013-pmkokc-PMKSA-update-current-cache-entry-due-to-association-.patch:
  Cherry-pick patches to properly do OKC (Opportunistic Key Caching) which
  helps maintaining connectivity on networks secured with WPA Enterprise,
  especially on nl80211-based drivers -- these patches require SME, and add
  or fix key caching and handling of the cache entries.
* debian/patches/force-enable-okc.patch: force Opportunistic Key Caching to
  be enabled.
* debian/patches/less-aggressive-roaming.patch: use less aggressive roaming
  settings to avoid switching to another AP unnecessarily, when the actual
  signal level difference is small.
* debian/patches/wpa_supplicant-dbus-null-error.patch: Don't send NULL to
  dbus_message_new_error().
* debian/patches/0001-nl80211-Fix-UNSPEC-signal-quality-reporting.patch: fix
  marking qual as invalid rather than signal level.
* debian/patches/wpa_supplicant-squelch-driver-disconnect-spam.patch: recover
  cleanly from streams of disconnect messages (like on iwl3945).
* debian/patches/wpa_supplicant-assoc-timeout.patch: increase association
  timeouts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
                 * not have enough time to get the association information
145
145
                 * event before receiving this 1/4 message, so try to find a
146
146
                 * matching PMKSA cache entry here. */
147
 
                sm->cur_pmksa = pmksa_cache_get(sm->pmksa, src_addr, pmkid);
 
147
                sm->cur_pmksa = pmksa_cache_get(sm->pmksa, src_addr, pmkid,
 
148
                                                NULL);
148
149
                if (sm->cur_pmksa) {
149
150
                        wpa_printf(MSG_DEBUG, "RSN: found matching PMKID from "
150
151
                                   "PMKSA cache");
187
188
#endif /* CONFIG_IEEE80211R */
188
189
                }
189
190
                if (res == 0) {
 
191
                        struct rsn_pmksa_cache_entry *sa = NULL;
190
192
                        wpa_hexdump_key(MSG_DEBUG, "WPA: PMK from EAPOL state "
191
193
                                        "machines", sm->pmk, pmk_len);
192
194
                        sm->pmk_len = pmk_len;
193
195
                        if (sm->proto == WPA_PROTO_RSN) {
194
 
                                pmksa_cache_add(sm->pmksa, sm->pmk, pmk_len,
195
 
                                                src_addr, sm->own_addr,
196
 
                                                sm->network_ctx, sm->key_mgmt);
 
196
                                sa = pmksa_cache_add(sm->pmksa,
 
197
                                                     sm->pmk, pmk_len,
 
198
                                                     src_addr, sm->own_addr,
 
199
                                                     sm->network_ctx,
 
200
                                                     sm->key_mgmt);
197
201
                        }
198
202
                        if (!sm->cur_pmksa && pmkid &&
199
 
                            pmksa_cache_get(sm->pmksa, src_addr, pmkid)) {
 
203
                            pmksa_cache_get(sm->pmksa, src_addr, pmkid, NULL))
 
204
                        {
200
205
                                wpa_printf(MSG_DEBUG, "RSN: the new PMK "
201
206
                                           "matches with the PMKID");
202
207
                                abort_cached = 0;
203
208
                        }
 
209
 
 
210
                        if (!sm->cur_pmksa)
 
211
                                sm->cur_pmksa = sa;
204
212
                } else {
205
213
                        wpa_msg(sm->ctx->msg_ctx, MSG_WARNING,
206
214
                                "WPA: Failed to get master session key from "
1933
1941
 
1934
1942
 
1935
1943
static void wpa_sm_pmksa_free_cb(struct rsn_pmksa_cache_entry *entry,
1936
 
                                 void *ctx, int replace)
 
1944
                                 void *ctx, int reason)
1937
1945
{
1938
1946
        struct wpa_sm *sm = ctx;
1939
 
 
1940
 
        if (sm->cur_pmksa == entry ||
 
1947
        int deauth = 0;
 
1948
 
 
1949
        if (sm->cur_pmksa == entry) {
 
1950
                wpa_printf(MSG_DEBUG, "RSN: removed current PMKSA entry");
 
1951
                pmksa_cache_clear_current (sm);
 
1952
 
 
1953
                /* If an entry is simply being replaced, there's no need to
 
1954
                 * deauthenticate because it will be immediately re-added.
 
1955
                 * This happens when EAP authentication is completed again
 
1956
                 * (reauth or failed PMKSA caching attempt). */
 
1957
                if (reason != PMKSA_REPLACE) {
 
1958
                        wpa_printf(MSG_DEBUG,
 
1959
                                   "RSN: deauthenticating due to removed entry");
 
1960
                        deauth = 1;
 
1961
                }
 
1962
        }
 
1963
 
 
1964
        if (reason == PMKSA_EXPIRE &&
1941
1965
            (sm->pmk_len == entry->pmk_len &&
1942
1966
             os_memcmp(sm->pmk, entry->pmk, sm->pmk_len) == 0)) {
1943
 
                wpa_printf(MSG_DEBUG, "RSN: removed current PMKSA entry");
1944
 
                sm->cur_pmksa = NULL;
1945
 
 
1946
 
                if (replace) {
1947
 
                        /* A new entry is being added, so no need to
1948
 
                         * deauthenticate in this case. This happens when EAP
1949
 
                         * authentication is completed again (reauth or failed
1950
 
                         * PMKSA caching attempt). */
1951
 
                        return;
1952
 
                }
1953
 
 
 
1967
                wpa_printf(MSG_DEBUG,
 
1968
                           "RSN: deauthenticating due to expired PMK");
 
1969
                pmksa_cache_clear_current (sm);
 
1970
                deauth = 1;
 
1971
        }
 
1972
 
 
1973
        if (deauth) {
1954
1974
                os_memset(sm->pmk, 0, sizeof(sm->pmk));
1955
1975
                wpa_sm_deauthenticate(sm, WLAN_REASON_UNSPECIFIED);
1956
1976
        }
2019
2039
 * wpa_sm_notify_assoc - Notify WPA state machine about association
2020
2040
 * @sm: Pointer to WPA state machine data from wpa_sm_init()
2021
2041
 * @bssid: The BSSID of the new association
 
2042
 * @network_ctx: Network configuration context for this BSSID
2022
2043
 *
2023
2044
 * This function is called to let WPA state machine know that the connection
2024
2045
 * was established.
2025
2046
 */
2026
 
void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid)
 
2047
void wpa_sm_notify_assoc(struct wpa_sm *sm, const u8 *bssid, void *network_ctx)
2027
2048
{
2028
2049
        int clear_ptk = 1;
2029
2050
 
2038
2059
        if (os_memcmp(sm->preauth_bssid, bssid, ETH_ALEN) == 0)
2039
2060
                rsn_preauth_deinit(sm);
2040
2061
 
 
2062
        if (!pmksa_cache_set_current(sm, NULL, bssid, network_ctx, 0)) {
 
2063
                wpa_printf(MSG_WARNING, "WPA: expected existing PMKSA cache "
 
2064
                           "entry for " MACSTR " but none found",
 
2065
                           MAC2STR(sm->bssid));
 
2066
        }
 
2067
 
2041
2068
#ifdef CONFIG_IEEE80211R
2042
2069
        if (wpa_ft_is_completed(sm)) {
2043
2070
                /*
2076
2103
void wpa_sm_notify_disassoc(struct wpa_sm *sm)
2077
2104
{
2078
2105
        rsn_preauth_deinit(sm);
 
2106
        pmksa_cache_clear_current (sm);
2079
2107
        if (wpa_sm_get_state(sm) == WPA_4WAY_HANDSHAKE)
2080
2108
                sm->dot11RSNA4WayHandshakeFailures++;
2081
2109
}
2191
2219
                sm->ssid_len = 0;
2192
2220
                sm->wpa_ptk_rekey = 0;
2193
2221
        }
2194
 
        if (config == NULL || config->network_ctx != sm->network_ctx)
2195
 
                pmksa_cache_notify_reconfig(sm->pmksa);
2196
2222
}
2197
2223
 
2198
2224
 
2564
2590
                return 0;
2565
2591
        return sm->ptk_set;
2566
2592
}
 
2593
 
 
2594
 
 
2595
void wpa_sm_pmksa_cache_flush(struct wpa_sm *sm, void *network_ctx)
 
2596
{
 
2597
#ifndef CONFIG_NO_WPA2
 
2598
        pmksa_cache_flush(sm->pmksa, network_ctx);
 
2599
#endif /* CONFIG_NO_WPA2 */
 
2600
}