From 6ed8eba00d9f9d34be9b4f80ec57b7f86eba6b5b Mon Sep 17 00:00:00 2001 From: Chaitanya Tata Date: Tue, 28 Nov 2023 00:33:58 +0530 Subject: [PATCH] Add an option to remove RRM and supported operating class indication Removing radio measurements and supported operating class indication might be needed to reduce binary size for a memory constrained system that does not need more advanced features. However, removing these is not recommended since they can help the AP manage the network and STA steering. By default this functionality is enabled. Signed-off-by: Chaitanya Tata --- src/ap/hostapd.c | 2 ++ src/ap/ieee802_11.c | 6 ++++++ wpa_supplicant/Android.mk | 13 ++++++++++--- wpa_supplicant/Makefile | 13 ++++++++++--- wpa_supplicant/android.config | 5 +++++ wpa_supplicant/ctrl_iface.c | 6 ++++++ wpa_supplicant/defconfig | 5 +++++ wpa_supplicant/dpp_supplicant.c | 4 ++++ wpa_supplicant/events.c | 6 ++++++ wpa_supplicant/scan.c | 2 ++ wpa_supplicant/sme.c | 2 ++ wpa_supplicant/wpa_supplicant.c | 6 ++++++ 12 files changed, 64 insertions(+), 6 deletions(-) diff --git a/src/ap/hostapd.c b/src/ap/hostapd.c index 0fcc4378c..fea3d8b3c 100644 --- a/src/ap/hostapd.c +++ b/src/ap/hostapd.c @@ -557,7 +557,9 @@ void hostapd_free_hapd_data(struct hostapd_data *hapd) hapd->setup_complete_cb = NULL; #endif /* CONFIG_MESH */ +#ifndef CONFIG_NO_RRM hostapd_clean_rrm(hapd); +#endif /* CONFIG_NO_RRM */ fils_hlp_deinit(hapd); #ifdef CONFIG_OCV diff --git a/src/ap/ieee802_11.c b/src/ap/ieee802_11.c index 701acaffd..e85b0635f 100644 --- a/src/ap/ieee802_11.c +++ b/src/ap/ieee802_11.c @@ -6067,9 +6067,11 @@ static int handle_action(struct hostapd_data *hapd, return 1; } break; +#ifndef CONFIG_NO_RRM case WLAN_ACTION_RADIO_MEASUREMENT: hostapd_handle_radio_measurement(hapd, (const u8 *) mgmt, len); return 1; +#endif /* CONFIG_NO_RRM */ } hostapd_logger(hapd, mgmt->sa, HOSTAPD_MODULE_IEEE80211, @@ -6674,7 +6676,9 @@ static void handle_action_cb(struct hostapd_data *hapd, size_t len, int ok) { struct sta_info *sta; +#ifndef CONFIG_NO_RRM const struct rrm_measurement_report_element *report; +#endif /* CONFIG_NO_RRM */ #ifdef CONFIG_DPP if (len >= IEEE80211_HDRLEN + 6 && @@ -6728,6 +6732,7 @@ static void handle_action_cb(struct hostapd_data *hapd, } #endif /* CONFIG_HS20 */ +#ifndef CONFIG_NO_RRM if (len < 24 + 5 + sizeof(*report)) return; report = (const struct rrm_measurement_report_element *) @@ -6738,6 +6743,7 @@ static void handle_action_cb(struct hostapd_data *hapd, report->len >= 3 && report->type == MEASURE_TYPE_BEACON) hostapd_rrm_beacon_req_tx_status(hapd, mgmt, len, ok); +#endif /* CONFIG_NO_RRM */ } diff --git a/wpa_supplicant/Android.mk b/wpa_supplicant/Android.mk index 5b0ca2e3b..83922621b 100644 --- a/wpa_supplicant/Android.mk +++ b/wpa_supplicant/Android.mk @@ -101,8 +101,6 @@ OBJS += src/utils/bitfield.c OBJS += src/utils/ip_addr.c OBJS += src/utils/crc32.c OBJS += wmm_ac.c -OBJS += op_classes.c -OBJS += rrm.c OBJS += twt.c OBJS += robust_av.c OBJS_p = wpa_passphrase.c @@ -423,6 +421,16 @@ ifdef CONFIG_NO_TKIP L_CFLAGS += -DCONFIG_NO_TKIP endif +ifdef CONFIG_NO_RRM +L_CFLAGS += -DCONFIG_NO_RRM +else +OBJS += rrm.c +ifdef CONFIG_AP +OBJS += src/ap/rrm.c +endif +OBJS += op_classes.c +endif + include $(LOCAL_PATH)/src/drivers/drivers.mk @@ -906,7 +914,6 @@ OBJS += src/ap/beacon.c OBJS += src/ap/bss_load.c OBJS += src/ap/eap_user_db.c OBJS += src/ap/neighbor_db.c -OBJS += src/ap/rrm.c OBJS += src/ap/ieee802_11_ht.c ifdef CONFIG_IEEE80211AC OBJS += src/ap/ieee802_11_vht.c diff --git a/wpa_supplicant/Makefile b/wpa_supplicant/Makefile index 8adbc3b41..2be4a5d76 100644 --- a/wpa_supplicant/Makefile +++ b/wpa_supplicant/Makefile @@ -111,8 +111,6 @@ OBJS += ../src/utils/wpabuf.o OBJS += ../src/utils/bitfield.o OBJS += ../src/utils/ip_addr.o OBJS += ../src/utils/crc32.o -OBJS += op_classes.o -OBJS += rrm.o OBJS += twt.o OBJS += robust_av.o OBJS_p = wpa_passphrase.o @@ -473,6 +471,16 @@ ifdef CONFIG_NO_LOAD_DYNAMIC_EAP CFLAGS += -DCONFIG_NO_LOAD_DYNAMIC_EAP endif +ifdef CONFIG_NO_RRM +CFLAGS += -DCONFIG_NO_RRM +else +OBJS += rrm.o +ifdef CONFIG_AP +OBJS += ../src/ap/rrm.o +endif +OBJS += op_classes.o +endif + include ../src/drivers/drivers.mak ifdef CONFIG_AP OBJS_d += $(DRV_BOTH_OBJS) @@ -979,7 +987,6 @@ OBJS += ../src/ap/beacon.o OBJS += ../src/ap/bss_load.o OBJS += ../src/ap/eap_user_db.o OBJS += ../src/ap/neighbor_db.o -OBJS += ../src/ap/rrm.o OBJS += ../src/ap/ieee802_11_ht.o ifdef CONFIG_IEEE80211AC OBJS += ../src/ap/ieee802_11_vht.o diff --git a/wpa_supplicant/android.config b/wpa_supplicant/android.config index 283f8eb0a..c2da557c9 100644 --- a/wpa_supplicant/android.config +++ b/wpa_supplicant/android.config @@ -542,4 +542,9 @@ CONFIG_WIFI_DISPLAY=y # be completely removed in a future release. CONFIG_WEP=y +# Disable support for Radio Measurement (IEEE 802.11k) and supported operating +# class indication. Removing these is not recommended since they can help the +# AP manage the network and STA steering. +#CONFIG_NO_RRM=y + include $(wildcard $(LOCAL_PATH)/android_config_*.inc) diff --git a/wpa_supplicant/ctrl_iface.c b/wpa_supplicant/ctrl_iface.c index b716fa774..a46c12a3f 100644 --- a/wpa_supplicant/ctrl_iface.c +++ b/wpa_supplicant/ctrl_iface.c @@ -10505,6 +10505,8 @@ static int wpas_ctrl_vendor_elem_remove(struct wpa_supplicant *wpa_s, char *cmd) } +#ifndef CONFIG_NO_RRM + static void wpas_ctrl_neighbor_rep_cb(void *ctx, struct wpabuf *neighbor_rep) { struct wpa_supplicant *wpa_s = ctx; @@ -10648,6 +10650,8 @@ static int wpas_ctrl_iface_send_neighbor_rep(struct wpa_supplicant *wpa_s, return ret; } +#endif /* CONFIG_NO_RRM */ + static int wpas_ctrl_iface_erp_flush(struct wpa_supplicant *wpa_s) { @@ -12873,9 +12877,11 @@ char * wpa_supplicant_ctrl_iface_process(struct wpa_supplicant *wpa_s, } else if (os_strncmp(buf, "VENDOR_ELEM_REMOVE ", 19) == 0) { if (wpas_ctrl_vendor_elem_remove(wpa_s, buf + 19) < 0) reply_len = -1; +#ifndef CONFIG_NO_RRM } else if (os_strncmp(buf, "NEIGHBOR_REP_REQUEST", 20) == 0) { if (wpas_ctrl_iface_send_neighbor_rep(wpa_s, buf + 20)) reply_len = -1; +#endif /* CONFIG_NO_RRM */ } else if (os_strcmp(buf, "ERP_FLUSH") == 0) { wpas_ctrl_iface_erp_flush(wpa_s); } else if (os_strncmp(buf, "MAC_RAND_SCAN ", 14) == 0) { diff --git a/wpa_supplicant/defconfig b/wpa_supplicant/defconfig index 8422a095f..27ca6ba40 100644 --- a/wpa_supplicant/defconfig +++ b/wpa_supplicant/defconfig @@ -671,3 +671,8 @@ CONFIG_DPP2=y # design is still subject to change. As such, this should not yet be enabled in # production use. #CONFIG_PASN=y + +# Disable support for Radio Measurement (IEEE 802.11k) and supported operating +# class indication. Removing these is not recommended since they can help the +# AP manage the network and STA steering. +#CONFIG_NO_RRM=y diff --git a/wpa_supplicant/dpp_supplicant.c b/wpa_supplicant/dpp_supplicant.c index b1a1e0ee0..4dd6a2ce1 100644 --- a/wpa_supplicant/dpp_supplicant.c +++ b/wpa_supplicant/dpp_supplicant.c @@ -1915,7 +1915,11 @@ static void wpas_dpp_start_gas_client(struct wpa_supplicant *wpa_s) offchannel_send_action_done(wpa_s); wpas_dpp_listen_stop(wpa_s); +#ifdef CONFIG_NO_RRM + supp_op_classes = NULL; +#else /* CONFIG_NO_RRM */ supp_op_classes = wpas_supp_op_classes(wpa_s); +#endif /* CONFIG_NO_RRM */ buf = dpp_build_conf_req_helper(auth, wpa_s->conf->dpp_name, wpa_s->dpp_netrole, wpa_s->conf->dpp_mud_url, diff --git a/wpa_supplicant/events.c b/wpa_supplicant/events.c index 26059a1ad..ad3dcd9d3 100644 --- a/wpa_supplicant/events.c +++ b/wpa_supplicant/events.c @@ -382,7 +382,9 @@ void wpa_supplicant_mark_disassoc(struct wpa_supplicant *wpa_s) wpa_s->key_mgmt = 0; wpa_s->allowed_key_mgmts = 0; +#ifndef CONFIG_NO_RRM wpas_rrm_reset(wpa_s); +#endif /* CONFIG_NO_RRM */ wpa_s->wnmsleep_used = 0; wnm_clear_coloc_intf_reporting(wpa_s); wpa_s->disable_mbo_oce = 0; @@ -2470,9 +2472,11 @@ static int _wpa_supplicant_event_scan_results(struct wpa_supplicant *wpa_s, if (sme_proc_obss_scan(wpa_s) > 0) goto scan_work_done; +#ifndef CONFIG_NO_RRM if (own_request && data && wpas_beacon_rep_scan_process(wpa_s, scan_res, &data->scan_info) > 0) goto scan_work_done; +#endif /* CONFIG_NO_RRM */ if (ml_link_probe_scan(wpa_s)) goto scan_work_done; @@ -5294,6 +5298,7 @@ static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s, } #endif /* CONFIG_INTERWORKING */ +#ifndef CONFIG_NO_RRM if (category == WLAN_ACTION_RADIO_MEASUREMENT && payload[0] == WLAN_RRM_RADIO_MEASUREMENT_REQUEST) { wpas_rrm_handle_radio_measurement_request(wpa_s, mgmt->sa, @@ -5316,6 +5321,7 @@ static void wpas_event_rx_mgmt_action(struct wpa_supplicant *wpa_s, rssi); return; } +#endif /* CONFIG_NO_RRM */ #ifdef CONFIG_FST if (mgmt->u.action.category == WLAN_ACTION_FST && wpa_s->fst) { diff --git a/wpa_supplicant/scan.c b/wpa_supplicant/scan.c index 4ed20b62d..a85555799 100644 --- a/wpa_supplicant/scan.c +++ b/wpa_supplicant/scan.c @@ -261,8 +261,10 @@ static void wpas_trigger_scan_cb(struct wpa_radio_work *work, int deinit) wpa_s->scan_res_handler = NULL; } +#ifndef CONFIG_NO_RRM if (wpa_s->beacon_rep_data.token) wpas_rrm_refuse_request(wpa_s); +#endif /* CONFIG_NO_RRM */ return; } diff --git a/wpa_supplicant/sme.c b/wpa_supplicant/sme.c index d5a4785ea..5e3ddafc0 100644 --- a/wpa_supplicant/sme.c +++ b/wpa_supplicant/sme.c @@ -874,10 +874,12 @@ static void sme_send_authentication(struct wpa_supplicant *wpa_s, sme_auth_handle_rrm(wpa_s, bss); +#ifndef CONFIG_NO_RRM wpa_s->sme.assoc_req_ie_len += wpas_supp_op_class_ie( wpa_s, ssid, bss, wpa_s->sme.assoc_req_ie + wpa_s->sme.assoc_req_ie_len, sizeof(wpa_s->sme.assoc_req_ie) - wpa_s->sme.assoc_req_ie_len); +#endif /* CONFIG_NO_RRM */ if (params.p2p) wpa_drv_get_ext_capa(wpa_s, WPA_IF_P2P_CLIENT); diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index c4c58b757..95a9de614 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -715,7 +715,9 @@ static void wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s) wpabuf_free(wpa_s->lci); wpa_s->lci = NULL; +#ifndef CONFIG_NO_RRM wpas_clear_beacon_rep_data(wpa_s); +#endif /* CONFIG_NO_RRM */ #ifdef CONFIG_PMKSA_CACHE_EXTERNAL #ifdef CONFIG_MESH @@ -3499,12 +3501,14 @@ static u8 * wpas_populate_assoc_ies( os_memset(wpa_s->p2p_ip_addr_info, 0, sizeof(wpa_s->p2p_ip_addr_info)); #endif /* CONFIG_P2P */ +#ifndef CONFIG_NO_RRM if (bss) { wpa_ie_len += wpas_supp_op_class_ie(wpa_s, ssid, bss, wpa_ie + wpa_ie_len, max_wpa_ie_len - wpa_ie_len); } +#endif /* CONFIG_NO_RRM */ /* * Workaround: Add Extended Capabilities element only if the AP @@ -7352,7 +7356,9 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s, if (wpas_init_ext_pw(wpa_s) < 0) return -1; +#ifndef CONFIG_NO_RRM wpas_rrm_reset(wpa_s); +#endif /* CONFIG_NO_RRM */ wpas_sched_scan_plans_set(wpa_s, wpa_s->conf->sched_scan_plans);