Cumulative patch from commit 390b92913a9a1b3a6aaf70e8b5971a7b7c76cabc

390b929 TLS testing: Allow hostapd to be used as a TLS testing tool
994afe3 RADIUS server: Allow TLS implementation add log entries
01f7fe1 RADIUS server: Allow EAP methods to log into SQLite DB
8a57da7 RADIUS server: Add option for storing log information to SQLite DB
f3ef7a2 TLS client: Send decrypt_error on verify_data validation error
129b9b9 TLS: Share a helper function for verifying Signature
6531963 TLS: Use a helper function for calculating ServerKeyExchange hash
65074a2 TLS: Add support for DHE-RSA cipher suites
41ebfe9 TLS server: Enable SHA256-based cipher suites
60b893d wpa_supplicant: Allow external management frame processing for testing
ec33bc6 Enable RADIUS message dumps with excessive debug verbosity
226e357 Revert "bridge: Track inter-BSS usage"
d0ee16e Allow arbitrary RADIUS attributes to be added into Access-Accept
0ac3876 Fix PMF protect disconnection on session timeout
49021c1 Fix hostapd error path regression

Change-Id: Ie0710c036cca2fb370d28684cc5a5d28a075dfc1
Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
diff --git a/src/ap/vlan_init.c b/src/ap/vlan_init.c
index 509e557..4e4a352 100644
--- a/src/ap/vlan_init.c
+++ b/src/ap/vlan_init.c
@@ -474,123 +474,6 @@
 #endif /* CONFIG_VLAN_NETLINK */
 
 
-/**
- * Increase the usage counter for given parent/ifname combination.
- * If create is set, then this iface is added to the global list.
- * Returns
- * 	-1 on error
- * 	0 if iface is not in list
- * 	1 if iface is in list (was there or has been added)
- */
-static int hapd_get_dynamic_iface(const char *parent, const char *ifname,
-				  int create, struct hostapd_data *hapd)
-{
-	size_t i;
-	struct hostapd_dynamic_iface *j = NULL, **tmp;
-	struct hapd_interfaces *hapd_global = hapd->iface->interfaces;
-
-	if (!parent)
-		parent = "";
-
-	for (i = 0; i < hapd_global->count_dynamic; i++) {
-		j = hapd_global->dynamic_iface[i];
-		if (os_strncmp(j->iface, ifname, sizeof(j->iface)) == 0 &&
-		    os_strncmp(j->parent, parent, sizeof(j->parent)) == 0)
-			break;
-	}
-	if (i < hapd_global->count_dynamic) {
-		j->usage++;
-		return 1;
-	}
-
-	/* new entry required */
-	if (!create)
-		return 0;
-
-	j = os_zalloc(sizeof(*j));
-	if (!j)
-		return -1;
-	os_strlcpy(j->iface, ifname, sizeof(j->iface));
-	os_strlcpy(j->parent, parent, sizeof(j->parent));
-
-	tmp = os_realloc_array(hapd_global->dynamic_iface, i + 1,
-			       sizeof(*hapd_global->dynamic_iface));
-	if (!tmp) {
-		wpa_printf(MSG_ERROR, "VLAN: Failed to allocate memory in %s",
-			   __func__);
-		return -1;
-	}
-	hapd_global->count_dynamic++;
-	hapd_global->dynamic_iface = tmp;
-	hapd_global->dynamic_iface[i] = j;
-
-	return 1;
-}
-
-
-/**
- * Decrease the usage counter for given ifname.
- * Returns
- *     -1 on error or if iface was not found
- *     0 if iface was found and is still present
- *     1 if iface was removed from global list
- */
-static int hapd_put_dynamic_iface(const char *parent, const char *ifname,
-				  struct hostapd_data *hapd)
-{
-	size_t i;
-	struct hostapd_dynamic_iface *j = NULL, **tmp;
-	struct hapd_interfaces *hapd_glob = hapd->iface->interfaces;
-
-	if (!parent)
-		parent = "";
-
-	for (i = 0; i < hapd_glob->count_dynamic; i++) {
-		j = hapd_glob->dynamic_iface[i];
-		if (os_strncmp(j->iface, ifname, sizeof(j->iface)) == 0 &&
-		    os_strncmp(j->parent, parent, sizeof(j->parent)) == 0)
-			break;
-	}
-
-	if (i == hapd_glob->count_dynamic) {
-		/*
-		 * Interface not in global list. This can happen if alloc in
-		 * _get_ failed.
-		 */
-		return -1;
-	}
-
-	if (j->usage > 0) {
-		j->usage--;
-		return 0;
-	}
-
-	os_free(j);
-	for (; i < hapd_glob->count_dynamic - 1; i++)
-		hapd_glob->dynamic_iface[i] = hapd_glob->dynamic_iface[i + 1];
-	hapd_glob->dynamic_iface[hapd_glob->count_dynamic - 1] = NULL;
-	hapd_glob->count_dynamic--;
-
-	if (hapd_glob->count_dynamic == 0) {
-		os_free(hapd_glob->dynamic_iface);
-		hapd_glob->dynamic_iface = NULL;
-		return 1;
-	}
-
-	tmp = os_realloc_array(hapd_glob->dynamic_iface,
-			       hapd_glob->count_dynamic,
-			       sizeof(*hapd_glob->dynamic_iface));
-	if (!tmp) {
-		wpa_printf(MSG_ERROR, "VLAN: Failed to release memory in %s",
-			   __func__);
-		return -1;
-	}
-	hapd_glob->dynamic_iface = tmp;
-
-	return 1;
-}
-
-
 static void vlan_newlink(char *ifname, struct hostapd_data *hapd)
 {
 	char vlan_ifname[IFNAMSIZ];
@@ -598,7 +481,6 @@
 	struct hostapd_vlan *vlan = hapd->conf->vlan;
 	char *tagged_interface = hapd->conf->ssid.vlan_tagged_interface;
 	int vlan_naming = hapd->conf->ssid.vlan_naming;
-	int ret;
 
 	wpa_printf(MSG_DEBUG, "VLAN: vlan_newlink(%s)", ifname);
 
@@ -618,9 +500,7 @@
 				            "brvlan%d", vlan->vlan_id);
 			}
 
-			ret = br_addbr(br_name);
-			if (hapd_get_dynamic_iface(NULL, br_name, ret == 0,
-			                           hapd))
+			if (!br_addbr(br_name))
 				vlan->clean |= DVLAN_CLEAN_BR;
 
 			ifconfig_up(br_name);
@@ -638,24 +518,17 @@
 						    "vlan%d", vlan->vlan_id);
 
 				ifconfig_up(tagged_interface);
-				ret = vlan_add(tagged_interface, vlan->vlan_id,
-					      vlan_ifname);
-				if (hapd_get_dynamic_iface(NULL, vlan_ifname,
-				                           ret == 0, hapd))
+				if (!vlan_add(tagged_interface, vlan->vlan_id,
+					      vlan_ifname))
 					vlan->clean |= DVLAN_CLEAN_VLAN;
 
-				ret = br_addif(br_name, vlan_ifname);
-				if (hapd_get_dynamic_iface(br_name,
-							   vlan_ifname,
-							   ret == 0, hapd))
+				if (!br_addif(br_name, vlan_ifname))
 					vlan->clean |= DVLAN_CLEAN_VLAN_PORT;
 
 				ifconfig_up(vlan_ifname);
 			}
 
-			ret = br_addif(br_name, ifname);
-			if (hapd_get_dynamic_iface(br_name, ifname, ret == 0,
-						   hapd))
+			if (!br_addif(br_name, ifname))
 				vlan->clean |= DVLAN_CLEAN_WLAN_PORT;
 
 			ifconfig_up(ifname);
@@ -694,8 +567,7 @@
 				            "brvlan%d", vlan->vlan_id);
 			}
 
-			if ((vlan->clean & DVLAN_CLEAN_WLAN_PORT) &&
-			    hapd_put_dynamic_iface(br_name, vlan->ifname, hapd))
+			if (vlan->clean & DVLAN_CLEAN_WLAN_PORT)
 				br_delif(br_name, vlan->ifname);
 
 			if (tagged_interface) {
@@ -709,20 +581,15 @@
 					os_snprintf(vlan_ifname,
 						    sizeof(vlan_ifname),
 						    "vlan%d", vlan->vlan_id);
-				if ((vlan->clean & DVLAN_CLEAN_VLAN_PORT) &&
-				    hapd_put_dynamic_iface(br_name, vlan_ifname,
-							   hapd))
+				if (vlan->clean & DVLAN_CLEAN_VLAN_PORT)
 					br_delif(br_name, vlan_ifname);
 				ifconfig_down(vlan_ifname);
 
-				if ((vlan->clean & DVLAN_CLEAN_VLAN) &&
-				    hapd_put_dynamic_iface(NULL, vlan_ifname,
-							   hapd))
+				if (vlan->clean & DVLAN_CLEAN_VLAN)
 					vlan_rem(vlan_ifname);
 			}
 
 			if ((vlan->clean & DVLAN_CLEAN_BR) &&
-			    hapd_put_dynamic_iface(NULL, br_name, hapd) &&
 			    br_getnumports(br_name) == 0) {
 				ifconfig_down(br_name);
 				br_delbr(br_name);