From 106fa1e97e29e7514ae324020802c280f993ee48 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Wed, 11 Feb 2015 10:26:26 +0200 Subject: [PATCH] nl80211: Indicate interface-down event only for the main netdev RTM_NEWLINK event without IFF_UP were processed for all related interfaces (including VLANs and bridge). While these events may need to be processed for other purposes, they should not end up claiming that the main interface has been disabled, so indicate EVENT_INTERFACE_DISABLED only if the ifname matches the first BSS ifname for the interface. In addition, fix some of the ifup/down checks from if_indextoname() cases to actually use the resolved ifname (namebuf) rather than hardcoding the first configured ifname to be used. Signed-off-by: Jouni Malinen --- src/drivers/driver_nl80211.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index b97079772..829904812 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -952,16 +952,21 @@ 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)) { + namebuf[0] = '\0'; if (if_indextoname(ifi->ifi_index, namebuf) && - linux_iface_up(drv->global->ioctl_sock, - drv->first_bss->ifname) > 0) { + linux_iface_up(drv->global->ioctl_sock, namebuf) > 0) { wpa_printf(MSG_DEBUG, "nl80211: Ignore interface down " "event since interface %s is up", namebuf); drv->ignore_if_down_event = 0; return; } - wpa_printf(MSG_DEBUG, "nl80211: Interface down"); - if (drv->ignore_if_down_event) { + wpa_printf(MSG_DEBUG, "nl80211: Interface down (%s/%s)", + namebuf, ifname); + if (os_strcmp(drv->first_bss->ifname, ifname) != 0) { + wpa_printf(MSG_DEBUG, + "nl80211: Not the main interface (%s) - do not indicate interface down", + drv->first_bss->ifname); + } else if (drv->ignore_if_down_event) { wpa_printf(MSG_DEBUG, "nl80211: Ignore interface down " "event generated by mode change"); drv->ignore_if_down_event = 0; @@ -984,8 +989,7 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx, if (drv->if_disabled && (ifi->ifi_flags & IFF_UP)) { if (if_indextoname(ifi->ifi_index, namebuf) && - linux_iface_up(drv->global->ioctl_sock, - drv->first_bss->ifname) == 0) { + linux_iface_up(drv->global->ioctl_sock, namebuf) == 0) { wpa_printf(MSG_DEBUG, "nl80211: Ignore interface up " "event since interface %s is down", namebuf);