From 3e0272ca00ce1df35b45e7d739dd7e935f13fd84 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Thu, 2 Oct 2014 10:30:05 -0500 Subject: [PATCH] nl80211: Re-read MAC address on RTM_NEWLINK Commit 97279d8d (after hostap-2.0) dropped frame events from foreign addresses. Unfortunately this commit did not handle the case where the interface's MAC address might be changed externally, which other wpa_supplicant code already handled. This causes the driver to reject any MLME event because the address from the event doesn't match the stale address in the driver data. Changing an interface's MAC address requires that the interface be down, the change made, and then the interface brought back up. This triggers an RTM_NEWLINK event which driver_nl80211.c can use to re-read the MAC address of the interface. Signed-hostap: Dan Williams --- src/drivers/driver_nl80211.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index d962637b8..88ec88bf1 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -1320,6 +1320,28 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx, "event since interface %s is marked " "removed", drv->first_bss->ifname); } else { + struct i802_bss *bss; + u8 addr[ETH_ALEN]; + + /* Re-read MAC address as it may have changed */ + bss = get_bss_ifindex(drv, ifi->ifi_index); + if (bss && + linux_get_ifhwaddr(drv->global->ioctl_sock, + bss->ifname, addr) < 0) { + wpa_printf(MSG_DEBUG, + "nl80211: %s: failed to re-read MAC address", + bss->ifname); + } else if (bss && + os_memcmp(addr, bss->addr, ETH_ALEN) != 0) { + wpa_printf(MSG_DEBUG, + "nl80211: Own MAC address on ifindex %d (%s) changed from " + MACSTR " to " MACSTR, + ifi->ifi_index, bss->ifname, + MAC2STR(bss->addr), + MAC2STR(addr)); + os_memcpy(bss->addr, addr, ETH_ALEN); + } + wpa_printf(MSG_DEBUG, "nl80211: Interface up"); drv->if_disabled = 0; wpa_supplicant_event(drv->ctx, EVENT_INTERFACE_ENABLED,