[PATCH] Fix for interface names parameter ignores subsequent parameters

Sam Tannous stannous at cumulusnetworks.com
Mon Nov 7 10:43:36 PST 2016


When using -i to specify one or more comma separated interfaces
(that all use the same config file), we also need to change
the loop parameters (interface.count) so that all the interfaces get
initialized.  Also, we need to make sure that all the
hostapd_interface_init()
calls are made with the same config filename.

This patch fixes hostapd/main.c to correct the interface count
and use of the one config file in the interface initialization call.

Thanks,
Sam Tannous
Cumulus Networks

Signed-off-by: Sam Tannous <stannous at cumulusnetworks.com>

--
diff --git a/hostapd/main.c b/hostapd/main.c
index 2c8dbd3..69fdd26 100644
--- a/hostapd/main.c
+++ b/hostapd/main.c
@@ -644,6 +644,7 @@ int main(int argc, char *argv[])
  int start_ifaces_in_sync = 0;
  char **if_names = NULL;
  size_t if_names_size = 0;
+ const char *config_fname = NULL;

  if (os_program_init())
  return -1;
@@ -756,7 +757,17 @@ int main(int argc, char *argv[])
  }
 #endif /* CONFIG_DEBUG_LINUX_TRACING */

- interfaces.count = argc - optind;
+ /*
+ * We may have comma separated multiple interfaces configured with -i.
+ * If this is the case, we must only have one config file.
+ */
+ if (if_names && if_names_size) {
+ interfaces.count = if_names_size;
+ /* the last arg must be the one config file */
+ config_fname = argv[optind];
+ } else
+ interfaces.count = argc - optind;
+
  if (interfaces.count || num_bss_configs) {
  interfaces.iface = os_calloc(interfaces.count + num_bss_configs,
      sizeof(struct hostapd_iface *));
@@ -792,7 +803,14 @@ int main(int argc, char *argv[])
  if (i < if_names_size)
  if_name = if_names[i];

- interfaces.iface[i] = hostapd_interface_init(&interfaces,
+ /* for interface names parameter, we have one config file */
+ if (config_fname)
+ interfaces.iface[i] = hostapd_interface_init(&interfaces,
+     if_name,
+     config_fname,
+     debug);
+ else
+ interfaces.iface[i] = hostapd_interface_init(&interfaces,
      if_name,
      argv[optind + i],
      debug);



More information about the Hostap mailing list