2023-04-10 WIFI countrycode國(guó)家碼忽略NL80211_REGDOM_SET_BY_COUNTRY_IE

如果為了避免在連接router路由器后,出現(xiàn)TV 或手機(jī)設(shè)備的WIFI countrycode國(guó)家碼隨著Router 中Country IE信息變化,也就是Kernel 的NL80211_REGDOM_SET_BY_COUNTRY_IE信息設(shè)置國(guó)家碼。

為了避免出現(xiàn)以上情況 ,需要設(shè)置REGULATORY_COUNTRY_IE_IGNORE到prWiphy->regulatory_flags,即:

? ? prWiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;


void? cfg80211_regd_set_wiphy(IN struct wiphy *prWiphy)

{

? ? /* * register callback*/

? ? prWiphy->reg_notifier = xxxx_reg_notify;

? ? /*? * clear REGULATORY_CUSTOM_REG flag*/

#if KERNEL_VERSION(3, 14, 0) > CFG80211_VERSION_CODE

? ? /*tells kernel that assign WW as default*/

? ? prWiphy->flags &= ~(WIPHY_FLAG_CUSTOM_REGULATORY);

#else

? ? prWiphy->regulatory_flags &= ~(REGULATORY_CUSTOM_REG);

? ? /*ignore the hint from IE*/

? ? prWiphy->regulatory_flags |= REGULATORY_COUNTRY_IE_IGNORE;

#ifdef CFG_SUPPORT_DISABLE_BCN_HINTS

? ? /*disable beacon hint to avoid channel flag be changed*/

? ? prWiphy->regulatory_flags |= REGULATORY_DISABLE_BEACON_HINTS;

#endif

#endif

? ? /*

? ? * set REGULATORY_CUSTOM_REG flag

? ? */

#if KERNEL_VERSION(3, 14, 0) > CFG80211_VERSION_CODE

? ? /*tells kernel that assign WW as default*/

? ? prWiphy->flags |= (WIPHY_FLAG_CUSTOM_REGULATORY);

#else

? ? prWiphy->regulatory_flags |= (REGULATORY_CUSTOM_REG);

#endif

? ? /* assigned a defautl one */

? ? if (rlmDomainGetLocalDefaultRegd())

? ? ? ? wiphy_apply_custom_regulatory(prWiphy,

? ? ? ? ? ? ? ? ? ? ? ? ? rlmDomainGetLocalDefaultRegd());

}



參考如下:

https://patchwork.kernel.org/project/linux-wireless/patch/1531228573-20734-1-git-send-email-rsirasan@codeaurora.org/

[v1] cfg80211: Avoid regulatory restore when COUNTRY_IE_IGNORE is set


When REGULATORY_COUNTRY_IE_IGNORE is set,? __reg_process_hint_country_ie()

ignores the country code change request from __cfg80211_connect_result()

via regulatory_hint_country_ie().

After Disconnect, similar to above, country code should not be reset to

world when country IE ignore is set. But this is violated and restore of

regulatory settings is invoked by cfg80211_disconnect_work via

regulatory_hint_disconnect().

To address this, avoid regulatory restore from regulatory_hint_disconnect()

when COUNTRY_IE_IGNORE is set.

Note: Currently, restore_regulatory_settings() takes care of clearing

beacon hints. But in the proposed change, regulatory restore is avoided.

Therefore, explicitly clear beacon hints when DISABLE_BEACON_HINTS

is not set.


---

net/wireless/reg.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++

1 file changed, 46 insertions(+)



Patch

diff --git a/net/wireless/reg.c b/net/wireless/reg.c

index bbe6298..9795e64 100644

--- a/net/wireless/reg.c

+++ b/net/wireless/reg.c

@@ -3271,8 +3271,54 @@? static void restore_regulatory_settings(bool reset_user)

? ? schedule_work(&reg_work);

}

+static bool is_wiphy_all_set_reg_flag(enum ieee80211_regulatory_flags flag)

+{

+? ? struct cfg80211_registered_device *rdev;

+? ? struct wireless_dev *wdev;

+

+? ? list_for_each_entry(rdev, &cfg80211_rdev_list, list) {

+? ? ? ? list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {

+? ? ? ? ? ? wdev_lock(wdev);

+? ? ? ? ? ? if (!(wdev->wiphy->regulatory_flags & flag)) {

+? ? ? ? ? ? ? ? wdev_unlock(wdev);

+? ? ? ? ? ? ? ? return false;

+? ? ? ? ? ? }

+? ? ? ? ? ? wdev_unlock(wdev);

+? ? ? ? }

+? ? }

+

+? ? return true;

+}

+

void regulatory_hint_disconnect(void)

{

+? ? /* Restore of regulatory settings is not required when wiphy(s)

+? ? * ignore IE from connected access point but clearance of beacon hints

+? ? * is required when wiphy(s) supports beacon hints.

+? ? */

+? ? if (is_wiphy_all_set_reg_flag(REGULATORY_COUNTRY_IE_IGNORE)) {

+? ? ? ? struct reg_beacon *reg_beacon, *btmp;

+

+? ? ? ? if (is_wiphy_all_set_reg_flag(REGULATORY_DISABLE_BEACON_HINTS))

+? ? ? ? ? ? return;

+

+? ? ? ? spin_lock_bh(&reg_pending_beacons_lock);

+? ? ? ? list_for_each_entry_safe(reg_beacon, btmp,

+? ? ? ? ? ? ? ? ? ? &reg_pending_beacons, list) {

+? ? ? ? ? ? list_del(&reg_beacon->list);

+? ? ? ? ? ? kfree(reg_beacon);

+? ? ? ? }

+? ? ? ? spin_unlock_bh(&reg_pending_beacons_lock);

+

+? ? ? ? list_for_each_entry_safe(reg_beacon, btmp,

+? ? ? ? ? ? ? ? ? ? &reg_beacon_list, list) {

+? ? ? ? ? ? list_del(&reg_beacon->list);

+? ? ? ? ? ? kfree(reg_beacon);

+? ? ? ? }

+

+? ? ? ? return;

+? ? }

+

? ? pr_debug("All devices are disconnected, going to restore regulatory settings\n");

? ? restore_regulatory_settings(false);

}

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容