• Luis R. Rodriguez's avatar
    cfg80211: Fix regulatory bug with multiple cards and delays · b2e253cf
    Luis R. Rodriguez authored
    When two cards are connected with the same regulatory domain
    if CRDA had a delayed response then cfg80211's own set regulatory
    domain would still be the world regulatory domain. There was a bug
    on cfg80211's logic such that it assumed that once you pegged a
    request as the last request it was already the currently set
    regulatory domain. This would mean we would race setting a stale
    regulatory domain to secondary cards which had the same regulatory
    domain since the alpha2 would match.
    
    We fix this by processing each regulatory request atomically,
    and only move on to the next one once we get it fully processed.
    In the case CRDA is not present we will simply world roam.
    
    This issue is only present when you have a slow system and the
    CRDA processing is delayed. Because of this it is not a known
    regression.
    
    Without this fix when a delay is present with CRDA the second card
    would end up with an intersected regulatory domain and not allow it
    to use the channels it really is designed for. When two cards with
    two different regulatory domains were inserted you'd end up
    rejecting the second card's regulatory domain request.
    This fails with mac80211_hswim's regtest=2 (two requests, same alpha2)
    and regtest=3 (two requests, different alpha2) module parameter
    options.
    
    This was reproduced and tested against mac80211_hwsim using this
    CRDA delayer:
    
           #!/bin/bash
           echo $COUNTRY >> /tmp/log
           sleep 2
           /sbin/crda.orig
    
    And these regulatory tests:
    
           modprobe mac80211_hwsim regtest=2
           modprobe mac80211_hwsim regtest=3
    Reported-by: default avatarMark Mentovai <mark@moxienet.com>
    Signed-off-by: default avatarLuis R. Rodriguez <lrodriguez@atheros.com>
    Tested-by: default avatarMark Mentovai <mark@moxienet.com>
    Tested-by: default avatarBruno Randolf <br1@einfach.org>
    Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
    b2e253cf
regulatory.h 3.46 KB