blob: 27d4416c4a4f88ee71070da8b389454286995cac [file] [log] [blame]
developer27057f82023-07-10 17:23:13 +08001From 9444dedd3f8bd97887c9cf274587b4c76f94d621 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
developer27057f82023-07-10 17:23:13 +08004Subject: [PATCH 26/32] hostapd: mtk: avoid setting beacon after wpa_supplicant
developer683be522023-05-11 14:24:50 +08005 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 ++++
developer27057f82023-07-10 17:23:13 +080014 src/ap/beacon.c | 4 ++++
developer683be522023-05-11 14:24:50 +080015 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 +
developer27057f82023-07-10 17:23:13 +080019 6 files changed, 16 insertions(+), 2 deletions(-)
developer683be522023-05-11 14:24:50 +080020
21diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c
developer27057f82023-07-10 17:23:13 +080022index 9989a04ce..4952bef89 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
developer27057f82023-07-10 17:23:13 +080042index f26e5254c..24144feff 100644
developer683be522023-05-11 14:24:50 +080043--- a/src/ap/beacon.c
44+++ b/src/ap/beacon.c
developer27057f82023-07-10 17:23:13 +080045@@ -2247,6 +2247,8 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd)
developer683be522023-05-11 14:24:50 +080046
developer27057f82023-07-10 17:23:13 +080047 for (i = 0; i < other->num_bss; i++) {
48 if (other->bss[i] && other->bss[i]->started)
49+ if (other->bss[i] && other->bss[i]->started &&
50+ !other->bss[i]->stopped_by_supplicant)
51 __ieee802_11_set_beacon(other->bss[i]);
developer683be522023-05-11 14:24:50 +080052 }
53 }
developer27057f82023-07-10 17:23:13 +080054@@ -2262,6 +2264,7 @@ int ieee802_11_set_beacons(struct hostapd_iface *iface)
developer683be522023-05-11 14:24:50 +080055
56 for (i = 0; i < iface->num_bss; i++) {
57 if (iface->bss[i]->started &&
58+ !iface->bss[i]->stopped_by_supplicant &&
59 ieee802_11_set_beacon(iface->bss[i]) < 0)
60 ret = -1;
61 }
developer27057f82023-07-10 17:23:13 +080062@@ -2278,6 +2281,7 @@ int ieee802_11_update_beacons(struct hostapd_iface *iface)
developer683be522023-05-11 14:24:50 +080063
64 for (i = 0; i < iface->num_bss; i++) {
65 if (iface->bss[i]->beacon_set_done && iface->bss[i]->started &&
66+ !iface->bss[i]->stopped_by_supplicant &&
67 ieee802_11_set_beacon(iface->bss[i]) < 0)
68 ret = -1;
69 }
70diff --git a/src/ap/bss_load.c b/src/ap/bss_load.c
developer27057f82023-07-10 17:23:13 +080071index 725d3cd34..ae5552140 100644
developer683be522023-05-11 14:24:50 +080072--- a/src/ap/bss_load.c
73+++ b/src/ap/bss_load.c
74@@ -46,7 +46,8 @@ static void update_channel_utilization(void *eloop_data, void *user_data)
75 int err;
76 struct hostapd_iface *iface = hapd->iface;
77
78- if (!(hapd->beacon_set_done && hapd->started))
79+ if (!(hapd->beacon_set_done && hapd->started &&
80+ !hapd->stopped_by_supplicant))
81 return;
82
83 err = hostapd_drv_get_survey(hapd, hapd->iface->freq);
84diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c
developer27057f82023-07-10 17:23:13 +080085index aab8a4665..d52188bb7 100644
developer683be522023-05-11 14:24:50 +080086--- a/src/ap/ctrl_iface_ap.c
87+++ b/src/ap/ctrl_iface_ap.c
developer27057f82023-07-10 17:23:13 +080088@@ -1028,8 +1028,10 @@ int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd)
developer683be522023-05-11 14:24:50 +080089 struct hostapd_iface *iface = hapd->iface;
90 int i;
91
92- for (i = 0; i < iface->num_bss; i++)
93+ for (i = 0; i < iface->num_bss; i++){
94+ iface->bss[i]->stopped_by_supplicant = 1;
95 hostapd_drv_stop_ap(iface->bss[i]);
96+ }
97
98 return 0;
99 }
100diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c
developer27057f82023-07-10 17:23:13 +0800101index abadd1ad0..6e6ae77d7 100644
developer683be522023-05-11 14:24:50 +0800102--- a/src/ap/hostapd.c
103+++ b/src/ap/hostapd.c
developer27057f82023-07-10 17:23:13 +0800104@@ -508,6 +508,7 @@ void hostapd_free_hapd_data(struct hostapd_data *hapd)
developer683be522023-05-11 14:24:50 +0800105 }
106 hapd->started = 0;
107 hapd->beacon_set_done = 0;
108+ hapd->stopped_by_supplicant = 0;
109
110 wpa_printf(MSG_DEBUG, "%s(%s)", __func__, hapd->conf->iface);
111 hostapd_ubus_free_bss(hapd);
developer27057f82023-07-10 17:23:13 +0800112@@ -1316,6 +1317,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first,
developer683be522023-05-11 14:24:50 +0800113 return -1;
114 }
115 hapd->started = 1;
116+ hapd->stopped_by_supplicant = 0;
117
118 if (!first || first == -1) {
119 u8 *addr = hapd->own_addr;
120diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h
developer27057f82023-07-10 17:23:13 +0800121index 072205c3c..4f1f98824 100644
developer683be522023-05-11 14:24:50 +0800122--- a/src/ap/hostapd.h
123+++ b/src/ap/hostapd.h
developer27057f82023-07-10 17:23:13 +0800124@@ -191,6 +191,7 @@ struct hostapd_data {
developer683be522023-05-11 14:24:50 +0800125 unsigned int started:1;
126 unsigned int disabled:1;
127 unsigned int reenable_beacon:1;
128+ unsigned int stopped_by_supplicant:1;
129
130 u8 own_addr[ETH_ALEN];
developer27057f82023-07-10 17:23:13 +0800131 u8 mld_addr[ETH_ALEN];
developer683be522023-05-11 14:24:50 +0800132--
developer27057f82023-07-10 17:23:13 +08001332.39.2
developer683be522023-05-11 14:24:50 +0800134