wext: Filter unexpected interface added/up events

It looks like a RTM_NEWLINK event claiming the interface to be UP is
delivered just before removing an interface after having first indicated
that the interface was going down/removed. Ignore this event if the
interface is not present anymore at the moment the event is processed.
This fixes issues where an interface that was re-added after being
removed did not get reconfigured properly.

Signed-hostap: Jouni Malinen <j@w1.fi>
intended-for: hostap-1
This commit is contained in:
Jouni Malinen 2012-02-18 13:28:21 +02:00
parent cb6710a4a5
commit 6d441b0da2
1 changed files with 40 additions and 5 deletions

View File

@ -569,10 +569,28 @@ static void wpa_driver_wext_event_link(struct wpa_driver_wext_data *drv,
del ? "removed" : "added");
if (os_strcmp(drv->ifname, event.interface_status.ifname) == 0) {
if (del)
if (del) {
if (drv->if_removed) {
wpa_printf(MSG_DEBUG, "WEXT: if_removed "
"already set - ignore event");
return;
}
drv->if_removed = 1;
else
} else {
if (if_nametoindex(drv->ifname) == 0) {
wpa_printf(MSG_DEBUG, "WEXT: Interface %s "
"does not exist - ignore "
"RTM_NEWLINK",
drv->ifname);
return;
}
if (!drv->if_removed) {
wpa_printf(MSG_DEBUG, "WEXT: if_removed "
"already cleared - ignore event");
return;
}
drv->if_removed = 0;
}
}
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_STATUS, &event);
@ -628,6 +646,7 @@ static void wpa_driver_wext_event_rtm_newlink(void *ctx, struct ifinfomsg *ifi,
struct wpa_driver_wext_data *drv = ctx;
int attrlen, rta_len;
struct rtattr *attr;
char namebuf[IFNAMSIZ];
if (!wpa_driver_wext_own_ifindex(drv, ifi->ifi_index, buf, len)) {
wpa_printf(MSG_DEBUG, "Ignore event for foreign ifindex %d",
@ -650,9 +669,25 @@ static void wpa_driver_wext_event_rtm_newlink(void *ctx, struct ifinfomsg *ifi,
}
if (drv->if_disabled && (ifi->ifi_flags & IFF_UP)) {
wpa_printf(MSG_DEBUG, "WEXT: Interface up");
drv->if_disabled = 0;
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED, NULL);
if (if_indextoname(ifi->ifi_index, namebuf) &&
linux_iface_up(drv->ioctl_sock, drv->ifname) == 0) {
wpa_printf(MSG_DEBUG, "WEXT: Ignore interface up "
"event since interface %s is down",
namebuf);
} else if (if_nametoindex(drv->ifname) == 0) {
wpa_printf(MSG_DEBUG, "WEXT: Ignore interface up "
"event since interface %s does not exist",
drv->ifname);
} else if (drv->if_removed) {
wpa_printf(MSG_DEBUG, "WEXT: Ignore interface up "
"event since interface %s is marked "
"removed", drv->ifname);
} else {
wpa_printf(MSG_DEBUG, "WEXT: Interface up");
drv->if_disabled = 0;
wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
NULL);
}
}
/*