mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2025-01-30 16:54:04 -05:00
nl80211: Stop more quickly on initialization errors
Stop on fatal errors like an attempt to use a non-existing interface or not have root privileges to avoid producing confusing error messages.
This commit is contained in:
parent
8c0d3b4fc6
commit
6e8183d714
@ -2340,8 +2340,9 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
|
|||||||
if ((drv->global == NULL ||
|
if ((drv->global == NULL ||
|
||||||
drv->ifindex != drv->global->if_add_ifindex) &&
|
drv->ifindex != drv->global->if_add_ifindex) &&
|
||||||
wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION) < 0) {
|
wpa_driver_nl80211_set_mode(bss, NL80211_IFTYPE_STATION) < 0) {
|
||||||
wpa_printf(MSG_DEBUG, "nl80211: Could not configure driver to "
|
wpa_printf(MSG_ERROR, "nl80211: Could not configure driver to "
|
||||||
"use managed mode");
|
"use managed mode");
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
|
if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 1)) {
|
||||||
@ -5711,15 +5712,21 @@ static int wpa_driver_nl80211_set_mode(struct i802_bss *bss,
|
|||||||
wpa_printf(MSG_DEBUG, "nl80211: Try mode change after setting "
|
wpa_printf(MSG_DEBUG, "nl80211: Try mode change after setting "
|
||||||
"interface down");
|
"interface down");
|
||||||
for (i = 0; i < 10; i++) {
|
for (i = 0; i < 10; i++) {
|
||||||
if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0) ==
|
int res;
|
||||||
0) {
|
res = linux_set_iface_flags(drv->ioctl_sock, bss->ifname, 0);
|
||||||
|
if (res == -EACCES || res == -ENODEV)
|
||||||
|
break;
|
||||||
|
if (res == 0) {
|
||||||
/* Try to set the mode again while the interface is
|
/* Try to set the mode again while the interface is
|
||||||
* down */
|
* down */
|
||||||
ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
|
ret = nl80211_set_mode(drv, drv->ifindex, nlmode);
|
||||||
if (linux_set_iface_flags(drv->ioctl_sock, bss->ifname,
|
if (ret == -EACCES)
|
||||||
1))
|
break;
|
||||||
|
res = linux_set_iface_flags(drv->ioctl_sock,
|
||||||
|
bss->ifname, 1);
|
||||||
|
if (res && !ret)
|
||||||
ret = -1;
|
ret = -1;
|
||||||
if (!ret)
|
else if (ret != -EBUSY)
|
||||||
break;
|
break;
|
||||||
} else
|
} else
|
||||||
wpa_printf(MSG_DEBUG, "nl80211: Failed to set "
|
wpa_printf(MSG_DEBUG, "nl80211: Failed to set "
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
int linux_set_iface_flags(int sock, const char *ifname, int dev_up)
|
int linux_set_iface_flags(int sock, const char *ifname, int dev_up)
|
||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (sock < 0)
|
if (sock < 0)
|
||||||
return -1;
|
return -1;
|
||||||
@ -32,9 +33,10 @@ int linux_set_iface_flags(int sock, const char *ifname, int dev_up)
|
|||||||
os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
os_strlcpy(ifr.ifr_name, ifname, IFNAMSIZ);
|
||||||
|
|
||||||
if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) {
|
if (ioctl(sock, SIOCGIFFLAGS, &ifr) != 0) {
|
||||||
|
ret = errno ? -errno : -999;
|
||||||
wpa_printf(MSG_ERROR, "Could not read interface %s flags: %s",
|
wpa_printf(MSG_ERROR, "Could not read interface %s flags: %s",
|
||||||
ifname, strerror(errno));
|
ifname, strerror(errno));
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_up) {
|
if (dev_up) {
|
||||||
@ -48,9 +50,10 @@ int linux_set_iface_flags(int sock, const char *ifname, int dev_up)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (ioctl(sock, SIOCSIFFLAGS, &ifr) != 0) {
|
if (ioctl(sock, SIOCSIFFLAGS, &ifr) != 0) {
|
||||||
|
ret = errno ? -errno : -999;
|
||||||
wpa_printf(MSG_ERROR, "Could not set interface %s flags: %s",
|
wpa_printf(MSG_ERROR, "Could not set interface %s flags: %s",
|
||||||
ifname, strerror(errno));
|
ifname, strerror(errno));
|
||||||
return -1;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user