developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 1 | From 9444dedd3f8bd97887c9cf274587b4c76f94d621 Mon Sep 17 00:00:00 2001 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 2 | From: Evelyn Tsai <evelyn.tsai@mediatek.com> |
| 3 | Date: Fri, 12 May 2023 05:21:28 +0800 |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 4 | Subject: [PATCH 26/32] hostapd: mtk: avoid setting beacon after wpa_supplicant |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 5 | stop the AP |
| 6 | |
| 7 | Add a new variable 'stopped_by_supplicant' to indicate the AP |
| 8 | interface is currently stopped by co-locating STA interface. |
| 9 | After the STA interface finishes association with some other APs, it |
| 10 | will reload the co-locating AP interfaces and marks the |
| 11 | 'stopped_by_supplicant' as 0. |
| 12 | --- |
| 13 | hostapd/ctrl_iface.c | 4 ++++ |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 14 | src/ap/beacon.c | 4 ++++ |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 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 + |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 19 | 6 files changed, 16 insertions(+), 2 deletions(-) |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 20 | |
| 21 | diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 22 | index 9989a04ce..4952bef89 100644 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 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; |
| 41 | diff --git a/src/ap/beacon.c b/src/ap/beacon.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 42 | index f26e5254c..24144feff 100644 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 43 | --- a/src/ap/beacon.c |
| 44 | +++ b/src/ap/beacon.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 45 | @@ -2247,6 +2247,8 @@ int ieee802_11_set_beacon(struct hostapd_data *hapd) |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 46 | |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 47 | 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]); |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 52 | } |
| 53 | } |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 54 | @@ -2262,6 +2264,7 @@ int ieee802_11_set_beacons(struct hostapd_iface *iface) |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 55 | |
| 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 | } |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 62 | @@ -2278,6 +2281,7 @@ int ieee802_11_update_beacons(struct hostapd_iface *iface) |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 63 | |
| 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 | } |
| 70 | diff --git a/src/ap/bss_load.c b/src/ap/bss_load.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 71 | index 725d3cd34..ae5552140 100644 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 72 | --- 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); |
| 84 | diff --git a/src/ap/ctrl_iface_ap.c b/src/ap/ctrl_iface_ap.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 85 | index aab8a4665..d52188bb7 100644 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 86 | --- a/src/ap/ctrl_iface_ap.c |
| 87 | +++ b/src/ap/ctrl_iface_ap.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 88 | @@ -1028,8 +1028,10 @@ int hostapd_ctrl_iface_stop_ap(struct hostapd_data *hapd) |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 89 | 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 | } |
| 100 | diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 101 | index abadd1ad0..6e6ae77d7 100644 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 102 | --- a/src/ap/hostapd.c |
| 103 | +++ b/src/ap/hostapd.c |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 104 | @@ -508,6 +508,7 @@ void hostapd_free_hapd_data(struct hostapd_data *hapd) |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 105 | } |
| 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); |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 112 | @@ -1316,6 +1317,7 @@ static int hostapd_setup_bss(struct hostapd_data *hapd, int first, |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 113 | 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; |
| 120 | diff --git a/src/ap/hostapd.h b/src/ap/hostapd.h |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 121 | index 072205c3c..4f1f98824 100644 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 122 | --- a/src/ap/hostapd.h |
| 123 | +++ b/src/ap/hostapd.h |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 124 | @@ -191,6 +191,7 @@ struct hostapd_data { |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 125 | 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]; |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 131 | u8 mld_addr[ETH_ALEN]; |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 132 | -- |
developer | 27057f8 | 2023-07-10 17:23:13 +0800 | [diff] [blame] | 133 | 2.39.2 |
developer | 683be52 | 2023-05-11 14:24:50 +0800 | [diff] [blame] | 134 | |