diff --git a/src/drivers/driver.h b/src/drivers/driver.h index 338a56eeb..d7aeef99c 100644 --- a/src/drivers/driver.h +++ b/src/drivers/driver.h @@ -4585,6 +4585,15 @@ enum wpa_event_type { * change event. */ EVENT_STATION_OPMODE_CHANGED, + + /** + * EVENT_INTERFACE_MAC_CHANGED - Notify that interface MAC changed + * + * This event is emitted when the MAC changes while the interface is + * enabled. When an interface was disabled and becomes enabled, it + * must be always assumed that the MAC possibly changed. + */ + EVENT_INTERFACE_MAC_CHANGED, }; diff --git a/src/drivers/driver_common.c b/src/drivers/driver_common.c index 9de9693f5..ca4668aa8 100644 --- a/src/drivers/driver_common.c +++ b/src/drivers/driver_common.c @@ -85,6 +85,7 @@ const char * event_to_string(enum wpa_event_type event) E2S(EXTERNAL_AUTH); E2S(PORT_AUTHORIZED); E2S(STATION_OPMODE_CHANGED); + E2S(INTERFACE_MAC_CHANGED); } return "UNKNOWN"; diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c index f7421c4bf..ac06d20fc 100644 --- a/src/drivers/driver_nl80211.c +++ b/src/drivers/driver_nl80211.c @@ -951,7 +951,7 @@ nl80211_find_drv(struct nl80211_global *global, int idx, u8 *buf, size_t len, static void nl80211_refresh_mac(struct wpa_driver_nl80211_data *drv, - int ifindex) + int ifindex, int notify) { struct i802_bss *bss; u8 addr[ETH_ALEN]; @@ -970,6 +970,9 @@ static void nl80211_refresh_mac(struct wpa_driver_nl80211_data *drv, ifindex, bss->ifname, MAC2STR(bss->addr), MAC2STR(addr)); os_memcpy(bss->addr, addr, ETH_ALEN); + if (notify) + wpa_supplicant_event(drv->ctx, + EVENT_INTERFACE_MAC_CHANGED, NULL); } } @@ -1041,11 +1044,11 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx, namebuf[0] = '\0'; if (if_indextoname(ifi->ifi_index, namebuf) && linux_iface_up(drv->global->ioctl_sock, namebuf) > 0) { - /* Re-read MAC address as it may have changed */ - nl80211_refresh_mac(drv, ifi->ifi_index); wpa_printf(MSG_DEBUG, "nl80211: Ignore interface down " "event since interface %s is up", namebuf); drv->ignore_if_down_event = 0; + /* Re-read MAC address as it may have changed */ + nl80211_refresh_mac(drv, ifi->ifi_index, 1); return; } wpa_printf(MSG_DEBUG, "nl80211: Interface down (%s/%s)", @@ -1091,7 +1094,7 @@ static void wpa_driver_nl80211_event_rtm_newlink(void *ctx, "removed", drv->first_bss->ifname); } else { /* Re-read MAC address as it may have changed */ - nl80211_refresh_mac(drv, ifi->ifi_index); + nl80211_refresh_mac(drv, ifi->ifi_index, 0); wpa_printf(MSG_DEBUG, "nl80211: Interface up"); drv->if_disabled = 0; diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index fe64fc285..19c8475b6 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -4374,6 +4374,9 @@ void wpa_supplicant_event(void *ctx, enum wpa_event_type event, data->signal_change.current_noise, data->signal_change.current_txrate); break; + case EVENT_INTERFACE_MAC_CHANGED: + wpa_supplicant_update_mac_addr(wpa_s); + break; case EVENT_INTERFACE_ENABLED: wpa_dbg(wpa_s, MSG_DEBUG, "Interface was enabled"); if (wpa_s->wpa_state == WPA_INTERFACE_DISABLED) {