mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-17 18:34:03 -05:00
nl80211: Try mode changes multiple times to avoid some races
cfg80211/mac80211 seems to be unwilling to change interface mode in some cases. Make these less likely to cause problems by trying the changes up to 10 times with 100 msec intervals.
This commit is contained in:
parent
f3f0f648d7
commit
26af9dcaef
@ -4069,6 +4069,7 @@ static int wpa_driver_nl80211_set_mode(void *priv, int mode)
|
|||||||
struct wpa_driver_nl80211_data *drv = bss->drv;
|
struct wpa_driver_nl80211_data *drv = bss->drv;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
int nlmode;
|
int nlmode;
|
||||||
|
int i;
|
||||||
|
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 0:
|
case 0:
|
||||||
@ -4101,11 +4102,23 @@ static int wpa_driver_nl80211_set_mode(void *priv, int mode)
|
|||||||
* take the device down, try to set the mode again, and bring the
|
* take the device down, try to set the mode again, and bring the
|
||||||
* device back up.
|
* device back up.
|
||||||
*/
|
*/
|
||||||
if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0) == 0) {
|
wpa_printf(MSG_DEBUG, "nl80211: Try mode change after setting "
|
||||||
/* Try to set the mode again while the interface is down */
|
"interface down");
|
||||||
ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
|
for (i = 0; i < 10; i++) {
|
||||||
if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1))
|
if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0) ==
|
||||||
ret = -1;
|
0) {
|
||||||
|
/* Try to set the mode again while the interface is
|
||||||
|
* down */
|
||||||
|
ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
|
||||||
|
if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname,
|
||||||
|
1))
|
||||||
|
ret = -1;
|
||||||
|
if (!ret)
|
||||||
|
break;
|
||||||
|
} else
|
||||||
|
wpa_printf(MSG_DEBUG, "nl80211: Failed to set "
|
||||||
|
"interface down");
|
||||||
|
os_sleep(0, 100000);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ret) {
|
if (!ret) {
|
||||||
|
Loading…
Reference in New Issue
Block a user