diff mbox

AP: Allow using existing interfaces as a fallback

Message ID 1464762834-26321-1-git-send-email-zajec5@gmail.com
State Changes Requested
Headers show

Commit Message

Rafał Miłecki June 1, 2016, 6:33 a.m. UTC
Some drivers (e.g. brcmfmac) may not support deleting virtual
interfaces. In such cases we can start AP interfaces once only. On next
tries be should try to use existing interfaces as a fallback.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
 src/ap/hostapd.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Comments

Johannes Berg June 1, 2016, 7:08 a.m. UTC | #1
On Wed, 2016-06-01 at 08:33 +0200, Rafał Miłecki wrote:
> Some drivers (e.g. brcmfmac) may not support deleting virtual
> interfaces. In such cases we can start AP interfaces once only. On
> next tries be should try to use existing interfaces as a fallback.
> 
Why don't we just consider that a driver bug if you can create, but not
remove, interfaces?

johannes
Rafał Miłecki June 1, 2016, 7:37 a.m. UTC | #2
On 1 June 2016 at 09:08, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Wed, 2016-06-01 at 08:33 +0200, Rafał Miłecki wrote:
>> Some drivers (e.g. brcmfmac) may not support deleting virtual
>> interfaces. In such cases we can start AP interfaces once only. On
>> next tries be should try to use existing interfaces as a fallback.
>>
> Why don't we just consider that a driver bug if you can create, but not
> remove, interfaces?

Ideally we should have just brcmfmac fixed. Unfortunately I have
doubts if we can hope for that. Broadcom added support for multiple
BSSes in late 2014 and since then it was in a kind of poor state
(buggy). It easily goes into some inconsistent & unreliable state. I
think Broadcom even released BCM43602 firmware with some special
modifications to make it work with brcmfmac.

I'll see again if there is anything I can do about that, I'll get back
to you in few days.
diff mbox

Patch

diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
index 42c1aaa..4e0de0c 100644
--- a/src/ap/hostapd.c
+++ b/src/ap/hostapd.c
@@ -936,16 +936,24 @@  static int hostapd_setup_bss(struct hostapd_data *hapd, int first)
 			} while (mac_in_conf(hapd->iconf, hapd->own_addr));
 		}
 
-		hapd->interface_added = 1;
 		if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS,
 				   conf->iface, addr, hapd,
 				   &hapd->drv_priv, force_ifname, if_addr,
 				   conf->bridge[0] ? conf->bridge : NULL,
 				   first == -1)) {
-			wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID="
-				   MACSTR ")", MAC2STR(hapd->own_addr));
-			hapd->interface_added = 0;
-			return -1;
+			/* Try to use existing interface */
+			if (hostapd_if_add(hapd->iface->bss[0], WPA_IF_AP_BSS,
+					   conf->iface, hapd->own_addr, hapd,
+					   &hapd->drv_priv, force_ifname,
+					   if_addr,
+					   conf->bridge[0] ? conf->bridge : NULL,
+					   1)) {
+				wpa_printf(MSG_ERROR, "Failed to add BSS (BSSID="
+					   MACSTR ")", MAC2STR(hapd->own_addr));
+				return -1;
+			}
+		} else {
+			hapd->interface_added = 1;
 		}
 
 		if (!addr)