在Andrid P版本上调试WiFi功能时,再断开WiFi后,发现后续很难再次连接上,遂跟踪了整个driver以及supplicant日志,其中supplicant中有如下日志:
01-01 00:01:11.325 4235 4235 D wpa_supplicant: nl80211: Scan results indicate BSS status with 98:de:d0:44:07:f3 as associated
01-01 00:01:17.996 4235 4235 D wpa_supplicant: nl80211: Connect (ifindex=8)
01-01 00:01:17.996 4235 4235 D wpa_supplicant: * bssid=98:de:d0:44:07:f3
01-01 00:01:17.996 4235 4235 D wpa_supplicant: * bssid_hint=98:de:d0:44:07:f3
01-01 00:01:17.996 4235 4235 D wpa_supplicant: * freq=2412
01-01 00:01:17.997 4235 4235 D wpa_supplicant: * freq_hint=2412
01-01 00:01:17.997 4235 4235 D wpa_supplicant: * SSID - hexdump(len=10): 77 69 66 69 36 30 5f 32 34 47
01-01 00:01:17.997 4235 4235 D wpa_supplicant: * IEs - hexdump(len=23): 3b 15 51 51 52 53 54 73 74 75 76 77 78 79 7a 7b 7c 7d 7e 7f 80 81 82
01-01 00:01:17.997 4235 4235 D wpa_supplicant: * Auth Type 0
01-01 00:01:17.997 4235 4235 D wpa_supplicant: nl80211: MLME connect failed: ret=-114 (Operation already in progress)
跟踪从supplicant->kernel连接流程:
wpa_driver_nl80211_associate
wpa_driver_nl80211_connect
wpa_driver_nl80211_try_connect
NL80211_CMD_CONNECT 进入Kernel
nl80211_connect
cfg80211_connect
在cfg80211_connect函数中有如下部分代码:
if (wdev->current_bss) {
if (!prev_bssid)
return -EALREADY;
if (!ether_addr_equal(prev_bssid, wdev->current_bss->pub.bssid))
return -ENOTCONN;
}
调试打印后可知当内核中变量wdev->current_bss有值时,将不会再执行连接命令,而是报错返回。
而wdev->current_bss变量则应在
cfg80211_disconnected
__cfg80211_disconnected
函数中清空。跟踪driver内核代码,查找出在发生断连时,driver并没有正常调用到cfg80211_disconnected函数,进而导致了该错误。只要在driver代码中断连时,正常调用到cfg80211_disconnected函数,即可消除该错误。