Browse Source

VLAN: Remove vlan_tail

Everything in hostapd can be implemented efficiently without vlan_tail.

Signed-hostap: Michael Braun <michael-dev@fami-braun.de>
Michael Braun 11 years ago
parent
commit
c2db79f237
4 changed files with 13 additions and 15 deletions
  1. 2 5
      hostapd/config_file.c
  2. 1 1
      src/ap/ap_config.h
  3. 8 4
      src/ap/sta_info.c
  4. 2 5
      src/ap/vlan_init.c

+ 2 - 5
hostapd/config_file.c

@@ -93,11 +93,8 @@ static int hostapd_config_read_vlan_file(struct hostapd_bss_config *bss,
 
 		vlan->vlan_id = vlan_id;
 		os_strlcpy(vlan->ifname, pos, sizeof(vlan->ifname));
-		if (bss->vlan_tail)
-			bss->vlan_tail->next = vlan;
-		else
-			bss->vlan = vlan;
-		bss->vlan_tail = vlan;
+		vlan->next = bss->vlan;
+		bss->vlan = vlan;
 	}
 
 	fclose(f);

+ 1 - 1
src/ap/ap_config.h

@@ -327,7 +327,7 @@ struct hostapd_bss_config {
 	int wmm_enabled;
 	int wmm_uapsd;
 
-	struct hostapd_vlan *vlan, *vlan_tail;
+	struct hostapd_vlan *vlan;
 
 	macaddr bssid;
 

+ 8 - 4
src/ap/sta_info.c

@@ -689,15 +689,19 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
 	if (sta->ssid->dynamic_vlan == DYNAMIC_VLAN_DISABLED)
 		sta->vlan_id = 0;
 	else if (sta->vlan_id > 0) {
+		struct hostapd_vlan *wildcard_vlan = NULL;
 		vlan = hapd->conf->vlan;
 		while (vlan) {
-			if (vlan->vlan_id == sta->vlan_id ||
-			    vlan->vlan_id == VLAN_ID_WILDCARD) {
-				iface = vlan->ifname;
+			if (vlan->vlan_id == sta->vlan_id)
 				break;
-			}
+			if (vlan->vlan_id == VLAN_ID_WILDCARD)
+				wildcard_vlan = vlan;
 			vlan = vlan->next;
 		}
+		if (!vlan)
+			vlan = wildcard_vlan;
+		if (vlan)
+			iface = vlan->ifname;
 	}
 
 	if (sta->vlan_id > 0 && vlan == NULL) {

+ 2 - 5
src/ap/vlan_init.c

@@ -1004,11 +1004,8 @@ int vlan_init(struct hostapd_data *hapd)
 		vlan->vlan_id = VLAN_ID_WILDCARD;
 		os_snprintf(vlan->ifname, sizeof(vlan->ifname), "%s.#",
 			    hapd->conf->iface);
-		if (hapd->conf->vlan_tail)
-			hapd->conf->vlan_tail->next = vlan;
-		else
-			hapd->conf->vlan = vlan;
-		hapd->conf->vlan_tail = vlan;
+		vlan->next = hapd->conf->vlan;
+		hapd->conf->vlan = vlan;
 	}
 
 	if (vlan_dynamic_add(hapd, hapd->conf->vlan))