From patchwork Fri Jan 9 18:55:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 427235 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) by ozlabs.org (Postfix) with ESMTP id 6E5CA140151 for ; Sat, 10 Jan 2015 05:56:21 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id ED81017C13E; Fri, 9 Jan 2015 13:56:14 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MuSWz15yqtMz; Fri, 9 Jan 2015 13:56:14 -0500 (EST) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 7F24317C131; Fri, 9 Jan 2015 13:56:01 -0500 (EST) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id AAA569D2D7 for ; Fri, 9 Jan 2015 13:55:57 -0500 (EST) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id EUbRGAGcS1NQ for ; Fri, 9 Jan 2015 13:55:53 -0500 (EST) Received: from sipsolutions.net (s3.sipsolutions.net [5.9.151.49]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 372439D2CE for ; Fri, 9 Jan 2015 13:55:53 -0500 (EST) Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84) (envelope-from ) id 1Y9eis-0007lf-BE; Fri, 09 Jan 2015 19:55:50 +0100 From: Johannes Berg To: hostap@lists.shmoo.com Subject: [PATCH v4 2/2] hwsim tests: add test to check disconnect in powersave Date: Fri, 9 Jan 2015 19:55:45 +0100 Message-Id: <1420829745-13761-2-git-send-email-johannes@sipsolutions.net> X-Mailer: git-send-email 2.1.1 In-Reply-To: <1420829745-13761-1-git-send-email-johannes@sipsolutions.net> References: <1420829745-13761-1-git-send-email-johannes@sipsolutions.net> Cc: Johannes Berg X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com From: Johannes Berg The kernel had two bugs (one in hwsim and one more important one in mac80211) in this area, add a test to make sure we can disconnect without any kernel issues while in powersave. Also make sure that the TIM bit gets set and cleared again (by checking with tshark.) Signed-off-by: Johannes Berg --- tests/hwsim/hwsim_utils.py | 8 ++++++++ tests/hwsim/test_ap_open.py | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/tests/hwsim/hwsim_utils.py b/tests/hwsim/hwsim_utils.py index edf0a4242472..31432619811e 100644 --- a/tests/hwsim/hwsim_utils.py +++ b/tests/hwsim/hwsim_utils.py @@ -149,3 +149,11 @@ def test_connectivity_p2p_sta(dev1, dev2, dscp=None, tos=None): def test_connectivity_sta(dev1, dev2, dscp=None, tos=None): test_connectivity(dev1, dev2, dscp, tos) + +(PS_DISABLED, PS_ENABLED, PS_AUTO_POLL, PS_MANUAL_POLL) = range(4) + +def set_powersave(dev, val): + phy = dev.get_driver_status_field("phyname") + psf = open('/sys/kernel/debug/ieee80211/%s/hwsim/ps' % phy, 'w') + psf.write('%d\n' % val) + psf.close() diff --git a/tests/hwsim/test_ap_open.py b/tests/hwsim/test_ap_open.py index 7a646b8ab407..e8e10f6cc7ff 100644 --- a/tests/hwsim/test_ap_open.py +++ b/tests/hwsim/test_ap_open.py @@ -9,10 +9,12 @@ logger = logging.getLogger() import struct import subprocess import time +import os import hostapd import hwsim_utils from utils import alloc_fail +from tshark import run_tshark def test_ap_open(dev, apdev): """AP with open mode (no security) configuration""" @@ -201,3 +203,41 @@ def test_ap_open_out_of_memory(dev, apdev): # verify that a new interface can still be added when memory allocation does # not fail hostapd.add_ap(apdev[1]['ifname'], { "ssid": "open" }) + +def test_ap_open_disconnect_in_ps(dev, apdev, params): + """disconnect with the client in PS to regression-test a kernel bug""" + hapd = hostapd.add_ap(apdev[0]['ifname'], { "ssid": "open" }) + dev[0].connect("open", key_mgmt="NONE", scan_freq="2412", + bg_scan_period="0") + ev = hapd.wait_event([ "AP-STA-CONNECTED" ], timeout=5) + if ev is None: + raise Exception("No connection event received from hostapd") + + hwsim_utils.set_powersave(dev[0], hwsim_utils.PS_MANUAL_POLL) + try: + # inject some traffic + sa = hapd.own_addr() + da = dev[0].own_addr() + hapd.request('DATA_TEST_TX {} {} 0'.format(da, sa)) + + # let the AP send two beacons + time.sleep(0.2) + + # disconnect - with traffic pending - shouldn't cause kernel warnings + dev[0].request("DISCONNECT") + finally: + hwsim_utils.set_powersave(dev[0], hwsim_utils.PS_DISABLED) + + out = run_tshark(os.path.join(params['logdir'], "hwsim0.pcapng"), + "wlan_mgt.tim.partial_virtual_bitmap", + ["wlan_mgt.tim.partial_virtual_bitmap"]) + if out is not None: + state = 0 + for l in out.splitlines(): + pvb = int(l, 16) + if pvb > 0 and state == 0: + state = 1 + elif pvb == 0 and state == 1: + state = 2 + if state != 2: + raise Exception("didn't observe TIM bit getting set and unset")