Files
wlan-ap/feeds/wifi-ax/hostapd/patches/900-max-sta-limit.patch
John Crispin 65cdb70c3b hostapd: add per phy max sta count
Normally max_num_sta is per BSS. This patch allows setting a pre IFACE max.

Signed-off-by: John Crispin <john@phrozen.org>
2021-02-22 13:54:42 -05:00

101 lines
3.9 KiB
Diff

Index: hostapd-2020-06-08-5a8b3662/hostapd/config_file.c
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/hostapd/config_file.c
+++ hostapd-2020-06-08-5a8b3662/hostapd/config_file.c
@@ -2909,6 +2909,11 @@ static int hostapd_config_fill(struct ho
line);
return 1;
}
+ } else if (os_strcmp(buf, "global_max_num_sta") == 0) {
+ conf->global_max_num_sta = atoi(pos);
+ if (conf->global_max_num_sta < 0 ||
+ conf->global_max_num_sta > MAX_STA_COUNT)
+ conf->global_max_num_sta = MAX_STA_COUNT;
} else if (os_strcmp(buf, "max_num_sta") == 0) {
bss->max_num_sta = atoi(pos);
if (bss->max_num_sta < 0 ||
Index: hostapd-2020-06-08-5a8b3662/src/ap/ap_config.c
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/src/ap/ap_config.c
+++ hostapd-2020-06-08-5a8b3662/src/ap/ap_config.c
@@ -228,6 +228,8 @@ struct hostapd_config * hostapd_config_d
conf->num_bss = 1;
+ conf->global_max_num_sta = 0;
+
conf->beacon_int = 100;
conf->rts_threshold = -2; /* use driver default: 2347 */
conf->fragm_threshold = -2; /* user driver default: 2346 */
Index: hostapd-2020-06-08-5a8b3662/src/ap/ap_config.h
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/src/ap/ap_config.h
+++ hostapd-2020-06-08-5a8b3662/src/ap/ap_config.h
@@ -1069,6 +1069,7 @@ struct hostapd_config {
#define AIRTIME_MODE_MAX (__AIRTIME_MODE_MAX - 1)
#endif /* CONFIG_AIRTIME_POLICY */
char *config_id;
+ int global_max_num_sta;
};
Index: hostapd-2020-06-08-5a8b3662/src/ap/beacon.c
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/src/ap/beacon.c
+++ hostapd-2020-06-08-5a8b3662/src/ap/beacon.c
@@ -1030,7 +1030,8 @@ void handle_probe_req(struct hostapd_dat
if (hapd->conf->no_probe_resp_if_max_sta &&
is_multicast_ether_addr(mgmt->da) &&
is_multicast_ether_addr(mgmt->bssid) &&
- hapd->num_sta >= hapd->conf->max_num_sta &&
+ hapd_check_max_sta(hapd) &&
+// hapd->num_sta >= hapd->conf->max_num_sta &&
!ap_get_sta(hapd, mgmt->sa)) {
wpa_printf(MSG_MSGDUMP, "%s: Ignore Probe Request from " MACSTR
" since no room for additional STA",
Index: hostapd-2020-06-08-5a8b3662/src/ap/sta_info.c
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/src/ap/sta_info.c
+++ hostapd-2020-06-08-5a8b3662/src/ap/sta_info.c
@@ -705,7 +705,8 @@ struct sta_info * ap_sta_add(struct host
return sta;
wpa_printf(MSG_DEBUG, " New STA");
- if (hapd->num_sta >= hapd->conf->max_num_sta) {
+ if (hapd_check_max_sta(hapd)) {
+// if (hapd->num_sta >= hapd->conf->max_num_sta) {
/* FIX: might try to remove some old STAs first? */
wpa_printf(MSG_DEBUG, "no more room for new STAs (%d/%d)",
hapd->num_sta, hapd->conf->max_num_sta);
Index: hostapd-2020-06-08-5a8b3662/src/ap/hostapd.c
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/src/ap/hostapd.c
+++ hostapd-2020-06-08-5a8b3662/src/ap/hostapd.c
@@ -3779,3 +3779,15 @@ void hostapd_ocv_check_csa_sa_query(void
}
}
#endif /* CONFIG_OCV */
+
+int hapd_check_max_sta(struct hostapd_data *hapd)
+{
+ int cnt = 0, i;
+
+ if (!hapd->iconf->global_max_num_sta)
+ return hapd->num_sta >= hapd->conf->max_num_sta;
+
+ for (i = 0; i < hapd->iface->num_bss; i++)
+ cnt += hapd->iface->bss[i]->num_sta;
+ return cnt >= hapd->iconf->global_max_num_sta;
+}
Index: hostapd-2020-06-08-5a8b3662/src/ap/hostapd.h
===================================================================
--- hostapd-2020-06-08-5a8b3662.orig/src/ap/hostapd.h
+++ hostapd-2020-06-08-5a8b3662/src/ap/hostapd.h
@@ -693,4 +693,6 @@ void fst_hostapd_fill_iface_obj(struct h
struct fst_wpa_obj *iface_obj);
#endif /* CONFIG_FST */
+int hapd_check_max_sta(struct hostapd_data *hapd);
+
#endif /* HOSTAPD_H */