developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 1 | --- a/hostapd/config_file.c |
| 2 | +++ b/hostapd/config_file.c |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 3 | @@ -2420,6 +2420,8 @@ static int hostapd_config_fill(struct ho |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 4 | bss->isolate = atoi(pos); |
| 5 | } else if (os_strcmp(buf, "ap_max_inactivity") == 0) { |
| 6 | bss->ap_max_inactivity = atoi(pos); |
| 7 | + } else if (os_strcmp(buf, "config_id") == 0) { |
| 8 | + bss->config_id = os_strdup(pos); |
| 9 | } else if (os_strcmp(buf, "skip_inactivity_poll") == 0) { |
| 10 | bss->skip_inactivity_poll = atoi(pos); |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 11 | } else if (os_strcmp(buf, "config_id") == 0) { |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 12 | @@ -3130,6 +3132,8 @@ static int hostapd_config_fill(struct ho |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 13 | } |
| 14 | } else if (os_strcmp(buf, "acs_exclude_dfs") == 0) { |
| 15 | conf->acs_exclude_dfs = atoi(pos); |
| 16 | + } else if (os_strcmp(buf, "radio_config_id") == 0) { |
| 17 | + conf->config_id = os_strdup(pos); |
| 18 | } else if (os_strcmp(buf, "op_class") == 0) { |
| 19 | conf->op_class = atoi(pos); |
| 20 | } else if (os_strcmp(buf, "channel") == 0) { |
| 21 | --- a/src/ap/ap_config.c |
| 22 | +++ b/src/ap/ap_config.c |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 23 | @@ -998,6 +998,7 @@ void hostapd_config_free(struct hostapd_ |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 24 | |
| 25 | for (i = 0; i < conf->num_bss; i++) |
| 26 | hostapd_config_free_bss(conf->bss[i]); |
| 27 | + os_free(conf->config_id); |
| 28 | os_free(conf->bss); |
| 29 | os_free(conf->supported_rates); |
| 30 | os_free(conf->basic_rates); |
| 31 | --- a/src/ap/ap_config.h |
| 32 | +++ b/src/ap/ap_config.h |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 33 | @@ -998,6 +998,7 @@ struct eht_phy_capabilities_info { |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 34 | struct hostapd_config { |
| 35 | struct hostapd_bss_config **bss, *last_bss; |
| 36 | size_t num_bss; |
| 37 | + char *config_id; |
| 38 | |
| 39 | u16 beacon_int; |
| 40 | int rts_threshold; |
| 41 | --- a/src/ap/hostapd.c |
| 42 | +++ b/src/ap/hostapd.c |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 43 | @@ -255,6 +255,10 @@ static int hostapd_iface_conf_changed(st |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 44 | { |
| 45 | size_t i; |
| 46 | |
| 47 | + if (newconf->config_id != oldconf->config_id) |
| 48 | + if (strcmp(newconf->config_id, oldconf->config_id)) |
| 49 | + return 1; |
| 50 | + |
| 51 | if (newconf->num_bss != oldconf->num_bss) |
| 52 | return 1; |
| 53 | |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 54 | @@ -268,7 +272,7 @@ static int hostapd_iface_conf_changed(st |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | |
| 58 | -int hostapd_reload_config(struct hostapd_iface *iface) |
| 59 | +int hostapd_reload_config(struct hostapd_iface *iface, int reconf) |
| 60 | { |
| 61 | struct hapd_interfaces *interfaces = iface->interfaces; |
| 62 | struct hostapd_data *hapd = iface->bss[0]; |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 63 | @@ -296,6 +300,9 @@ int hostapd_reload_config(struct hostapd |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 64 | char *fname; |
| 65 | int res; |
| 66 | |
| 67 | + if (reconf) |
| 68 | + return -1; |
| 69 | + |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 70 | hostapd_clear_old(iface); |
| 71 | |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 72 | wpa_printf(MSG_DEBUG, |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 73 | @@ -322,6 +329,24 @@ int hostapd_reload_config(struct hostapd |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 74 | wpa_printf(MSG_ERROR, |
| 75 | "Failed to enable interface on config reload"); |
| 76 | return res; |
| 77 | + } else { |
| 78 | + for (j = 0; j < iface->num_bss; j++) { |
| 79 | + hapd = iface->bss[j]; |
| 80 | + if (!hapd->config_id || strcmp(hapd->config_id, newconf->bss[j]->config_id)) { |
| 81 | + hostapd_flush_old_stations(iface->bss[j], |
| 82 | + WLAN_REASON_PREV_AUTH_NOT_VALID); |
| 83 | +#ifdef CONFIG_WEP |
| 84 | + hostapd_broadcast_wep_clear(iface->bss[j]); |
| 85 | +#endif |
| 86 | + |
| 87 | +#ifndef CONFIG_NO_RADIUS |
| 88 | + /* TODO: update dynamic data based on changed configuration |
| 89 | + * items (e.g., open/close sockets, etc.) */ |
| 90 | + radius_client_flush(iface->bss[j]->radius, 0); |
| 91 | +#endif /* CONFIG_NO_RADIUS */ |
| 92 | + wpa_printf(MSG_INFO, "bss %zu changed", j); |
| 93 | + } |
| 94 | + } |
| 95 | } |
| 96 | iface->conf = newconf; |
| 97 | |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 98 | @@ -338,6 +363,12 @@ int hostapd_reload_config(struct hostapd |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 99 | |
| 100 | for (j = 0; j < iface->num_bss; j++) { |
| 101 | hapd = iface->bss[j]; |
| 102 | + if (hapd->config_id) { |
| 103 | + os_free(hapd->config_id); |
| 104 | + hapd->config_id = NULL; |
| 105 | + } |
| 106 | + if (newconf->bss[j]->config_id) |
| 107 | + hapd->config_id = strdup(newconf->bss[j]->config_id); |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 108 | if (!hapd->conf->config_id || !newconf->bss[j]->config_id || |
| 109 | os_strcmp(hapd->conf->config_id, |
| 110 | newconf->bss[j]->config_id) != 0) |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 111 | @@ -2700,6 +2731,10 @@ hostapd_alloc_bss_data(struct hostapd_if |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 112 | hapd->iconf = conf; |
| 113 | hapd->conf = bss; |
| 114 | hapd->iface = hapd_iface; |
| 115 | + if (bss && bss->config_id) |
| 116 | + hapd->config_id = strdup(bss->config_id); |
| 117 | + else |
| 118 | + hapd->config_id = NULL; |
| 119 | if (conf) |
| 120 | hapd->driver = conf->driver; |
| 121 | hapd->ctrl_sock = -1; |
| 122 | --- a/src/ap/hostapd.h |
| 123 | +++ b/src/ap/hostapd.h |
| 124 | @@ -47,7 +47,7 @@ struct mesh_conf; |
| 125 | struct hostapd_iface; |
| 126 | |
| 127 | struct hapd_interfaces { |
| 128 | - int (*reload_config)(struct hostapd_iface *iface); |
| 129 | + int (*reload_config)(struct hostapd_iface *iface, int reconf); |
| 130 | struct hostapd_config * (*config_read_cb)(const char *config_fname); |
| 131 | int (*ctrl_iface_init)(struct hostapd_data *hapd); |
| 132 | void (*ctrl_iface_deinit)(struct hostapd_data *hapd); |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 133 | @@ -186,6 +186,7 @@ struct hostapd_data { |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 134 | struct hostapd_config *iconf; |
| 135 | struct hostapd_bss_config *conf; |
| 136 | struct hostapd_ubus_bss ubus; |
| 137 | + char *config_id; |
| 138 | int interface_added; /* virtual interface added for this BSS */ |
| 139 | unsigned int started:1; |
| 140 | unsigned int disabled:1; |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 141 | @@ -689,7 +690,7 @@ struct hostapd_iface { |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 142 | int hostapd_for_each_interface(struct hapd_interfaces *interfaces, |
| 143 | int (*cb)(struct hostapd_iface *iface, |
| 144 | void *ctx), void *ctx); |
| 145 | -int hostapd_reload_config(struct hostapd_iface *iface); |
| 146 | +int hostapd_reload_config(struct hostapd_iface *iface, int reconf); |
| 147 | void hostapd_reconfig_encryption(struct hostapd_data *hapd); |
| 148 | struct hostapd_data * |
| 149 | hostapd_alloc_bss_data(struct hostapd_iface *hapd_iface, |
| 150 | --- a/src/drivers/driver_nl80211.c |
| 151 | +++ b/src/drivers/driver_nl80211.c |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 152 | @@ -5322,6 +5322,9 @@ static int wpa_driver_nl80211_set_ap(voi |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 153 | if (ret) { |
| 154 | wpa_printf(MSG_DEBUG, "nl80211: Beacon set failed: %d (%s)", |
| 155 | ret, strerror(-ret)); |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 156 | + if (!bss->flink->beacon_set) |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 157 | + ret = 0; |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 158 | + bss->flink->beacon_set = 0; |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 159 | } else { |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 160 | link->beacon_set = 1; |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 161 | nl80211_set_bss(bss, params->cts_protect, params->preamble, |
| 162 | --- a/hostapd/ctrl_iface.c |
| 163 | +++ b/hostapd/ctrl_iface.c |
developer | 505c943 | 2023-05-12 18:58:17 +0800 | [diff] [blame] | 164 | @@ -187,7 +187,7 @@ static int hostapd_ctrl_iface_update(str |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 165 | iface->interfaces->config_read_cb = hostapd_ctrl_iface_config_read; |
| 166 | reload_opts = txt; |
| 167 | |
| 168 | - hostapd_reload_config(iface); |
| 169 | + hostapd_reload_config(iface, 0); |
| 170 | |
| 171 | iface->interfaces->config_read_cb = config_read_cb; |
| 172 | } |
| 173 | --- a/hostapd/main.c |
| 174 | +++ b/hostapd/main.c |
developer | 8bff647 | 2023-07-17 11:11:44 +0800 | [diff] [blame] | 175 | @@ -410,7 +410,7 @@ static void handle_term(int sig, void *s |
developer | 29c4d2d | 2022-12-26 19:41:22 +0800 | [diff] [blame] | 176 | |
| 177 | static int handle_reload_iface(struct hostapd_iface *iface, void *ctx) |
| 178 | { |
| 179 | - if (hostapd_reload_config(iface) < 0) { |
| 180 | + if (hostapd_reload_config(iface, 0) < 0) { |
| 181 | wpa_printf(MSG_WARNING, "Failed to read new configuration " |
| 182 | "file - continuing with old."); |
| 183 | } |
| 184 | --- a/src/ap/wps_hostapd.c |
| 185 | +++ b/src/ap/wps_hostapd.c |
| 186 | @@ -315,7 +315,7 @@ static void wps_reload_config(void *eloo |
| 187 | |
| 188 | wpa_printf(MSG_DEBUG, "WPS: Reload configuration data"); |
| 189 | if (iface->interfaces == NULL || |
| 190 | - iface->interfaces->reload_config(iface) < 0) { |
| 191 | + iface->interfaces->reload_config(iface, 1) < 0) { |
| 192 | wpa_printf(MSG_WARNING, "WPS: Failed to reload the updated " |
| 193 | "configuration"); |
| 194 | } |