[PATCH] hostapd: for VHT 20/40, allow center segment 0 to be zero

Johannes Berg johannes
Fri Feb 28 00:54:20 PST 2014


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

The 802.11ac amendment specifies that that the center segment 0 field
is reserved, so it should be zero. Hostapd previously required it to
be set, which is likely a good idea for interoperability, but allow it
to be unset. However, don't allow it to be set to a random value, only
allow zero and the correct channel.

Add a test case for this. This was found through a mac80211 bug which
didn't correctly accept a center segment 0 value of zero, so the test
will fail until the mac80211 bug is fixed.

Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
 src/ap/ap_drv_ops.c        |  3 ++-
 tests/hwsim/test_ap_vht.py | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 tests/hwsim/test_ap_vht.py

diff --git a/src/ap/ap_drv_ops.c b/src/ap/ap_drv_ops.c
index e998fc620510..39e122e249e0 100644
--- a/src/ap/ap_drv_ops.c
+++ b/src/ap/ap_drv_ops.c
@@ -492,7 +492,8 @@ int hostapd_set_freq_params(struct hostapd_freq_params *data, int mode,
 	case VHT_CHANWIDTH_USE_HT:
 		if (center_segment1)
 			return -1;
-		if (5000 + center_segment0 * 5 != data->center_freq1 &&
+		if (center_segment0 != 0 &&
+		    5000 + center_segment0 * 5 != data->center_freq1 &&
 		    2407 + center_segment0 * 5 != data->center_freq1)
 			return -1;
 		break;
diff --git a/tests/hwsim/test_ap_vht.py b/tests/hwsim/test_ap_vht.py
new file mode 100644
index 000000000000..afad296b0509
--- /dev/null
+++ b/tests/hwsim/test_ap_vht.py
@@ -0,0 +1,37 @@
+# VHT tests
+# Copyright (c) 2013, Intel Corporation
+#
+# Author: Johannes Berg <johannes.berg at intel.com>
+#
+# This software may be distributed under the terms of the BSD license.
+# See README for more details.
+
+import logging
+logger = logging.getLogger()
+
+import hwsim_utils
+import hostapd
+import subprocess, time
+
+def test_ap_vht_20(devs, apdevs):
+    dev = devs[0]
+    ap = apdevs[0]
+    subprocess.call(['sudo', 'iw', 'reg', 'set', 'DE'])
+    time.sleep(.1)
+    try:
+        params = { "ssid": "test-vht20",
+                   "hw_mode": "a",
+                   "channel": "36",
+                   "ieee80211n": "1",
+                   "ieee80211ac": "1",
+                   "ht_capab": "",
+                   "vht_capab": "",
+                   "vht_oper_chwidth": "0",
+                   "vht_oper_centr_freq_seg0_idx": "0",
+                   "require_vht": "1",
+                 }
+        hostapd.add_ap(ap['ifname'], params)
+        dev.connect("test-vht20", scan_freq="5180", key_mgmt="NONE")
+        hwsim_utils.test_connectivity(dev.ifname, ap['ifname'])
+    finally:
+        subprocess.call(['sudo', 'iw', 'reg', 'set', '00'])
-- 
1.8.5.3




More information about the Hostap mailing list