[PATCH] wireless/atmel: fix Open System authentication process bugs

This patch fixes a number of bugs in the authentication process:

1) When falling back to Shared Key authentication mode from Open System,
a missing 'return' would cause the auth request to be sent, but would
drop the card into Management Error state. When falling back, the
driver should also indicate that it is switching to Shared Key mode by
setting exclude_unencrypted.

2) Initial authentication modes were apparently wrong in some cases,
causing the driver to attempt Shared Key authentication mode when in
fact the access point didn't support that mode or even had WEP disabled.
The driver should set the correct initial authentication mode based on
wep_is_on and exclude_unencrypted.

3) Authentication response packets from the access point in Open System
mode were getting ignored because the driver was expecting the sequence
number of a Shared Key mode response. The patch separates the OS and SK
mode handling to provide the correct behavior.

Signed-off-by: Dan Williams <dcbw@redhat.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by Dan Williams and committed by John W. Linville 73451379 0d467502

+27 -10
+27 -10
drivers/net/wireless/atmel.c
··· 3064 3064 } 3065 3065 3066 3066 if (status == C80211_MGMT_SC_Success && priv->wep_is_on) { 3067 + int should_associate = 0; 3067 3068 /* WEP */ 3068 3069 if (trans_seq_no != priv->ExpectedAuthentTransactionSeqNum) 3069 3070 return; 3070 3071 3071 - if (trans_seq_no == 0x0002 && 3072 - auth->el_id == C80211_MGMT_ElementID_ChallengeText) { 3073 - send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len); 3074 - return; 3072 + if (system == C80211_MGMT_AAN_OPENSYSTEM) { 3073 + if (trans_seq_no == 0x0002) { 3074 + should_associate = 1; 3075 + } 3076 + } else if (system == C80211_MGMT_AAN_SHAREDKEY) { 3077 + if (trans_seq_no == 0x0002 && 3078 + auth->el_id == C80211_MGMT_ElementID_ChallengeText) { 3079 + send_authentication_request(priv, system, auth->chall_text, auth->chall_text_len); 3080 + return; 3081 + } else if (trans_seq_no == 0x0004) { 3082 + should_associate = 1; 3083 + } 3075 3084 } 3076 3085 3077 - if (trans_seq_no == 0x0004) { 3086 + if (should_associate) { 3078 3087 if(priv->station_was_associated) { 3079 3088 atmel_enter_state(priv, STATION_STATE_REASSOCIATING); 3080 3089 send_association_request(priv, 1); ··· 3096 3087 } 3097 3088 } 3098 3089 3099 - if (status == C80211_MGMT_SC_AuthAlgNotSupported) { 3090 + if (status == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG) { 3100 3091 /* Do opensystem first, then try sharedkey */ 3101 - if (system == C80211_MGMT_AAN_OPENSYSTEM) { 3092 + if (system == WLAN_AUTH_OPEN) { 3102 3093 priv->CurrentAuthentTransactionSeqNum = 0x001; 3103 - send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0); 3094 + priv->exclude_unencrypted = 1; 3095 + send_authentication_request(priv, WLAN_AUTH_SHARED_KEY, NULL, 0); 3096 + return; 3104 3097 } else if (priv->connect_to_any_BSS) { 3105 3098 int bss_index; 3106 3099 ··· 3453 3442 priv->AuthenticationRequestRetryCnt = 0; 3454 3443 restart_search(priv); 3455 3444 } else { 3445 + int auth = C80211_MGMT_AAN_OPENSYSTEM; 3456 3446 priv->AuthenticationRequestRetryCnt++; 3457 3447 priv->CurrentAuthentTransactionSeqNum = 0x0001; 3458 3448 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); 3459 - send_authentication_request(priv, C80211_MGMT_AAN_OPENSYSTEM, NULL, 0); 3449 + if (priv->wep_is_on && priv->exclude_unencrypted) 3450 + auth = C80211_MGMT_AAN_SHAREDKEY; 3451 + send_authentication_request(priv, auth, NULL, 0); 3460 3452 } 3461 3453 break; 3462 3454 ··· 3558 3544 priv->station_was_associated = priv->station_is_associated; 3559 3545 atmel_enter_state(priv, STATION_STATE_READY); 3560 3546 } else { 3547 + int auth = C80211_MGMT_AAN_OPENSYSTEM; 3561 3548 priv->AuthenticationRequestRetryCnt = 0; 3562 3549 atmel_enter_state(priv, STATION_STATE_AUTHENTICATING); 3563 3550 3564 3551 mod_timer(&priv->management_timer, jiffies + MGMT_JIFFIES); 3565 3552 priv->CurrentAuthentTransactionSeqNum = 0x0001; 3566 - send_authentication_request(priv, C80211_MGMT_AAN_SHAREDKEY, NULL, 0); 3553 + if (priv->wep_is_on && priv->exclude_unencrypted) 3554 + auth = C80211_MGMT_AAN_SHAREDKEY; 3555 + send_authentication_request(priv, auth, NULL, 0); 3567 3556 } 3568 3557 return; 3569 3558 }