Patchwork [PATCHv2,15/21] Fix kernel NEWLINK processing

login
register
mail settings
Submitter michael-dev@fami-braun.de
Date June 2, 2013, 9:17 a.m.
Message ID <8aa8e333c89eca6e37e51ef1ff341b649381afa1.1370512966.git.michael-dev@fami-braun.de>
Download mbox | patch
Permalink /patch/249370/
State Superseded
Headers show

Comments

michael-dev@fami-braun.de - June 2, 2013, 9:17 a.m.
Somehow with Kernel 3.8.11 and others, there are multiple NEWLINK
messages received all containing wlanX.<VLAN>.
Though, when processing the extra NEWLINK messages, the usage counters
get increased too far so the dynamic interfaces get not freed.

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

Patch

diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 9638d0e..504e8f3 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -96,6 +96,13 @@  struct hostapd_vlan {
 	 * generation. The linked list is sorted by this id (ascending);
 	 * non-dynamically generated entries get value zero */
 	int artifical_id;
+	/* Somehow with Kernel 3.8.11 and others, there are multiple NEWLINK
+	 * messages received all containing wlanX.<VLAN>.
+	 * Though, when processing the extra NEWLINK messages, the usage
+	 * counters get increased too far so the dynamic interfaces get not
+	 * freed.
+	 */
+	int newlink_seen;
 	int dynamic_vlan;
 #ifdef CONFIG_FULL_DYNAMIC_VLAN
 
diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c
index 20c9ff9..982e793 100644
--- a/src/ap/vlan_init.c
+++ b/src/ap/vlan_init.c
@@ -658,7 +658,7 @@  static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
 	wpa_printf(MSG_DEBUG, "VLAN: vlan_newlink(%s)", ifname);
 
 	for (vlan = hapd->conf->vlan; vlan; vlan = vlan->next) {
-		if (os_strcmp(ifname, vlan->ifname) != 0)
+		if (os_strcmp(ifname, vlan->ifname) != 0 || vlan->newlink_seen)
 			continue;
 
 		int untagged, num_tagged, *tagged;
@@ -692,6 +692,11 @@  static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
 			vlan_newlink_vlan(tagged_vlan_id, vlan_ifname, clean,
 			                  hapd);
 		}
+
+		/* newlink_seen does not need to be reset, as the whole
+		 * vlan entry is freed uplink RTM_DELLINK
+		 */
+		vlan->newlink_seen = 1;
 		break;
 	}
 }