blob: 87e286e5af5d9cadf3576380c7f42b77a4fe3d19 [file] [log] [blame]
developer683be522023-05-11 14:24:50 +08001From 1d5dfbffb750a0de15622265dc709524a330f059 Mon Sep 17 00:00:00 2001
2From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Fri, 12 May 2023 05:21:28 +0800
4Subject: [PATCH 26/28] hostapd: mtk: avoid setting beacon after wpa_supplicant
5 stop the AP
6
7Add a new variable 'stopped_by_supplicant' to indicate the AP
8interface is currently stopped by co-locating STA interface.
9After the STA interface finishes association with some other APs, it
10will reload the co-locating AP interfaces and marks the
11'stopped_by_supplicant' as 0.
12---
13 hostapd/ctrl_iface.c | 4 ++++
14 src/ap/beacon.c | 5 ++++-
15 src/ap/bss_load.c | 3 ++-
16 src/ap/ctrl_iface_ap.c | 4 +++-
17 src/ap/hostapd.c | 2 ++
18 src/ap/hostapd.h | 1 +
19 6 files changed, 16 insertions(+), 3 deletions(-)
20
21diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
22index 234b800..06d8345 100644
23--- a/hostapd/ctrl_iface.c
24+++ b/hostapd/ctrl_iface.c
25@@ -194,11 +194,15 @@ static int hostapd_ctrl_iface_update(struct hostapd_data *hapd, char *txt)
26 {
27 struct hostapd_config * (*config_read_cb)(const char *config_fname);
28 struct hostapd_iface *iface = hapd->iface;
29+ size_t j;
30
31 config_read_cb = iface->interfaces->config_read_cb;
32 iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read;
33 reload_opts = txt;
34
35+ for (j = 0; j < iface->num_bss; j++)
36+ iface->bss[j]->stopped_by_supplicant = 0;
37+
38 hostapd_reload_config(iface, 0);
39
40 iface->interfaces->config_read_cb = config_read_cb;
41diff --git a/src/ap/beacon.c b/src/ap/beacon.c
42index ddb5d03..ffa27f3 100644
43--- a/src/ap/beacon.c
44+++ b/src/ap/beacon.c
45@@ -2169,7 +2169,8 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd)
46 continue;
47
48 for (i = 0; i < colocated->num_bss; i++) {
49- if (colocated->bss[i] && colocated->bss[i]->started)
50+ if (colocated->bss[i] && colocated->bss[i]->started &&
51+ !colocated->bss[i]->stopped_by_supplicant)
52 __ieee802_11_set_beacon(colocated->bss[i]);
53 }
54 }
55@@ -2185,6 +2186,7 @@ int ieee802_11_set_beacons(struct hostapd_iface *iface)
56
57 for (i = 0; i < iface->num_bss; i++) {
58 if (iface->bss[i]->started &&
59+ !iface->bss[i]->stopped_by_supplicant &&
60 ieee802_11_set_beacon(iface->bss[i]) < 0)
61 ret = -1;
62 }
63@@ -2201,6 +2203,7 @@ int ieee802_11_update_beacons(struct hostapd_iface *iface)
64
65 for (i = 0; i < iface->num_bss; i++) {
66 if (iface->bss[i]->beacon_set_done && iface->bss[i]->started &&
67+ !iface->bss[i]->stopped_by_supplicant &&
68 ieee802_11_set_beacon(iface->bss[i]) < 0)
69 ret = -1;
70 }
71diff --git a/src/ap/bss_load.c b/src/ap/bss_load.c
72index 725d3cd..ae55521 100644
73--- a/src/ap/bss_load.c
74+++ b/src/ap/bss_load.c
75@@ -46,7 +46,8 @@ static void update_channel_utilization(void *eloop_data, void *user_data)
76 int err;
77 struct hostapd_iface *iface = hapd->iface;
78
79- if (!(hapd->beacon_set_done && hapd->started))
80+ if (!(hapd->beacon_set_done && hapd->started &&
81+ !hapd->stopped_by_supplicant))
82 return;
83
84 err = hostapd_drv_get_survey(hapd, hapd->iface->freq);
85diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
86index fed5473..2a8ac9d 100644
87--- a/src/ap/ctrl_iface_ap.c
88+++ b/src/ap/ctrl_iface_ap.c
89@@ -1013,8 +1013,10 @@ int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd)
90 struct hostapd_iface *iface = hapd->iface;
91 int i;
92
93- for (i = 0; i < iface->num_bss; i++)
94+ for (i = 0; i < iface->num_bss; i++){
95+ iface->bss[i]->stopped_by_supplicant = 1;
96 hostapd_drv_stop_ap(iface->bss[i]);
97+ }
98
99 return 0;
100 }
101diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
102index 88eb984..05ddb6f 100644
103--- a/src/ap/hostapd.c
104+++ b/src/ap/hostapd.c
105@@ -488,6 +488,7 @@ void hostapd_free_hapd_data(struct hostapd_data *hapd)
106 }
107 hapd->started = 0;
108 hapd->beacon_set_done = 0;
109+ hapd->stopped_by_supplicant = 0;
110
111 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
112 hostapd_ubus_free_bss(hapd);
113@@ -1290,6 +1291,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first,
114 return -1;
115 }
116 hapd->started = 1;
117+ hapd->stopped_by_supplicant = 0;
118
119 if (!first || first == -1) {
120 u8 *addr = hapd->own_addr;
121diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
122index c0b3a08..fb8566a 100644
123--- a/src/ap/hostapd.h
124+++ b/src/ap/hostapd.h
125@@ -190,6 +190,7 @@ struct hostapd_data {
126 unsigned int started:1;
127 unsigned int disabled:1;
128 unsigned int reenable_beacon:1;
129+ unsigned int stopped_by_supplicant:1;
130
131 u8 own_addr[ETH_ALEN];
132
133--
1342.18.0
135