hostapd: allow stations to move between different bss interfaces

With this patch, a client gets kicked out of the last BSS it was
attached to, when it is associating to a different one.
While mac80211 does allow a station to be present on multiple bss
interfaces, this does seem to cause problems both for the stack
and for hostapd.
This commit is contained in:
Felix Fietkau 2010-03-06 22:30:25 +02:00 committed by Jouni Malinen
parent a2e40bb650
commit 53f3d6f3e6

View file

@ -32,8 +32,8 @@
#include "vlan_init.h" #include "vlan_init.h"
#include "sta_info.h" #include "sta_info.h"
static int ap_sta_in_other_bss(struct hostapd_data *hapd, static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
struct sta_info *sta, u32 flags); struct sta_info *sta);
static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx); static void ap_handle_session_timer(void *eloop_ctx, void *timeout_ctx);
#ifdef CONFIG_IEEE80211W #ifdef CONFIG_IEEE80211W
static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx); static void ap_sa_query_timer(void *eloop_ctx, void *timeout_ctx);
@ -123,8 +123,8 @@ void ap_free_sta(struct hostapd_data *hapd, struct sta_info *sta)
if (sta->flags & WLAN_STA_WDS) if (sta->flags & WLAN_STA_WDS)
hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0); hapd->drv.set_wds_sta(hapd, sta->addr, sta->aid, 0);
if (!ap_sta_in_other_bss(hapd, sta, WLAN_STA_ASSOC) &&
!(sta->flags & WLAN_STA_PREAUTH)) if (!(sta->flags & WLAN_STA_PREAUTH))
hapd->drv.sta_remove(hapd, sta->addr); hapd->drv.sta_remove(hapd, sta->addr);
ap_sta_hash_del(hapd, sta); ap_sta_hash_del(hapd, sta);
@ -451,6 +451,7 @@ struct sta_info * ap_sta_add(struct hostapd_data *hapd, const u8 *addr)
hapd->num_sta++; hapd->num_sta++;
ap_sta_hash_add(hapd, sta); ap_sta_hash_add(hapd, sta);
sta->ssid = &hapd->conf->ssid; sta->ssid = &hapd->conf->ssid;
ap_sta_remove_in_other_bss(hapd, sta);
return sta; return sta;
} }
@ -472,8 +473,8 @@ static int ap_sta_remove(struct hostapd_data *hapd, struct sta_info *sta)
} }
static int ap_sta_in_other_bss(struct hostapd_data *hapd, static void ap_sta_remove_in_other_bss(struct hostapd_data *hapd,
struct sta_info *sta, u32 flags) struct sta_info *sta)
{ {
struct hostapd_iface *iface = hapd->iface; struct hostapd_iface *iface = hapd->iface;
size_t i; size_t i;
@ -488,11 +489,12 @@ static int ap_sta_in_other_bss(struct hostapd_data *hapd,
if (bss == hapd || bss == NULL) if (bss == hapd || bss == NULL)
continue; continue;
sta2 = ap_get_sta(bss, sta->addr); sta2 = ap_get_sta(bss, sta->addr);
if (sta2 && ((sta2->flags & flags) == flags)) if (!sta2)
return 1; continue;
}
return 0; ap_sta_disconnect(bss, sta2, sta2->addr,
WLAN_REASON_PREV_AUTH_NOT_VALID);
}
} }
@ -502,8 +504,7 @@ void ap_sta_disassociate(struct hostapd_data *hapd, struct sta_info *sta,
wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR, wpa_printf(MSG_DEBUG, "%s: disassociate STA " MACSTR,
hapd->conf->iface, MAC2STR(sta->addr)); hapd->conf->iface, MAC2STR(sta->addr));
sta->flags &= ~WLAN_STA_ASSOC; sta->flags &= ~WLAN_STA_ASSOC;
if (!ap_sta_in_other_bss(hapd, sta, WLAN_STA_ASSOC)) ap_sta_remove(hapd, sta);
ap_sta_remove(hapd, sta);
sta->timeout_next = STA_DEAUTH; sta->timeout_next = STA_DEAUTH;
eloop_cancel_timeout(ap_handle_timer, hapd, sta); eloop_cancel_timeout(ap_handle_timer, hapd, sta);
eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DISASSOC, 0, eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DISASSOC, 0,
@ -521,8 +522,7 @@ void ap_sta_deauthenticate(struct hostapd_data *hapd, struct sta_info *sta,
wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR, wpa_printf(MSG_DEBUG, "%s: deauthenticate STA " MACSTR,
hapd->conf->iface, MAC2STR(sta->addr)); hapd->conf->iface, MAC2STR(sta->addr));
sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC); sta->flags &= ~(WLAN_STA_AUTH | WLAN_STA_ASSOC);
if (!ap_sta_in_other_bss(hapd, sta, WLAN_STA_ASSOC)) ap_sta_remove(hapd, sta);
ap_sta_remove(hapd, sta);
sta->timeout_next = STA_REMOVE; sta->timeout_next = STA_REMOVE;
eloop_cancel_timeout(ap_handle_timer, hapd, sta); eloop_cancel_timeout(ap_handle_timer, hapd, sta);
eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0, eloop_register_timeout(AP_MAX_INACTIVITY_AFTER_DEAUTH, 0,