• Lior Cohen's avatar
    mac80211: clear crypto tx tailroom counter upon keys enable · 624ff4b2
    Lior Cohen authored
    In case we got a fw restart while roaming from encrypted AP to
    non-encrypted one, we might end up with hitting a warning on the pending
    counter crypto_tx_tailroom_pending_dec having a non-zero value.
    
    The following comment taken from net/mac80211/key.c explains the rational
    for the delayed tailroom needed:
    
    	/*
    	* The reason for the delayed tailroom needed decrementing is to
    	* make roaming faster: during roaming, all keys are first deleted
    	* and then new keys are installed. The first new key causes the
    	* crypto_tx_tailroom_needed_cnt to go from 0 to 1, which invokes
    	* the cost of synchronize_net() (which can be slow). Avoid this
    	* by deferring the crypto_tx_tailroom_needed_cnt decrementing on
    	* key removal for a while, so if we roam the value is larger than
    	* zero and no 0->1 transition happens.
    	*
    	* The cost is that if the AP switching was from an AP with keys
    	* to one without, we still allocate tailroom while it would no
    	* longer be needed. However, in the typical (fast) roaming case
    	* within an ESS this usually won't happen.
    	*/
    
    The next flow lead to the warning eventually reported as a bug:
    1. Disconnect from encrypted AP
    2. Set crypto_tx_tailroom_pending_dec = 1 for the key
    3. Schedule work
    4. Reconnect to non-encrypted AP
    5. Add a new key, setting the tailroom counter = 1
    6. Got FW restart while pending counter is set ---> hit the warning
    
    While on it, the ieee80211_reset_crypto_tx_tailroom() func was merged into
    its single caller ieee80211_reenable_keys (previously called
    ieee80211_enable_keys). Also, we reset the crypto_tx_tailroom_pending_dec
    and remove the counters warning as we just reset both.
    Signed-off-by: default avatarLior Cohen <lior2.cohen@intel.com>
    Signed-off-by: default avatarLuca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/20190830112451.21655-7-luca@coelho.fiSigned-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
    624ff4b2
util.c 103 KB