[PATCH 25/26] hostapd: add testing option to use only ECSA

Ilan Peer ilan.peer
Tue Sep 8 02:46:32 PDT 2015


From: Johannes Berg <johannes.berg at intel.com>

Some APs don't include a CSA IE when an ECSA IE is generated,
and mac80211 used to fail following their channel switch. Add
a testing option to hostapd to allow reproducing the behavior
and use it in a new test.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 hostapd/config_file.c      |  2 ++
 hostapd/hostapd.conf       |  4 ++++
 src/ap/ap_config.c         |  1 +
 src/ap/ap_config.h         |  1 +
 src/ap/beacon.c            |  5 +++++
 tests/hwsim/test_ap_csa.py | 12 +++++++++++-
 6 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/hostapd/config_file.c b/hostapd/config_file.c
index 82ac61d..37030d0 100644
--- a/hostapd/config_file.c
+++ b/hostapd/config_file.c
@@ -3249,6 +3249,8 @@ static int hostapd_config_fill(struct hostapd_config *conf,
 	PARSE_TEST_PROBABILITY(ignore_assoc_probability)
 	PARSE_TEST_PROBABILITY(ignore_reassoc_probability)
 	PARSE_TEST_PROBABILITY(corrupt_gtk_rekey_mic_probability)
+	} else if (os_strcmp(buf, "ecsa_ie_only") == 0) {
+		conf->ecsa_ie_only = atoi(pos);
 	} else if (os_strcmp(buf, "bss_load_test") == 0) {
 		WPA_PUT_LE16(bss->bss_load_test, atoi(pos));
 		pos = os_strchr(pos, ':');
diff --git a/hostapd/hostapd.conf b/hostapd/hostapd.conf
index a0071f7..c15cc44 100644
--- a/hostapd/hostapd.conf
+++ b/hostapd/hostapd.conf
@@ -1844,6 +1844,10 @@ own_ip_addr=127.0.0.1
 #
 # Corrupt Key MIC in GTK rekey EAPOL-Key frames with the given probability
 #corrupt_gtk_rekey_mic_probability=0.0
+#
+# Include only ECSA IE without CSA IE where possible
+# (channel switch operating class is needed)
+#ecsa_ie_only=0
 
 ##### Multiple BSSID support ##################################################
 #
diff --git a/src/ap/ap_config.c b/src/ap/ap_config.c
index 75804a0..69def85 100644
--- a/src/ap/ap_config.c
+++ b/src/ap/ap_config.c
@@ -180,6 +180,7 @@ struct hostapd_config * hostapd_config_defaults(void)
 	conf->ignore_assoc_probability = 0.0;
 	conf->ignore_reassoc_probability = 0.0;
 	conf->corrupt_gtk_rekey_mic_probability = 0.0;
+	conf->ecsa_ie_only = 0;
 #endif /* CONFIG_TESTING_OPTIONS */
 
 	conf->acs = 0;
diff --git a/src/ap/ap_config.h b/src/ap/ap_config.h
index de470a9..aa8da63 100644
--- a/src/ap/ap_config.h
+++ b/src/ap/ap_config.h
@@ -652,6 +652,7 @@ struct hostapd_config {
 	double ignore_assoc_probability;
 	double ignore_reassoc_probability;
 	double corrupt_gtk_rekey_mic_probability;
+	int ecsa_ie_only;
 #endif /* CONFIG_TESTING_OPTIONS */
 
 #ifdef CONFIG_ACS
diff --git a/src/ap/beacon.c b/src/ap/beacon.c
index 2c960aa..b88322c 100644
--- a/src/ap/beacon.c
+++ b/src/ap/beacon.c
@@ -297,6 +297,11 @@ static u8 * hostapd_eid_wpa(struct hostapd_data *hapd, u8 *eid, size_t len)
 
 static u8 * hostapd_eid_csa(struct hostapd_data *hapd, u8 *eid)
 {
+#ifdef CONFIG_TESTING_OPTIONS
+	if (hapd->iface->cs_oper_class && hapd->iconf->ecsa_ie_only)
+		return eid;
+#endif /* CONFIG_TESTING_OPTIONS */
+
 	if (!hapd->cs_freq_params.channel)
 		return eid;
 
diff --git a/tests/hwsim/test_ap_csa.py b/tests/hwsim/test_ap_csa.py
index c88e517..d8290c7 100644
--- a/tests/hwsim/test_ap_csa.py
+++ b/tests/hwsim/test_ap_csa.py
@@ -12,9 +12,10 @@ import hwsim_utils
 import hostapd
 from utils import HwsimSkip
 
-def connect(dev, apdev):
+def connect(dev, apdev, **kwargs):
     params = { "ssid": "ap-csa",
                "channel": "1" }
+    params.update(kwargs)
     ap = hostapd.add_ap(apdev[0]['ifname'], params)
     dev.connect("ap-csa", key_mgmt="NONE")
     return ap
@@ -109,3 +110,12 @@ def test_ap_csa_1_switch_count_2(dev, apdev):
     hwsim_utils.test_connectivity(dev[0], ap)
     switch_channel(ap, 2, 2462)
     hwsim_utils.test_connectivity(dev[0], ap)
+
+def test_ap_csa_ecsa_only(dev, apdev):
+    """AP Channel Switch, one switch with only ECSA IE"""
+    csa_supported(dev[0])
+    ap = connect(dev[0], apdev, ecsa_ie_only="1")
+
+    hwsim_utils.test_connectivity(dev[0], ap)
+    switch_channel(ap, 10, 2462)
+    hwsim_utils.test_connectivity(dev[0], ap)
-- 
1.9.1




More information about the Hostap mailing list