3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 09:39:25 +01:00

test-runner: Only create/remove interfaces for hostapd

Move the interface creation code from configure_hw_radios to
configure_hostapd_instaces so as not to create unneeded interfaces on
the wiphys that IWD is going to manage.  We pass a wiphy whitelist to
IWD later and IWD now creates the interfaces it needs on those managed
wiphys.  Change TEST_WIPHY_LIST format to only include the interface
name for the wiphys used by hostapd.

Note that we still remove interfaces just before removing the hwsim
radios on exit, it seems like there's no point removing the interfaces
in that case.
This commit is contained in:
Andrew Zaborowski 2019-04-20 22:29:00 +02:00 committed by Denis Kenzior
parent 20faa37467
commit d1c4921b86

View File

@ -1116,22 +1116,7 @@ configure:
goto exit; goto exit;
} }
l_queue_push_head(wiphy_list, wiphy); l_queue_push_tail(wiphy_list, wiphy);
wiphy->interface_name = l_strdup_printf("%s%d",
HW_INTERFACE_PREFIX,
num_radios_created);
if (!create_interface(wiphy->interface_name, wiphy->name))
goto exit;
wiphy->interface_created = true;
l_info("Created interface %s on %s radio",
wiphy->interface_name, wiphy->name);
if (!set_interface_state(wiphy->interface_name,
HW_INTERFACE_STATE_UP))
goto exit;
num_radios_created++; num_radios_created++;
} }
@ -1197,6 +1182,7 @@ static bool configure_hostapd_instances(struct l_settings *hw_settings,
for (i = 0; hostap_keys[i]; i++) { for (i = 0; hostap_keys[i]; i++) {
const struct l_queue_entry *wiphy_entry; const struct l_queue_entry *wiphy_entry;
const char *hostapd_config_file; const char *hostapd_config_file;
unsigned wiphy_idx = 0;
hostapd_config_file = hostapd_config_file =
l_settings_get_value(hw_settings, l_settings_get_value(hw_settings,
@ -1216,7 +1202,8 @@ static bool configure_hostapd_instances(struct l_settings *hw_settings,
for (wiphy_entry = l_queue_get_entries(wiphy_list); for (wiphy_entry = l_queue_get_entries(wiphy_list);
wiphy_entry; wiphy_entry;
wiphy_entry = wiphy_entry->next) { wiphy_entry = wiphy_entry->next,
wiphy_idx++) {
struct wiphy *wiphy = wiphy_entry->data; struct wiphy *wiphy = wiphy_entry->data;
if (strcmp(wiphy->name, hostap_keys[i])) if (strcmp(wiphy->name, hostap_keys[i]))
@ -1233,7 +1220,29 @@ static bool configure_hostapd_instances(struct l_settings *hw_settings,
} }
if (!wiphy_entry) { if (!wiphy_entry) {
l_error("Failed to find available interface."); l_error("Failed to find available wiphy.");
goto done;
}
wiphys[i]->interface_name = l_strdup_printf("%s%d",
HW_INTERFACE_PREFIX,
wiphy_idx);
if (!create_interface(wiphys[i]->interface_name,
wiphys[i]->name)) {
l_error("Failed to create hostapd interface %s on "
"radio %s",
wiphys[i]->interface_name, wiphys[i]->name);
goto done;
}
wiphys[i]->interface_created = true;
l_info("Created hostapd interface %s on %s radio",
wiphys[i]->interface_name, wiphys[i]->name);
if (!set_interface_state(wiphys[i]->interface_name,
HW_INTERFACE_STATE_UP)) {
l_error("Failed to set %s state UP",
wiphys[i]->interface_name);
goto done; goto done;
} }
@ -1293,9 +1302,6 @@ static pid_t start_iwd(const char *config_dir, struct l_queue *wiphy_list,
wiphy_entry = wiphy_entry->next) { wiphy_entry = wiphy_entry->next) {
struct wiphy *wiphy = wiphy_entry->data; struct wiphy *wiphy = wiphy_entry->data;
if (!wiphy->interface_created)
continue;
if (wiphy->used_by_hostapd) if (wiphy->used_by_hostapd)
continue; continue;
@ -1665,10 +1671,9 @@ static void set_wiphy_list(struct l_queue *wiphy_list)
struct wiphy *wiphy = wiphy_entry->data; struct wiphy *wiphy = wiphy_entry->data;
size += 32 + strlen(wiphy->name); size += 32 + strlen(wiphy->name);
if (wiphy->interface_created)
size += 32 + strlen(wiphy->interface_name);
if (wiphy->used_by_hostapd) { if (wiphy->used_by_hostapd) {
size += 32 + strlen(wiphy->hostapd_ctrl_interface) + size += 32 + strlen(wiphy->interface_name) +
strlen(wiphy->hostapd_ctrl_interface) +
strlen(wiphy->hostapd_config); strlen(wiphy->hostapd_config);
} }
} }
@ -1683,12 +1688,13 @@ static void set_wiphy_list(struct l_queue *wiphy_list)
if (size) if (size)
var[size++] = '\n'; var[size++] = '\n';
size += sprintf(var + size, "%s=%s=", wiphy->name, size += sprintf(var + size, "%s=", wiphy->name);
wiphy->interface_name);
if (wiphy->used_by_hostapd) if (wiphy->used_by_hostapd)
size += sprintf(var + size, size += sprintf(var + size,
"hostapd,ctrl_interface=%s,config=%s", "hostapd,name=%s,ctrl_interface=%s,"
"config=%s",
wiphy->interface_name,
wiphy->hostapd_ctrl_interface, wiphy->hostapd_ctrl_interface,
wiphy->hostapd_config); wiphy->hostapd_config);
else else