nl80211: Re-read MAC address on RTM_NEWLINK
authorDan Williams <dcbw@redhat.com>
Thu, 2 Oct 2014 15:30:05 +0000 (10:30 -0500)
committerJouni Malinen <j@w1.fi>
Sat, 4 Oct 2014 13:41:20 +0000 (16:41 +0300)
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 <dcbw@redhat.com>

src/drivers/driver_nl80211.c

index d962637..88ec88b 100644 (file)
@@ -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,