blob: dbd716311b5d7296e8487432718963eaa9eb3f85 [file] [log] [blame]
developerbad62872023-08-08 14:41:14 +08001From 67e2363c4875dd918418dd84b43f86041db690c7 Mon Sep 17 00:00:00 2001
developer683be522023-05-11 14:24:50 +08002From: Evelyn Tsai <evelyn.tsai@mediatek.com>
3Date: Fri, 12 May 2023 05:21:28 +0800
developer636e5232023-07-17 10:26:43 +08004Subject: [PATCH] hostapd: mtk: Avoid setting beacon after wpa_supplicant stop
5 the AP
developer683be522023-05-11 14:24:50 +08006
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---
developer636e5232023-07-17 10:26:43 +080013 hostapd/ctrl_iface.c | 4 ++++
14 src/ap/beacon.c | 5 ++++-
15 src/ap/bss_load.c | 10 +++++++---
16 src/ap/ctrl_iface_ap.c | 4 +++-
17 src/ap/hostapd.c | 4 +++-
18 src/ap/hostapd.h | 1 +
19 6 files changed, 22 insertions(+), 6 deletions(-)
developer683be522023-05-11 14:24:50 +080020
21diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
developerbad62872023-08-08 14:41:14 +080022index e575c37d1..0e352c5c7 100644
developer683be522023-05-11 14:24:50 +080023--- 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
developerbad62872023-08-08 14:41:14 +080042index f26e5254c..1aaeaa8e4 100644
developer683be522023-05-11 14:24:50 +080043--- a/src/ap/beacon.c
44+++ b/src/ap/beacon.c
developer636e5232023-07-17 10:26:43 +080045@@ -2246,7 +2246,8 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd)
46 continue;
developer683be522023-05-11 14:24:50 +080047
developer27057f82023-07-10 17:23:13 +080048 for (i = 0; i < other->num_bss; i++) {
developer636e5232023-07-17 10:26:43 +080049- if (other->bss[i] && other->bss[i]->started)
developer27057f82023-07-10 17:23:13 +080050+ if (other->bss[i] && other->bss[i]->started &&
51+ !other->bss[i]->stopped_by_supplicant)
52 __ieee802_11_set_beacon(other->bss[i]);
developer683be522023-05-11 14:24:50 +080053 }
54 }
developer636e5232023-07-17 10:26:43 +080055@@ -2262,6 +2263,7 @@ int ieee802_11_set_beacons(struct hostapd_iface *iface)
developer683be522023-05-11 14:24:50 +080056
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 }
developer636e5232023-07-17 10:26:43 +080063@@ -2278,6 +2280,7 @@ int ieee802_11_update_beacons(struct hostapd_iface *iface)
developer683be522023-05-11 14:24:50 +080064
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
developerbad62872023-08-08 14:41:14 +080072index 725d3cd34..78fd9d8ec 100644
developer683be522023-05-11 14:24:50 +080073--- a/src/ap/bss_load.c
74+++ b/src/ap/bss_load.c
developer636e5232023-07-17 10:26:43 +080075@@ -49,6 +49,9 @@ static void update_channel_utilization(void *eloop_data, void *user_data)
76 if (!(hapd->beacon_set_done && hapd->started))
developer683be522023-05-11 14:24:50 +080077 return;
78
developer636e5232023-07-17 10:26:43 +080079+ if(hapd->stopped_by_supplicant)
80+ goto skip_update;
81+
developer683be522023-05-11 14:24:50 +080082 err = hostapd_drv_get_survey(hapd, hapd->iface->freq);
developer636e5232023-07-17 10:26:43 +080083 if (err) {
84 wpa_printf(MSG_ERROR, "BSS Load: Failed to get survey data");
85@@ -57,9 +60,6 @@ static void update_channel_utilization(void *eloop_data, void *user_data)
86
87 ieee802_11_set_beacon(hapd);
88
89- if (get_bss_load_update_timeout(hapd, &sec, &usec) < 0)
90- return;
91-
92 if (hapd->conf->chan_util_avg_period) {
93 iface->chan_util_samples_sum += iface->channel_utilization;
94 iface->chan_util_num_sample_periods +=
95@@ -75,6 +75,10 @@ static void update_channel_utilization(void *eloop_data, void *user_data)
96 }
97 }
98
99+skip_update:
100+ if (get_bss_load_update_timeout(hapd, &sec, &usec) < 0)
101+ return;
102+
103 eloop_register_timeout(sec, usec, update_channel_utilization, hapd,
104 NULL);
105 }
developer683be522023-05-11 14:24:50 +0800106diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
developerbad62872023-08-08 14:41:14 +0800107index aab8a4665..d52188bb7 100644
developer683be522023-05-11 14:24:50 +0800108--- a/src/ap/ctrl_iface_ap.c
109+++ b/src/ap/ctrl_iface_ap.c
developer27057f82023-07-10 17:23:13 +0800110@@ -1028,8 +1028,10 @@ int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd)
developer683be522023-05-11 14:24:50 +0800111 struct hostapd_iface *iface = hapd->iface;
112 int i;
113
114- for (i = 0; i < iface->num_bss; i++)
115+ for (i = 0; i < iface->num_bss; i++){
116+ iface->bss[i]->stopped_by_supplicant = 1;
117 hostapd_drv_stop_ap(iface->bss[i]);
118+ }
119
120 return 0;
121 }
122diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
developerbad62872023-08-08 14:41:14 +0800123index 28e549b61..be75613c8 100644
developer683be522023-05-11 14:24:50 +0800124--- a/src/ap/hostapd.c
125+++ b/src/ap/hostapd.c
developerbad62872023-08-08 14:41:14 +0800126@@ -510,6 +510,7 @@ void hostapd_free_hapd_data(struct hostapd_data *hapd)
developer683be522023-05-11 14:24:50 +0800127 }
128 hapd->started = 0;
129 hapd->beacon_set_done = 0;
130+ hapd->stopped_by_supplicant = 0;
131
132 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
developerbad62872023-08-08 14:41:14 +0800133 hostapd_ucode_free_bss(hapd);
134@@ -1320,6 +1321,7 @@ int hostapd_setup_bss(struct hostapd_data *hapd, int first, bool start_beacon)
developer683be522023-05-11 14:24:50 +0800135 return -1;
136 }
137 hapd->started = 1;
138+ hapd->stopped_by_supplicant = 0;
139
140 if (!first || first == -1) {
141 u8 *addr = hapd->own_addr;
developerbad62872023-08-08 14:41:14 +0800142@@ -4289,7 +4291,7 @@ void hostapd_switch_color(struct hostapd_data *hapd, u64 bitmap)
developer636e5232023-07-17 10:26:43 +0800143 {
144 struct os_reltime now;
145
146- if (hapd->cca_in_progress)
147+ if (hapd->cca_in_progress || hapd->stopped_by_supplicant)
148 return;
149
150 if (os_get_reltime(&now))
developer683be522023-05-11 14:24:50 +0800151diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
developerbad62872023-08-08 14:41:14 +0800152index 5bd1537fe..435dbd027 100644
developer683be522023-05-11 14:24:50 +0800153--- a/src/ap/hostapd.h
154+++ b/src/ap/hostapd.h
developerbad62872023-08-08 14:41:14 +0800155@@ -197,6 +197,7 @@ struct hostapd_data {
developer683be522023-05-11 14:24:50 +0800156 unsigned int started:1;
157 unsigned int disabled:1;
158 unsigned int reenable_beacon:1;
159+ unsigned int stopped_by_supplicant:1;
160
161 u8 own_addr[ETH_ALEN];
developer27057f82023-07-10 17:23:13 +0800162 u8 mld_addr[ETH_ALEN];
developer683be522023-05-11 14:24:50 +0800163--
developerbad62872023-08-08 14:41:14 +08001642.39.2
developer683be522023-05-11 14:24:50 +0800165