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