]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Fix STA re-bind to another VLAN on reauthentication
authorJouni Malinen <jouni@qca.qualcomm.com>
Thu, 29 Jan 2015 23:09:51 +0000 (01:09 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 29 Jan 2015 23:09:51 +0000 (01:09 +0200)
Previously, the old VLAN ID could have been deleted before the STA was
bound to the new VLAN in case the RADIUS server changed the VLAN ID
during an association. This did not exactly work well with mac80211, so
reorder the operations in a way that first binds the STA to the new VLAN
ID and only after that, removes the old VLAN interface if no STAs remain
in it.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
src/ap/sta_info.c

index bb43218926441b7e73d4a7440a74610bb7f662b7..eebaa3ce6227eab43c6fc27242d730eed70ff37a 100644 (file)
@@ -781,13 +781,6 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
        if (sta->vlan_id == old_vlanid)
                return 0;
 
-       /*
-        * During 1x reauth, if the vlan id changes, then remove the old id and
-        * proceed furthur to add the new one.
-        */
-       if (old_vlanid > 0)
-               vlan_remove_dynamic(hapd, old_vlanid);
-
        iface = hapd->conf->iface;
        if (sta->ssid->vlan[0])
                iface = sta->ssid->vlan;
@@ -815,7 +808,8 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
                               HOSTAPD_LEVEL_DEBUG, "could not find VLAN for "
                               "binding station to (vlan_id=%d)",
                               sta->vlan_id);
-               return -1;
+               ret = -1;
+               goto done;
        } else if (sta->vlan_id > 0 && vlan->vlan_id == VLAN_ID_WILDCARD) {
                vlan = vlan_add_dynamic(hapd, vlan, sta->vlan_id);
                if (vlan == NULL) {
@@ -824,7 +818,8 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
                                       HOSTAPD_LEVEL_DEBUG, "could not add "
                                       "dynamic VLAN interface for vlan_id=%d",
                                       sta->vlan_id);
-                       return -1;
+                       ret = -1;
+                       goto done;
                }
 
                iface = vlan->ifname;
@@ -878,6 +873,12 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
                               HOSTAPD_LEVEL_DEBUG, "could not bind the STA "
                               "entry to vlan_id=%d", sta->vlan_id);
        }
+
+done:
+       /* During 1x reauth, if the vlan id changes, then remove the old id. */
+       if (old_vlanid > 0)
+               vlan_remove_dynamic(hapd, old_vlanid);
+
        return ret;
 #else /* CONFIG_NO_VLAN */
        return 0;