Patchwork [v4,03/25] VLAN: remove vlan_tail

login
register
mail settings
Submitter michael-dev@fami-braun.de
Date July 27, 2013, 7:54 p.m.
Message ID <20130727195441.17627.56605.stgit@ray-controller>
Download mbox | patch
Permalink /patch/262505/
State Superseded
Headers show

Comments

michael-dev@fami-braun.de - July 27, 2013, 7:54 p.m.
Everything in hostapd can be implemented efficiently without vlan_tail.

Signed-hostap: Michael Braun <michael-dev@fami-braun.de>

V3: Fix sta_info.c depending on the order of VLAN ID / WILDCARD.
    This originally was in VLAN: use untagged/tagged for interface
    configuration by mistake.
---
 hostapd/config_file.c |    7 ++-----
 src/ap/ap_config.h    |    2 +-
 src/ap/sta_info.c     |   12 ++++++++----
 src/ap/vlan_init.c    |    7 ++-----
 4 files changed, 13 insertions(+), 15 deletions(-)
Jouni Malinen - Aug. 4, 2013, 6:48 p.m.
On Sat, Jul 27, 2013 at 09:54:41PM +0200, Michael Braun wrote:
> Everything in hostapd can be implemented efficiently without vlan_tail.

> V3: Fix sta_info.c depending on the order of VLAN ID / WILDCARD.
>     This originally was in VLAN: use untagged/tagged for interface
>     configuration by mistake.

Thanks, applied.

> diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
> @@ -690,14 +690,18 @@ int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
>  		sta->vlan_id = 0;
>  	else if (sta->vlan_id > 0) {
>  		vlan = hapd->conf->vlan;
> +		struct hostapd_vlan *wildcard_vlan = NULL;

With that variable declaration moved to the beginning of the block to
comply with C89.

Patch

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index bf17abe..e9d324f 100644
--- a/hostapd/config_file.c
+++ b/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);
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index e0ded7c..9b87686 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -325,7 +325,7 @@  struct hostapd_bss_config {
 	int wmm_enabled;
 	int wmm_uapsd;
 
-	struct hostapd_vlan *vlan, *vlan_tail;
+	struct hostapd_vlan *vlan;
 
 	macaddr bssid;
 
diff --git a/src/ap/sta_info.c b/src/ap/sta_info.c
index 21235f2..39c9eb8 100644
--- a/src/ap/sta_info.c
+++ b/src/ap/sta_info.c
@@ -690,14 +690,18 @@  int ap_sta_bind_vlan(struct hostapd_data *hapd, struct sta_info *sta,
 		sta->vlan_id = 0;
 	else if (sta->vlan_id > 0) {
 		vlan = hapd->conf->vlan;
+		struct hostapd_vlan *wildcard_vlan = NULL;
 		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) {
diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c
index 70affda..746af40 100644
--- a/src/ap/vlan_init.c
+++ b/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))