mirror of
https://github.com/vanhoefm/fragattacks.git
synced 2024-11-25 00:38:24 -05:00
hostapd: nl80211 retry creating a interface if it fails the first time
If hostapd segfaults, or is killed with -9, or the interface already exists, when the interface is created, it will fail. Configuration file: /tmp/hostapd/hostapd.conf Failed to create interface mon.wlan0_0. Using interface wlan0_0 with hwaddr 00:13:01:01:08:0a and ssid 'IG_0405_LAN' Failed to set beacon head/tail or DTIM period Failed to create interface wlan0_1. Try to remove the interface and re-create it before aborting.
This commit is contained in:
parent
8077a80042
commit
a35187e71a
@ -2468,9 +2468,10 @@ static void nl80211_remove_iface(struct wpa_driver_nl80211_data *drv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
|
static int nl80211_create_iface_once(struct wpa_driver_nl80211_data *drv,
|
||||||
const char *ifname, enum nl80211_iftype iftype,
|
const char *ifname,
|
||||||
const u8 *addr)
|
enum nl80211_iftype iftype,
|
||||||
|
const u8 *addr)
|
||||||
{
|
{
|
||||||
struct nl_msg *msg, *flags = NULL;
|
struct nl_msg *msg, *flags = NULL;
|
||||||
int ifidx;
|
int ifidx;
|
||||||
@ -2506,8 +2507,8 @@ static int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
|
|||||||
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
|
ret = send_and_recv_msgs(drv, msg, NULL, NULL);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
nla_put_failure:
|
nla_put_failure:
|
||||||
wpa_printf(MSG_ERROR, "Failed to create interface %s.",
|
wpa_printf(MSG_ERROR, "Failed to create interface %s: %d (%s)",
|
||||||
ifname);
|
ifname, ret, strerror(-ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2529,6 +2530,27 @@ static int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
|
|||||||
|
|
||||||
return ifidx;
|
return ifidx;
|
||||||
}
|
}
|
||||||
|
static int nl80211_create_iface(struct wpa_driver_nl80211_data *drv,
|
||||||
|
const char *ifname, enum nl80211_iftype iftype,
|
||||||
|
const u8 *addr)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = nl80211_create_iface_once(drv, ifname, iftype, addr);
|
||||||
|
|
||||||
|
/* if error occured and interface exists already */
|
||||||
|
if (ret == -ENFILE && if_nametoindex(ifname)) {
|
||||||
|
wpa_printf(MSG_INFO, "Try to remove and re-create %s", ifname);
|
||||||
|
|
||||||
|
/* Try to remove the interface that was already there. */
|
||||||
|
nl80211_remove_iface(drv, if_nametoindex(ifname));
|
||||||
|
|
||||||
|
/* Try to create the interface again */
|
||||||
|
ret = nl80211_create_iface_once(drv, ifname, iftype, addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_AP || HOSTAPD */
|
#endif /* CONFIG_AP || HOSTAPD */
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user