]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
nl80211: Ignore interface up event if interface is down
authorJouni Malinen <j@w1.fi>
Sat, 3 Dec 2011 11:18:57 +0000 (13:18 +0200)
committerJouni Malinen <j@w1.fi>
Sat, 3 Dec 2011 11:18:57 +0000 (13:18 +0200)
The RTM_NEWLINK even can have IFF_UP flag even if the interface is
down. Do not generate EVENT_INTERFACE_ENABLED event based on such a
message.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/drivers/driver_nl80211.c

index 1e738cf26e0865b9fb22eda4a41c8c3f5cfaee5e..a98b28ebdf8ab57ae78aa055c9233a5f98fbd4bb 100644 (file)
@@ -584,6 +584,7 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
        int attrlen, rta_len;
        struct rtattr *attr;
        u32 brid = 0;
+       char namebuf[IFNAMSIZ];
 
        drv = nl80211_find_drv(global, ifi->ifi_index, buf, len);
        if (!drv) {
@@ -601,7 +602,6 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
                   (ifi->ifi_flags & IFF_DORMANT) ? "[DORMANT]" : "");
 
        if (!drv->if_disabled && !(ifi->ifi_flags & IFF_UP)) {
-               char namebuf[IFNAMSIZ];
                if (if_indextoname(ifi->ifi_index, namebuf) &&
                    linux_iface_up(drv->global->ioctl_sock,
                                   drv->first_bss.ifname) > 0) {
@@ -622,9 +622,18 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
        }
 
        if (drv->if_disabled && (ifi->ifi_flags & IFF_UP)) {
-               wpa_printf(MSG_DEBUG, "nl80211: 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->global->ioctl_sock,
+                                  drv->first_bss.ifname) == 0) {
+                       wpa_printf(MSG_DEBUG, "nl80211: Ignore interface up "
+                                  "event since interface %s is down",
+                                  namebuf);
+               } else {
+                       wpa_printf(MSG_DEBUG, "nl80211: Interface up");
+                       drv->if_disabled = 0;
+                       wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,
+                                            NULL);
+               }
        }
 
        /*
@@ -655,7 +664,6 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx,
 
        if (ifi->ifi_family == AF_BRIDGE && brid) {
                /* device has been added to bridge */
-               char namebuf[IFNAMSIZ];
                if_indextoname(brid, namebuf);
                wpa_printf(MSG_DEBUG, "nl80211: Add ifindex %u for bridge %s",
                           brid, namebuf);