]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
hostapd: Move ctrl_iface initialization to happen earlier
authorJouni Malinen <j@w1.fi>
Sun, 3 Nov 2013 13:47:01 +0000 (15:47 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Nov 2013 17:51:06 +0000 (19:51 +0200)
Channel determination may take considerable time when ACS or DFS is
used, so it is useful to be able to observe this process through the
control interface. Move the initialization of the control interfaces to
happen before channel determination so that this can be achieved.

Signed-hostap: Jouni Malinen <j@w1.fi>

src/ap/hostapd.c

index 0675655b5faa0a12e545dbd94a248673da9b96b3..d16c36d0d1c2459939d3c66f4fad7784d4bff7e8 100644 (file)
@@ -782,13 +782,6 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
        }
 #endif /* CONFIG_INTERWORKING */
 
-       if (hapd->iface->interfaces &&
-           hapd->iface->interfaces->ctrl_iface_init &&
-           hapd->iface->interfaces->ctrl_iface_init(hapd)) {
-               wpa_printf(MSG_ERROR, "Failed to setup control interface");
-               return -1;
-       }
-
        if (!hostapd_drv_none(hapd) && vlan_init(hapd)) {
                wpa_printf(MSG_ERROR, "VLAN initialization failed.");
                return -1;
@@ -895,6 +888,44 @@ static void hostapd_set_acl(struct hostapd_data *hapd)
 }
 
 
+static int start_ctrl_iface_bss(struct hostapd_data *hapd)
+{
+       if (!hapd->iface->interfaces ||
+           !hapd->iface->interfaces->ctrl_iface_init)
+               return 0;
+
+       if (hapd->iface->interfaces->ctrl_iface_init(hapd)) {
+               wpa_printf(MSG_ERROR,
+                          "Failed to setup control interface for %s",
+                          hapd->conf->iface);
+               return -1;
+       }
+
+       return 0;
+}
+
+
+static int start_ctrl_iface(struct hostapd_iface *iface)
+{
+       size_t i;
+
+       if (!iface->interfaces || !iface->interfaces->ctrl_iface_init)
+               return 0;
+
+       for (i = 0; i < iface->num_bss; i++) {
+               struct hostapd_data *hapd = iface->bss[i];
+               if (iface->interfaces->ctrl_iface_init(hapd)) {
+                       wpa_printf(MSG_ERROR,
+                                  "Failed to setup control interface for %s",
+                                  hapd->conf->iface);
+                       return -1;
+               }
+       }
+
+       return 0;
+}
+
+
 static int setup_interface(struct hostapd_iface *iface)
 {
        struct hostapd_data *hapd = iface->bss[0];
@@ -913,6 +944,14 @@ static int setup_interface(struct hostapd_iface *iface)
        if (hostapd_validate_bssid_configuration(iface))
                return -1;
 
+       /*
+        * Initialize control interfaces early to allow external monitoring of
+        * channel setup operations that may take considerable amount of time
+        * especially for DFS cases.
+        */
+       if (start_ctrl_iface(iface))
+               return -1;
+
        if (hapd->iconf->country[0] && hapd->iconf->country[1]) {
                os_memcpy(country, hapd->iconf->country, 3);
                country[3] = '\0';
@@ -1589,7 +1628,8 @@ int hostapd_add_iface(struct hapd_interfaces *interfaces, char *buf)
                        os_memcpy(hapd->own_addr, hapd_iface->bss[0]->own_addr,
                                  ETH_ALEN);
 
-                       if (hostapd_setup_bss(hapd, -1)) {
+                       if (start_ctrl_iface_bss(hapd) < 0 ||
+                           hostapd_setup_bss(hapd, -1)) {
                                hapd_iface->conf->num_bss--;
                                hapd_iface->num_bss--;
                                os_free(hapd);