[PATCH v4 20/25] Fix kernel NEWLINK processing

Michael Braun michael-dev at fami-braun.de
Sat Jul 27 15:56:07 EDT 2013


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 at fami-braun.de>
---
 src/ap/ap_config.h |    7 +++++++
 src/ap/vlan_init.c |    9 ++++++++-
 2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index 5c5b15a..deae005 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -88,6 +88,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 11de5af..4ea7a9d 100644
--- a/src/ap/vlan_init.c
+++ b/src/ap/vlan_init.c
@@ -662,7 +662,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;
@@ -696,6 +696,9 @@ static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
 			vlan_newlink_vlan(tagged_vlan_id, vlan_ifname, clean,
 			                  hapd);
 		}
+
+		vlan->newlink_seen = 1;
+
 		break;
 	}
 }
@@ -739,6 +742,10 @@ static void vlan_dellink_vlan(int vlan_id, char* ifname, int *clean,
 			ifconfig_down(vlan_ifname);
 			vlan_rem(vlan_ifname);
 		}
+
+		/* newlink_seen does not need to be reset, as the whole
+		 * vlan entry is freed uplink RTM_DELLINK
+		 */
 	}
 
 	if (clean && (*clean & DVLAN_CLEAN_BR) &&



More information about the HostAP mailing list