[PATCH] nl80211: report new station / assoc event for the correct BSS

Rafał Miłecki zajec5
Sat Dec 6 07:06:35 PST 2014


drv->ctx always points to the first BSS and we should report event using
BSS related to the interface we got NL80211_CMD_NEW_STATION from.
This fixes STA association for drivers using NL80211_CMD_NEW_STATION and
multiple virtual interfaces.

Before:
nl80211: Drv Event 19 (NL80211_CMD_NEW_STATION) received for wlan0-1 (ifindex:7)
nl80211: New station 02:00:00:00:01:00
wlan0: STA 02:00:00:00:01:00 IEEE 802.11: associated

After:
nl80211: Drv Event 19 (NL80211_CMD_NEW_STATION) received for wlan0-1 (ifindex:7)
nl80211: New station 02:00:00:00:01:00
wlan0-1: STA 02:00:00:00:01:00 IEEE 802.11: associated

Signed-off-by: Rafa? Mi?ecki <zajec5 at gmail.com>
---
Hi guys :)

I recently heard about possible problems with handling BSS-es from Arend and was
working with nl80211 / hostapd anyway, so decided to take a look at this.

I think I found some bug in handling events that can be exposed when using
multiple virtual interfaces, hardware authentication and cfg80211_new_sta (which
gets translated into NL80211_CMD_NEW_STATION).

As you can see in the log called "Before", hostapd was getting event from
wlan0-1 but then association was happening on the wlan0. This was breaking AP
mode on virtual interfaces (BSS other than the first one).

Please note, that this bug (I believe it's a bug) won't be exposed when running
mac80211_hwsim. In such case authentication is handled in hostapd and assoc
happens in handle_assoc_cb (not hostapd_notif_assoc) which handles BSS-es
correctly.

If you review this patch and it appears to be OK, I guess we will need similar
modification for other events.

P.S.
Jouni / Arent: re-sending this patch after subscribing to the ML.
---
 src/drivers/driver_nl80211_event.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/drivers/driver_nl80211_event.c b/src/drivers/driver_nl80211_event.c
index ab5208e..e2f2f3a 100644
--- a/src/drivers/driver_nl80211_event.c
+++ b/src/drivers/driver_nl80211_event.c
@@ -1122,6 +1122,7 @@ static void nl80211_new_peer_candidate(struct wpa_driver_nl80211_data *drv,
 
 
 static void nl80211_new_station_event(struct wpa_driver_nl80211_data *drv,
+				      struct i802_bss *bss,
 				      struct nlattr **tb)
 {
 	u8 *addr;
@@ -1140,7 +1141,7 @@ static void nl80211_new_station_event(struct wpa_driver_nl80211_data *drv,
 			ies_len = nla_len(tb[NL80211_ATTR_IE]);
 		}
 		wpa_hexdump(MSG_DEBUG, "nl80211: Assoc Req IEs", ies, ies_len);
-		drv_event_assoc(drv->ctx, addr, ies, ies_len, 0);
+		drv_event_assoc(bss->ctx, addr, ies, ies_len, 0);
 		return;
 	}
 
@@ -1149,7 +1150,7 @@ static void nl80211_new_station_event(struct wpa_driver_nl80211_data *drv,
 
 	os_memset(&data, 0, sizeof(data));
 	os_memcpy(data.ibss_rsn_start.peer, addr, ETH_ALEN);
-	wpa_supplicant_event(drv->ctx, EVENT_IBSS_RSN_START, &data);
+	wpa_supplicant_event(bss->ctx, EVENT_IBSS_RSN_START, &data);
 }
 
 
@@ -1822,7 +1823,7 @@ static void do_process_drv_event(struct i802_bss *bss, int cmd,
 				     &data);
 		break;
 	case NL80211_CMD_NEW_STATION:
-		nl80211_new_station_event(drv, tb);
+		nl80211_new_station_event(drv, bss, tb);
 		break;
 	case NL80211_CMD_DEL_STATION:
 		nl80211_del_station_event(drv, tb);
-- 
1.8.4.5




More information about the Hostap mailing list