mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-22 06:29:23 +01:00
t-runner: Use radio identifiers in service assign.
This commit is contained in:
parent
6d0bef0bfb
commit
7fa2ac7b67
@ -394,6 +394,11 @@ static bool wait_for_socket(const char *socket, useconds_t wait_time)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void hashmap_string_destroy(void *value)
|
||||||
|
{
|
||||||
|
l_free(value);
|
||||||
|
}
|
||||||
|
|
||||||
static void create_dbus_system_conf(void)
|
static void create_dbus_system_conf(void)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
@ -788,7 +793,7 @@ error_exit:
|
|||||||
|
|
||||||
static bool configure_hw_radios(struct l_settings *hw_settings,
|
static bool configure_hw_radios(struct l_settings *hw_settings,
|
||||||
int hwsim_radio_ids[],
|
int hwsim_radio_ids[],
|
||||||
char *interface_names_out[])
|
struct l_hashmap *if_name_map)
|
||||||
{
|
{
|
||||||
char interface_name[7];
|
char interface_name[7];
|
||||||
char phy_name[7];
|
char phy_name[7];
|
||||||
@ -834,7 +839,7 @@ static bool configure_hw_radios(struct l_settings *hw_settings,
|
|||||||
goto configure;
|
goto configure;
|
||||||
}
|
}
|
||||||
|
|
||||||
radio_config_group = radio_conf_list[i++];
|
radio_config_group = radio_conf_list[i];
|
||||||
|
|
||||||
if (!l_settings_has_group(hw_settings, radio_config_group)) {
|
if (!l_settings_has_group(hw_settings, radio_config_group)) {
|
||||||
l_error("No radio configuration group [%s] found in "
|
l_error("No radio configuration group [%s] found in "
|
||||||
@ -889,33 +894,35 @@ configure:
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface_names_out[num_radios_created] =
|
l_hashmap_insert(if_name_map,
|
||||||
strdup(interface_name);
|
has_hw_conf ?
|
||||||
|
l_strdup(radio_conf_list[i++]) :
|
||||||
|
l_strdup(interface_name),
|
||||||
|
l_strdup(interface_name));
|
||||||
|
|
||||||
num_radios_created++;
|
num_radios_created++;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface_names_out[num_radios_created + 1] = NULL;
|
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
l_strfreev(radio_conf_list);
|
l_strfreev(radio_conf_list);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void destroy_hw_radios(int hwsim_radio_ids[],
|
static void destroy_hw_radios(int hwsim_radio_ids[])
|
||||||
char *interface_names_in[])
|
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
while (interface_names_in[i]) {
|
while (hwsim_radio_ids[i] != -1) {
|
||||||
set_interface_state(interface_names_in[i],
|
char *if_name;
|
||||||
HW_INTERFACE_STATE_DOWN);
|
|
||||||
|
|
||||||
delete_interface(interface_names_in[i]);
|
if_name = l_strdup_printf("%s%d", HW_INTERFACE_PREFIX, i);
|
||||||
l_debug("Removed interface %s", interface_names_in[i]);
|
|
||||||
|
|
||||||
interface_names_in[i] = NULL;
|
set_interface_state(if_name, HW_INTERFACE_STATE_DOWN);
|
||||||
|
delete_interface(if_name);
|
||||||
|
|
||||||
|
l_debug("Removed interface %s", if_name);
|
||||||
|
|
||||||
|
l_free(if_name);
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -931,9 +938,20 @@ static void destroy_hw_radios(int hwsim_radio_ids[],
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void get_next_avail_if(const void *key, void *value, void *data)
|
||||||
|
{
|
||||||
|
char **if_name = (char **) data;
|
||||||
|
|
||||||
|
if (!*if_name && !strcmp(key, value)) {
|
||||||
|
*if_name = l_strdup(value);
|
||||||
|
|
||||||
|
l_debug("Found available interface %s", (char *) *if_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static bool configure_hostapd_instances(struct l_settings *hw_settings,
|
static bool configure_hostapd_instances(struct l_settings *hw_settings,
|
||||||
char *config_dir_path,
|
char *config_dir_path,
|
||||||
char *interface_names_in[],
|
struct l_hashmap *if_name_map,
|
||||||
pid_t hostapd_pids_out[])
|
pid_t hostapd_pids_out[])
|
||||||
{
|
{
|
||||||
char **hostap_keys;
|
char **hostap_keys;
|
||||||
@ -950,7 +968,7 @@ static bool configure_hostapd_instances(struct l_settings *hw_settings,
|
|||||||
while (hostap_keys[i]) {
|
while (hostap_keys[i]) {
|
||||||
char hostapd_config_file_path[PATH_MAX];
|
char hostapd_config_file_path[PATH_MAX];
|
||||||
const char *hostapd_config_file;
|
const char *hostapd_config_file;
|
||||||
char *interface_name;
|
char *if_name;
|
||||||
|
|
||||||
hostapd_config_file =
|
hostapd_config_file =
|
||||||
l_settings_get_value(hw_settings,
|
l_settings_get_value(hw_settings,
|
||||||
@ -970,10 +988,21 @@ static bool configure_hostapd_instances(struct l_settings *hw_settings,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface_name = interface_names_in[i];
|
if_name = l_hashmap_remove(if_name_map, hostap_keys[i]);
|
||||||
|
|
||||||
|
if (!if_name)
|
||||||
|
l_hashmap_foreach(if_name_map, get_next_avail_if,
|
||||||
|
&if_name);
|
||||||
|
if (if_name) {
|
||||||
|
l_hashmap_remove(if_name_map, if_name);
|
||||||
|
} else {
|
||||||
|
l_error("Failed to find available interface.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
hostapd_pids_out[i] = start_hostapd(hostapd_config_file_path,
|
hostapd_pids_out[i] = start_hostapd(hostapd_config_file_path,
|
||||||
interface_name);
|
if_name);
|
||||||
|
l_free(if_name);
|
||||||
|
|
||||||
if (hostapd_pids_out[i] < 1)
|
if (hostapd_pids_out[i] < 1)
|
||||||
return false;
|
return false;
|
||||||
@ -1279,11 +1308,11 @@ static void create_network_and_run_tests(const void *key, void *value,
|
|||||||
void *data)
|
void *data)
|
||||||
{
|
{
|
||||||
int hwsim_radio_ids[HWSIM_RADIOS_MAX];
|
int hwsim_radio_ids[HWSIM_RADIOS_MAX];
|
||||||
char *interface_names[HWSIM_RADIOS_MAX];
|
|
||||||
pid_t hostapd_pids[HWSIM_RADIOS_MAX];
|
pid_t hostapd_pids[HWSIM_RADIOS_MAX];
|
||||||
pid_t iwd_pid;
|
pid_t iwd_pid;
|
||||||
char *config_dir_path;
|
char *config_dir_path;
|
||||||
struct l_settings *hw_settings;
|
struct l_settings *hw_settings;
|
||||||
|
struct l_hashmap *if_name_map;
|
||||||
struct l_queue *test_queue;
|
struct l_queue *test_queue;
|
||||||
struct l_queue *test_stats_queue;
|
struct l_queue *test_stats_queue;
|
||||||
|
|
||||||
@ -1309,10 +1338,13 @@ static void create_network_and_run_tests(const void *key, void *value,
|
|||||||
if (!hw_settings)
|
if (!hw_settings)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if_name_map = l_hashmap_string_new();
|
||||||
|
if (!if_name_map)
|
||||||
|
return;
|
||||||
|
|
||||||
l_info("Configuring network...");
|
l_info("Configuring network...");
|
||||||
|
|
||||||
if (!configure_hw_radios(hw_settings, hwsim_radio_ids,
|
if (!configure_hw_radios(hw_settings, hwsim_radio_ids, if_name_map))
|
||||||
interface_names))
|
|
||||||
goto exit_hwsim;
|
goto exit_hwsim;
|
||||||
|
|
||||||
list_hwsim_radios();
|
list_hwsim_radios();
|
||||||
@ -1320,7 +1352,7 @@ static void create_network_and_run_tests(const void *key, void *value,
|
|||||||
list_interfaces();
|
list_interfaces();
|
||||||
|
|
||||||
if (!configure_hostapd_instances(hw_settings, config_dir_path,
|
if (!configure_hostapd_instances(hw_settings, config_dir_path,
|
||||||
interface_names, hostapd_pids))
|
if_name_map, hostapd_pids))
|
||||||
goto exit_hostapd;
|
goto exit_hostapd;
|
||||||
|
|
||||||
iwd_pid = start_iwd();
|
iwd_pid = start_iwd();
|
||||||
@ -1342,8 +1374,9 @@ exit_hostapd:
|
|||||||
destroy_hostapd_instances(hostapd_pids);
|
destroy_hostapd_instances(hostapd_pids);
|
||||||
|
|
||||||
exit_hwsim:
|
exit_hwsim:
|
||||||
destroy_hw_radios(hwsim_radio_ids, interface_names);
|
destroy_hw_radios(hwsim_radio_ids);
|
||||||
|
|
||||||
|
l_hashmap_destroy(if_name_map, hashmap_string_destroy);
|
||||||
l_settings_free(hw_settings);
|
l_settings_free(hw_settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user