hostapd: maintain ucode hostapd.bss list per interface
Preparation for MLO support Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
		| @@ -471,18 +471,26 @@ function bss_find_existing(config, prev_config, prev_hash) | |||||||
| 	return -1; | 	return -1; | ||||||
| } | } | ||||||
|  |  | ||||||
| function get_config_bss(config, idx) | function get_config_bss(name, config, idx) | ||||||
| { | { | ||||||
| 	if (!config.bss[idx]) { | 	if (!config.bss[idx]) { | ||||||
| 		hostapd.printf(`Invalid bss index ${idx}`); | 		hostapd.printf(`Invalid bss index ${idx}`); | ||||||
| 		return null; | 		return; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	let ifname = config.bss[idx].ifname; | 	let ifname = config.bss[idx].ifname; | ||||||
| 	if (!ifname) | 	if (!ifname) { | ||||||
| 		hostapd.printf(`Could not find bss ${config.bss[idx].ifname}`); | 		hostapd.printf(`Could not find bss ${config.bss[idx].ifname}`); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	return hostapd.bss[ifname]; | 	let if_bss = hostapd.bss[name]; | ||||||
|  | 	if (!if_bss) { | ||||||
|  | 		hostapd.printf(`Could not find interface ${name} bss list`); | ||||||
|  | 		return; | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	return if_bss[ifname]; | ||||||
| } | } | ||||||
|  |  | ||||||
| function iface_reload_config(name, phydev, config, old_config) | function iface_reload_config(name, phydev, config, old_config) | ||||||
| @@ -508,7 +516,7 @@ function iface_reload_config(name, phydev, config, old_config) | |||||||
| 		return false; | 		return false; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	let first_bss = hostapd.bss[iface_name]; | 	let first_bss = get_config_bss(name, old_config, 0); | ||||||
| 	if (!first_bss) { | 	if (!first_bss) { | ||||||
| 		hostapd.printf(`Could not find bss of previous interface ${iface_name}`); | 		hostapd.printf(`Could not find bss of previous interface ${iface_name}`); | ||||||
| 		return false; | 		return false; | ||||||
| @@ -543,7 +551,7 @@ function iface_reload_config(name, phydev, config, old_config) | |||||||
| 		let cur_config = config.bss[i]; | 		let cur_config = config.bss[i]; | ||||||
| 		let prev_config = old_config.bss[prev]; | 		let prev_config = old_config.bss[prev]; | ||||||
|  |  | ||||||
| 		let prev_bss = get_config_bss(old_config, prev); | 		let prev_bss = get_config_bss(name, old_config, prev); | ||||||
| 		if (!prev_bss) | 		if (!prev_bss) | ||||||
| 			return false; | 			return false; | ||||||
|  |  | ||||||
| @@ -576,7 +584,7 @@ function iface_reload_config(name, phydev, config, old_config) | |||||||
| 			config.bss[0].bssid = old_config.bss[0].bssid; | 			config.bss[0].bssid = old_config.bss[0].bssid; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		let prev_bss = get_config_bss(old_config, 0); | 		let prev_bss = get_config_bss(name, old_config, 0); | ||||||
| 		if (!prev_bss) | 		if (!prev_bss) | ||||||
| 			return false; | 			return false; | ||||||
|  |  | ||||||
| @@ -591,7 +599,7 @@ function iface_reload_config(name, phydev, config, old_config) | |||||||
| 		if (!prev_bss_hash[i]) | 		if (!prev_bss_hash[i]) | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		let prev_bss = get_config_bss(old_config, i); | 		let prev_bss = get_config_bss(name, old_config, i); | ||||||
| 		if (!prev_bss) | 		if (!prev_bss) | ||||||
| 			return false; | 			return false; | ||||||
|  |  | ||||||
| @@ -612,7 +620,7 @@ function iface_reload_config(name, phydev, config, old_config) | |||||||
| 		if (old_ifname == new_ifname) | 		if (old_ifname == new_ifname) | ||||||
| 			continue; | 			continue; | ||||||
|  |  | ||||||
| 		if (hostapd.bss[new_ifname]) { | 		if (hostapd.bss[name][new_ifname]) { | ||||||
| 			new_ifname = "tmp_" + substr(hostapd.sha1(new_ifname), 0, 8); | 			new_ifname = "tmp_" + substr(hostapd.sha1(new_ifname), 0, 8); | ||||||
| 			push(rename_list, i); | 			push(rename_list, i); | ||||||
| 		} | 		} | ||||||
|   | |||||||
| @@ -47,39 +47,37 @@ hostapd_ucode_iface_get_uval(struct hostapd_iface *hapd) | |||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| hostapd_ucode_update_bss_list(struct hostapd_iface *iface, uc_value_t *if_bss, uc_value_t *bss) | hostapd_ucode_update_bss_list(struct hostapd_iface *iface, uc_value_t *bss) | ||||||
| { | { | ||||||
| 	uc_value_t *list; | 	uc_value_t *list; | ||||||
| 	int i; | 	int i; | ||||||
|  |  | ||||||
| 	list = ucv_array_new(vm); | 	list = ucv_object_new(vm); | ||||||
| 	for (i = 0; iface->bss && i < iface->num_bss; i++) { | 	for (i = 0; iface->bss && i < iface->num_bss; i++) { | ||||||
| 		struct hostapd_data *hapd = iface->bss[i]; | 		struct hostapd_data *hapd = iface->bss[i]; | ||||||
|  | 		uc_value_t *uval = hostapd_ucode_bss_get_uval(hapd); | ||||||
|  |  | ||||||
| 		ucv_array_set(list, i, ucv_string_new(hapd->conf->iface)); | 		ucv_object_add(list, hapd->conf->iface, uval); | ||||||
| 		ucv_object_add(bss, hapd->conf->iface, hostapd_ucode_bss_get_uval(hapd)); |  | ||||||
| 	} | 	} | ||||||
| 	ucv_object_add(if_bss, iface->phy, list); | 	ucv_object_add(bss, iface->phy, list); | ||||||
| } | } | ||||||
|  |  | ||||||
| static void | static void | ||||||
| hostapd_ucode_update_interfaces(void) | hostapd_ucode_update_interfaces(void) | ||||||
| { | { | ||||||
| 	uc_value_t *ifs = ucv_object_new(vm); | 	uc_value_t *ifs = ucv_object_new(vm); | ||||||
| 	uc_value_t *if_bss = ucv_array_new(vm); | 	uc_value_t *if_bss = ucv_object_new(vm); | ||||||
| 	uc_value_t *bss = ucv_object_new(vm); |  | ||||||
| 	int i; | 	int i; | ||||||
|  |  | ||||||
| 	for (i = 0; i < interfaces->count; i++) { | 	for (i = 0; i < interfaces->count; i++) { | ||||||
| 		struct hostapd_iface *iface = interfaces->iface[i]; | 		struct hostapd_iface *iface = interfaces->iface[i]; | ||||||
|  |  | ||||||
| 		ucv_object_add(ifs, iface->phy, hostapd_ucode_iface_get_uval(iface)); | 		ucv_object_add(ifs, iface->phy, hostapd_ucode_iface_get_uval(iface)); | ||||||
| 		hostapd_ucode_update_bss_list(iface, if_bss, bss); | 		hostapd_ucode_update_bss_list(iface, if_bss); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	ucv_object_add(ucv_prototype_get(global), "interfaces", ifs); | 	ucv_object_add(ucv_prototype_get(global), "interfaces", ifs); | ||||||
| 	ucv_object_add(ucv_prototype_get(global), "interface_bss", if_bss); | 	ucv_object_add(ucv_prototype_get(global), "bss", if_bss); | ||||||
| 	ucv_object_add(ucv_prototype_get(global), "bss", bss); |  | ||||||
|  |  | ||||||
| 	ucv_gc(vm); | 	ucv_gc(vm); | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Felix Fietkau
					Felix Fietkau