From patchwork Thu May 18 16:49:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13247102 Received: from mail-qk1-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A95C223C9D for ; Thu, 18 May 2023 16:50:05 +0000 (UTC) Received: by mail-qk1-f176.google.com with SMTP id af79cd13be357-75773252cbfso221511785a.2 for ; Thu, 18 May 2023 09:50:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684428604; x=1687020604; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fG6R7UgDgCF1ajrAKokqnJMs+Wt7JSzEyYbVTWFg9lE=; b=ktsLNlFB7vdZaGaO+WjoKmZPGnJSuczDKRjlQz+8E088EAENiEFOPMj3dCod9nyZgc Pc0ZJZb0EDYDe5nJLP8wU3xlozbjv8Qmwo1JLTJwgpiFCCpVKh1hd/SgcQOSRdsoyRDe aZHe8Kh3Wv7FtKZC/aDokGhSmWKUqEYzBtCZENV9r1fgctF3x45G6ZCSTRzJx9WW2eWH zysfPAAATZaArJt9WsKbCDLuINNiPkQVHmNx5e8tWbal9fCxfWAd4dyznXeMD4V/OFsJ xIKgwLLm4P3zMSAXpK4giNmv6bPLwTdVgpGo/smp3Kv6ZlSUBjWOK4Wt2/G7U9YtDPaK VOGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684428604; x=1687020604; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fG6R7UgDgCF1ajrAKokqnJMs+Wt7JSzEyYbVTWFg9lE=; b=k4d+UqLi0dAaerGrXPFyomP7P3RxYxdW7b5/jRHKT2slMvetDm7ZM/l6l3eRf1ITRG umRrrLaKXrIuRbfKcEVs8vRlXEUq+v0xM2T53Tu5ZJJ4VCGkaKALVZQkTw02ueS4Y64c GjkZ/DW+MYrQVz+bGY9MgjRJ4nBtC9/K9Iu59xdqPT4ywj5anJGm0rt4JkCEAdWmHvqe ghRlZRCdwArPXA9oqVW5iFbiZhZkYqolyIfgvf02rJt2TtNpurCsqMmBCft4JpDPaQ+s tBF1mM1m9x9CQYonego8NVxVqygBFh03+sRNAWduJjYL1OMkdH8aVCQivweGbD0ggLxd Rhuw== X-Gm-Message-State: AC+VfDzrAEw3QIuLIW8mieMH1bzJiIgUyAHX9hZ+SQUlfGi9YnVxjRDv 3LCjsDLY4lCzVJpsk0QrP9Pwiv7WZbs= X-Google-Smtp-Source: ACHHUZ6yK7U1KpeTNT74Ldhd+OUHTnosVl0J9p9FUtXpliVLxSnxMm4hrFcbLWjyYTotokdx1/SSpw== X-Received: by 2002:a05:622a:2cf:b0:3f5:1626:6a3d with SMTP id a15-20020a05622a02cf00b003f516266a3dmr559116qtx.42.1684428604383; Thu, 18 May 2023 09:50:04 -0700 (PDT) Received: from LOCLAP699.cardinalhealth-columbus.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id cn13-20020a05622a248d00b003f3941ba4d9sm626112qtb.32.2023.05.18.09.50.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 09:50:04 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 1/4] auto-t: modify PSK-roam test to use FT failure path Date: Thu, 18 May 2023 09:49:57 -0700 Message-Id: <20230518165000.275611-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This adds another radio so IWD hits the FT failure path after authentication to the first BSS fails. This causes a wiphy work item to be rescheduled which previously was unsafe. --- autotests/testPSK-roam/connection_test.py | 13 ++++--- autotests/testPSK-roam/failed_roam_test.py | 33 ++++++++++------ autotests/testPSK-roam/ft-psk-ccmp-3.conf | 39 +++++++++++++++++++ autotests/testPSK-roam/hw.conf | 3 +- .../testPSK-roam/roam_ap_disconnect_test.py | 4 +- 5 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 autotests/testPSK-roam/ft-psk-ccmp-3.conf diff --git a/autotests/testPSK-roam/connection_test.py b/autotests/testPSK-roam/connection_test.py index 7a135e95..459c25cf 100644 --- a/autotests/testPSK-roam/connection_test.py +++ b/autotests/testPSK-roam/connection_test.py @@ -48,7 +48,7 @@ class Test(unittest.TestCase): self.rule2.enabled = True # Send 100 packets (to be dropped), should trigger beacon loss testutil.tx_packets(device.name, self.bss_hostapd[0].ifname, 100) - device.wait_for_event('packet-loss-roam', timeout=30) + device.wait_for_event('packet-loss-roam', timeout=60) else: device.roam(self.bss_hostapd[1].bssid) @@ -173,19 +173,22 @@ class Test(unittest.TestCase): IWD.copy_to_storage('TestFT.psk') cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] + HostapdCLI(config='ft-psk-ccmp-2.conf'), + HostapdCLI(config='ft-psk-ccmp-3.conf') ] + cls.bss_hostapd[2].disable() + rad0 = hwsim.get_radio('rad0') - rad2 = hwsim.get_radio('rad2') + rad3 = hwsim.get_radio('rad3') cls.rule0 = hwsim.rules.create() - cls.rule0.source = rad2.addresses[0] + cls.rule0.source = rad3.addresses[0] cls.rule0.bidirectional = True cls.rule0.signal = -2000 cls.rule0.prefix = 'b0' cls.rule0.drop = True cls.rule1 = hwsim.rules.create() - cls.rule1.source = rad2.addresses[0] + cls.rule1.source = rad3.addresses[0] cls.rule1.prefix = '08' cls.rule1.drop = True diff --git a/autotests/testPSK-roam/failed_roam_test.py b/autotests/testPSK-roam/failed_roam_test.py index 360c1de5..eda2b4e2 100644 --- a/autotests/testPSK-roam/failed_roam_test.py +++ b/autotests/testPSK-roam/failed_roam_test.py @@ -62,21 +62,17 @@ class Test(unittest.TestCase): self.rule0.enabled = True - device.roam(self.bss_hostapd[1].bssid) - - # Roam should fail... - device.wait_for_event('ft-roam-failed') + # IWD should connect, then attempt a roam to BSS 1, which should fail... + device.wait_for_event('ft-roam-failed', timeout=60) # ... but IWD should remain connected self.assertTrue(device.state == DeviceState.connected) self.rule0.enabled = False - # Try again once more - device.roam(self.bss_hostapd[1].bssid) - - self.verify_roam(wd, device, self.bss_hostapd[0], self.bss_hostapd[1]) + # IWD should then try BSS 2, and succeed + self.verify_roam(wd, device, self.bss_hostapd[0], self.bss_hostapd[2]) - self.bss_hostapd[1].deauthenticate(device.address) + self.bss_hostapd[2].deauthenticate(device.address) condition = 'obj.state == DeviceState.disconnected' wd.wait_for_object_condition(device, condition) @@ -88,6 +84,7 @@ class Test(unittest.TestCase): self.rule0.enabled = False self.rule1.enabled = False + self.rule2.enabled = False @classmethod def setUpClass(cls): @@ -96,14 +93,16 @@ class Test(unittest.TestCase): IWD.copy_to_storage('TestFT.psk') cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] + HostapdCLI(config='ft-psk-ccmp-2.conf'), + HostapdCLI(config='ft-psk-ccmp-3.conf') ] cls.bss_hostapd[0].set_address('12:00:00:00:00:01') cls.bss_hostapd[1].set_address('12:00:00:00:00:02') + cls.bss_hostapd[2].set_address('12:00:00:00:00:03') # Drop Authenticate frames cls.rule0 = hwsim.rules.create() - cls.rule0.bidirectional = True + cls.rule0.source = hwsim.get_radio('rad1').addresses[0] cls.rule0.prefix = 'b0' cls.rule0.drop = True @@ -113,6 +112,18 @@ class Test(unittest.TestCase): cls.rule1.prefix = 'd0' cls.rule1.drop = True + # Causes IWD to immediately roam away from BSS 0 + cls.rule2 = hwsim.rules.create() + cls.rule2.source = hwsim.get_radio('rad0').addresses[0] + cls.rule2.signal = -8000 + cls.rule2.enabled = True + + # Causes IWD to first prefer BSS 1 to roam, then BSS 2. + cls.rule3 = hwsim.rules.create() + cls.rule3.source = hwsim.get_radio('rad2').addresses[0] + cls.rule3.signal = -7000 + cls.rule3.enabled = True + @classmethod def tearDownClass(cls): IWD.clear_storage() diff --git a/autotests/testPSK-roam/ft-psk-ccmp-3.conf b/autotests/testPSK-roam/ft-psk-ccmp-3.conf new file mode 100644 index 00000000..a42e175d --- /dev/null +++ b/autotests/testPSK-roam/ft-psk-ccmp-3.conf @@ -0,0 +1,39 @@ +hw_mode=g +channel=2 +ssid=TestFT +utf8_ssid=1 +ctrl_interface=/var/run/hostapd + +r1_key_holder=120000000002 +nas_identifier=dummy2 + +wpa=2 +# Can support WPA-PSK and FT-PSK (space separated list) and/or EAP at the same +# time but we want to force FT +wpa_key_mgmt=FT-PSK +wpa_pairwise=CCMP +wpa_passphrase=EasilyGuessedPassword +ieee80211w=1 +rsn_preauth=1 +rsn_preauth_interfaces=lo +disable_pmksa_caching=0 +# Allow PMK cache to be shared opportunistically among configured interfaces +# and BSSes (i.e., all configurations within a single hostapd process). +okc=1 +mobility_domain=1234 +reassociation_deadline=60000 +r0kh=12:00:00:00:00:01 dummy1 000102030405060708090a0b0c0d0e0f +r0kh=12:00:00:00:00:02 dummy2 000102030405060708090a0b0c0d0e0f +r1kh=12:00:00:00:00:01 00:00:00:00:00:01 000102030405060708090a0b0c0d0e0f +r1kh=12:00:00:00:00:02 00:00:00:00:00:02 000102030405060708090a0b0c0d0e0f +# Push mode only needed for 8021x, not PSK mode since msk already known +pmk_r1_push=0 +# Allow locally generated FT response so we don't have to configure push/pull +# between BSSes running as separate hostapd processes as in the test-runner +# case. Only works with FT-PSK, otherwise brctl needs to be installed and +# CONFIG_BRIDGE enabled in the kernel. +ft_psk_generate_local=1 +ft_over_ds=0 +ap_table_expiration_time=36000 +ap_table_max_size=10 +rrm_neighbor_report=1 diff --git a/autotests/testPSK-roam/hw.conf b/autotests/testPSK-roam/hw.conf index c2b35d6e..da9e385c 100644 --- a/autotests/testPSK-roam/hw.conf +++ b/autotests/testPSK-roam/hw.conf @@ -1,8 +1,9 @@ [SETUP] -num_radios=3 +num_radios=4 start_iwd=0 hwsim_medium=yes [HOSTAPD] rad0=ft-psk-ccmp-1.conf rad1=ft-psk-ccmp-2.conf +rad2=ft-psk-ccmp-3.conf diff --git a/autotests/testPSK-roam/roam_ap_disconnect_test.py b/autotests/testPSK-roam/roam_ap_disconnect_test.py index 416541ce..130e1702 100644 --- a/autotests/testPSK-roam/roam_ap_disconnect_test.py +++ b/autotests/testPSK-roam/roam_ap_disconnect_test.py @@ -70,8 +70,10 @@ class Test(unittest.TestCase): IWD.copy_to_storage('TestFT.psk') cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), - HostapdCLI(config='ft-psk-ccmp-2.conf') ] + HostapdCLI(config='ft-psk-ccmp-2.conf'), + HostapdCLI(config='ft-psk-ccmp-3.conf') ] cls.bss_hostapd[1].disable() + cls.bss_hostapd[2].disable() cls.bss_hostapd[0].set_value('ocv', '0') cls.bss_hostapd[0].set_value('ieee80211w', '0') From patchwork Thu May 18 16:49:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13247103 Received: from mail-qt1-f180.google.com (mail-qt1-f180.google.com [209.85.160.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD8CC23D78 for ; Thu, 18 May 2023 16:50:06 +0000 (UTC) Received: by mail-qt1-f180.google.com with SMTP id d75a77b69052e-3f4c8d78a18so23253011cf.2 for ; Thu, 18 May 2023 09:50:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684428605; x=1687020605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=bvyiYUqoqdRmkFTliyZi62r+N0b0AOgiyYrPEVc04rg=; b=KBu0O/loJc4NcOedbPFA7lcObDpBYhTI8PWRZCsmNw8lvwz7RicLcTv+AYk6jeyhsk HfYG/kRpPAK2DTLiQIP4gCAZn3iW8BqjiN+r4sB7dFhJ+aBoLuZ5d3u5X59PaH0t5XkH ZzdOY9Kt6/SVLjAOFSMgFby84oL/NbjZSwm3vVIC1ja1IArIrDGzDHMDu+4gxrUia1Rr gtGxEub78ccf4DWnycvUy4W5fXuAmSAgQAA5UfGxG60I+W2XxoEQTBSstclZYThriqsE +yMy5LZto2Bd84eLOY+R58h82rkjM8L6LNTb+W30JNFzs+ZCkm45wK8c+jZ8EGGqSyZC i4eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684428605; x=1687020605; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bvyiYUqoqdRmkFTliyZi62r+N0b0AOgiyYrPEVc04rg=; b=NBnttWy8ca1cJgRq62P5McNLHRQ4ocwyzQOxlp1dld+W1k69Q3+iAEVDiIUT29uB3R z07+kp5kd6Dsf7Jn13sTZeM9cgyyZBkkazO2taUlhaTUejpwqrh/s7EroKbONvCPlSiD HH+lY/A0tjYsNTjDHG8iaVYEhkf5P5dPVCiboOtselqHELp1i0a+OnuDEy2JDIt+M138 930T3TeYj4jMN0UydvVGjtvsfnj24H4IxC8AvVjvmKoMVMwH/+7g1sypk6TplbhM5rJ1 9AcgANd2eDjCqhKFmyhtopKXAtDa+PP8GjrzashFCObBh+oLprBepRYBDiLvldppnfFk hdYA== X-Gm-Message-State: AC+VfDyPfb5UIGx4umvumKW187L5iN1laVIV+09cvBkx//TAe8ac8sNj s3jhv8fh2ZZyiO92msA4FrAX3H8UtS0= X-Google-Smtp-Source: ACHHUZ7SdTYd8vPycrHufNt0To+w/TaZDAEvJ+hgvbATLrc5QN8+Iat59lKwz3uqdfyWDC6zy52C9w== X-Received: by 2002:a05:622a:389:b0:3f5:279f:c4dd with SMTP id j9-20020a05622a038900b003f5279fc4ddmr467028qtx.64.1684428605682; Thu, 18 May 2023 09:50:05 -0700 (PDT) Received: from LOCLAP699.cardinalhealth-columbus.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id cn13-20020a05622a248d00b003f3941ba4d9sm626112qtb.32.2023.05.18.09.50.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 09:50:05 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 2/4] auto-t: increase timeout in testPSK-roam Date: Thu, 18 May 2023 09:49:58 -0700 Message-Id: <20230518165000.275611-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518165000.275611-1-prestwoj@gmail.com> References: <20230518165000.275611-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This was causing random failures and increasing the timeout seems to be a lot more reliable. --- autotests/testPSK-roam/roam_ap_disconnect_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autotests/testPSK-roam/roam_ap_disconnect_test.py b/autotests/testPSK-roam/roam_ap_disconnect_test.py index 130e1702..b5775990 100644 --- a/autotests/testPSK-roam/roam_ap_disconnect_test.py +++ b/autotests/testPSK-roam/roam_ap_disconnect_test.py @@ -33,7 +33,7 @@ class Test(unittest.TestCase): # Since both BSS's have low signal, the roam should fail and trigger # another roam scan. device.wait_for_event('roam-scan-triggered', timeout=30) - device.wait_for_event('no-roam-candidates', timeout=30) + device.wait_for_event('no-roam-candidates', timeout=60) # Hostapd sends disconnect self.bss_hostapd[0].disable() From patchwork Thu May 18 16:49:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13247104 Received: from mail-qt1-f179.google.com (mail-qt1-f179.google.com [209.85.160.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B68123C9D for ; Thu, 18 May 2023 16:50:08 +0000 (UTC) Received: by mail-qt1-f179.google.com with SMTP id d75a77b69052e-3f684f20f77so11563741cf.2 for ; Thu, 18 May 2023 09:50:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684428607; x=1687020607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=136oyQ5+BI/4ee7CPLkprRBSjXplxunh2AE+r12f3/E=; b=jKqxDdmbZE+mWWdVqgqeyPlqACXlmOYcX4uptpG8FhQxgdYpbG3Ndke63jdgGrS+lO ifDlUaHNsuzWKLAWRgxul2Shm9MDzhppdpKgal9mru9I4oZm6G8aW46+1h5v7+cJYj3t WL8RwAQUzsPi++pkaDvLOLDzKKTK0b+4YUzLPh+jAzQbuOmgvYx6H8Z8dl1FxvJpvrsN vjkP3AeG1TuwSheBlyk4LdgGt34l9nZLeSowzA3WtvJNEbnc+R5csm6PIuUHdaEM5h4w mEpZ0oqjvMUOchNSQMxV60p40RaayftGv4j/LfuilFTB0K6zRPL+pQHBcSbdYMAg7VYQ YuVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684428607; x=1687020607; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=136oyQ5+BI/4ee7CPLkprRBSjXplxunh2AE+r12f3/E=; b=UK6dMDT+yIPojKefH/6X2hzeqBuDr0LTBQz/z+Ib62AV3/TInzpwHdExzd5vO2Oizs TEFnS/TLmgJ2zV36f0mrB/aagpTyRDfwTPCfjDLrpN5KzdZOfFSbO2IB3HP7/b+eaBZK HbKHamI0qbTfrxDei3Dh1E+vQo9k623O+yMxuoy4WZ5LGQfCYUC6bXbBj57AcUzJHTiq VuaCMHvyErbpUBUgu3bJn6Oufz9gmjbQ1jw4m8/Htchj9JdTK5WQUatTMBMS/ioYyOkn B8zcWQnmV0Yj0Xdx68/p0YjON+Ehb3u/MGvghLkCIfAiqcMdNcUDySrQl0ZwGs9Azf3x j5vw== X-Gm-Message-State: AC+VfDwBMa6fl0HKqs/kq1AbqxcIFAUOwuobDSKJJmMRF4XFqH0ayNgM 78PdcnQofRrXF1Dv65WGisoktG/HUU8= X-Google-Smtp-Source: ACHHUZ7vsWAji6g2QQOOvLBtrYm1k6mPcWE2MWGfcFtKxWTxLxQzgP5MNKCg54vz6m2khIA3OT91wA== X-Received: by 2002:ac8:5d91:0:b0:3f5:3678:f4d8 with SMTP id d17-20020ac85d91000000b003f53678f4d8mr342508qtx.56.1684428606977; Thu, 18 May 2023 09:50:06 -0700 (PDT) Received: from LOCLAP699.cardinalhealth-columbus.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id cn13-20020a05622a248d00b003f3941ba4d9sm626112qtb.32.2023.05.18.09.50.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 09:50:06 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 3/4] wiphy: make wiphy work queue reentrant Date: Thu, 18 May 2023 09:49:59 -0700 Message-Id: <20230518165000.275611-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518165000.275611-1-prestwoj@gmail.com> References: <20230518165000.275611-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In some situations its convenient for the same work item to be inserted (rescheduled) while its in progress. FT for example does this now if a roam fails. The same ft_work item gets re-inserted which, currently, is not safe to do since the item is modified and removed once completed. Fix this by introducing wiphy_radio_work_reschedule which is an explicit API for re-inserting work items from within the do_work callback. The wiphy work logic was changed around slightly to remove the item at the head of the queue prior to starting and note the ID going into do_work. If do_work signaled done and ID changed we know it was re-inserted and can skip the destroy logic and move onto the next item. If the item is not done continue as normal but set the priority to INT_MIN, as usual, to prevent other items from getting to the head of the queue. --- src/wiphy.c | 45 +++++++++++++++++++++++++++++++++++++-------- src/wiphy.h | 2 ++ 2 files changed, 39 insertions(+), 8 deletions(-) v3: * Reworked the logic to simplify as well as added an explicit API for work rescheduling to make it clear to the caller. diff --git a/src/wiphy.c b/src/wiphy.c index 2db2d2cd..d06b2447 100644 --- a/src/wiphy.c +++ b/src/wiphy.c @@ -2574,16 +2574,13 @@ static void wiphy_radio_work_next(struct wiphy *wiphy) { struct wiphy_radio_work_item *work; bool done; + uint32_t id; - work = l_queue_peek_head(wiphy->work); + work = l_queue_pop_head(wiphy->work); if (!work) return; - /* - * Ensures no other work item will get inserted before this one while - * the work is being done. - */ - work->priority = INT_MIN; + id = work->id; l_debug("Starting work item %u", work->id); @@ -2592,15 +2589,25 @@ static void wiphy_radio_work_next(struct wiphy *wiphy) wiphy->work_in_callback = false; if (done) { - work->id = 0; + /* Item was rescheduled, don't destroy */ + if (work->id != id) + goto next; - l_queue_remove(wiphy->work, work); + work->id = 0; wiphy->work_in_callback = true; destroy_work(work); wiphy->work_in_callback = false; +next: wiphy_radio_work_next(wiphy); + } else { + /* + * Ensures no other work item will get inserted before this one + * while the work is being done. + */ + work->priority = INT_MIN; + l_queue_push_head(wiphy->work, work); } } @@ -2684,6 +2691,28 @@ int wiphy_radio_work_is_running(struct wiphy *wiphy, uint32_t id) return item == l_queue_peek_head(wiphy->work) ? 1 : 0; } +uint32_t wiphy_radio_work_reschedule(struct wiphy *wiphy, + struct wiphy_radio_work_item *item) +{ + /* + * This should only be called from within the do_work callback, meaning + * the item should not be in the queue. Any re-insertion on a running + * item after do_work is not allowed. + */ + if (L_WARN_ON(wiphy_radio_work_is_running(wiphy, item->id) != -ENOENT)) + return 0; + + work_ids++; + + l_debug("Rescheduling work item %u, new id %u", item->id, work_ids); + + item->id = work_ids; + + l_queue_insert(wiphy->work, item, insert_by_priority, NULL); + + return item->id; +} + static int wiphy_init(void) { struct l_genl *genl = iwd_get_genl(); diff --git a/src/wiphy.h b/src/wiphy.h index d5d1cc8f..f4f205ad 100644 --- a/src/wiphy.h +++ b/src/wiphy.h @@ -168,3 +168,5 @@ uint32_t wiphy_radio_work_insert(struct wiphy *wiphy, const struct wiphy_radio_work_item_ops *ops); void wiphy_radio_work_done(struct wiphy *wiphy, uint32_t id); int wiphy_radio_work_is_running(struct wiphy *wiphy, uint32_t id); +uint32_t wiphy_radio_work_reschedule(struct wiphy *wiphy, + struct wiphy_radio_work_item *item); From patchwork Thu May 18 16:50:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13247105 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A661B23D78 for ; Thu, 18 May 2023 16:50:09 +0000 (UTC) Received: by mail-qk1-f174.google.com with SMTP id af79cd13be357-757942bd912so123164685a.2 for ; Thu, 18 May 2023 09:50:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1684428608; x=1687020608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cMNDXCtv1dRZ3EhNXLekDDNKFmZKuaqafsL8saIA0xY=; b=drqW9NiPQlLN7WPyO6BU5IDAv1EuBV27GrX9ahRXlwO4lIFR/IG5CaItaeCfIEdj0e zJpdvrExNsAMSbhaCXnG9frcSgmBkve4UttJNaXU777X3LOZ9CT/Q77Rd/0+ps60o9TX ES80Cv5B39coNu/Tu67AMa38c3TMEe13WYZaZ2NiSJ0FvZHOVovJLo/z/W2AOq97K6Mp 9aEYupjDM09/7QjvD5+IfpemofPMc1ERS5gQSCAnPV3r+qeIoU4995MVPf9e6Zf7ATjq WESdeItk7C79XPk0s3rXkYwVwGNofszeepYckiQnpHRgCRK3O7ir3Kii7V0OLBZyX9EU X/qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684428608; x=1687020608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cMNDXCtv1dRZ3EhNXLekDDNKFmZKuaqafsL8saIA0xY=; b=ifgUC1sxZ57lCWcL0XW2Q1fDQ01Hw/9KzuSJqFpbz23dl379no60epxF0TAGHnPAZ/ IyZrRMCt3Q/IlKSSiNHoDwFYcbhcID5L7I6R0sMjMsabxQUidGSS/JjcnVKe7uQA5tAa 0AzHggTkEU6ZFj1Km1hkn40zZMpVrUQdBESnmaKiL9Ls2oW7PH75bVBbIhYTMS53HZQ7 bkD+opFLGM3nGfsjmBuBZYuOUd3z8LAG8K3OPWbwN/ShmKgqGa+U8RpiYH5yVyxe9JL/ lhsEHYDlx5u+FxU1nZ0rGzVMfWfIV1BOdUZoUz4CryMs8+TfjuB86MknkQTbbctu+ArP H5tg== X-Gm-Message-State: AC+VfDzFfSuaufck/myqrBYAw548Oyw9n+Wub8s+DfoCFvvG7UhJaBwK 6V0LIntZQ0dWPyITRq/wq5HyxiXl0/I= X-Google-Smtp-Source: ACHHUZ52PTirPzzIJ1025ZEWfCDNuzyFSZRnJxXPghkjsnoEbUSt1OtRyCWFELdVpCOeU3UF0Vlmlw== X-Received: by 2002:a05:622a:447:b0:3f5:1ff7:db72 with SMTP id o7-20020a05622a044700b003f51ff7db72mr550292qtx.22.1684428608369; Thu, 18 May 2023 09:50:08 -0700 (PDT) Received: from LOCLAP699.cardinalhealth-columbus.locus (50-78-19-50-static.hfc.comcastbusiness.net. [50.78.19.50]) by smtp.gmail.com with ESMTPSA id cn13-20020a05622a248d00b003f3941ba4d9sm626112qtb.32.2023.05.18.09.50.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 18 May 2023 09:50:08 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 4/4] station: use wiphy_radio_work_reschedule in FT path Date: Thu, 18 May 2023 09:50:00 -0700 Message-Id: <20230518165000.275611-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230518165000.275611-1-prestwoj@gmail.com> References: <20230518165000.275611-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If FT fails the work item needs to be rescheduled rather than inserted. --- src/station.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/station.c b/src/station.c index be571083..f830ab7a 100644 --- a/src/station.c +++ b/src/station.c @@ -2330,8 +2330,12 @@ static bool station_fast_transition(struct station *station, ft_authenticate(netdev_get_ifindex(station->netdev), bss); done: - wiphy_radio_work_insert(station->wiphy, &station->ft_work, - WIPHY_WORK_PRIORITY_CONNECT, &ft_work_ops); + if (station->ft_work.id) + wiphy_radio_work_reschedule(station->wiphy, &station->ft_work); + else + wiphy_radio_work_insert(station->wiphy, &station->ft_work, + WIPHY_WORK_PRIORITY_CONNECT, + &ft_work_ops); return true; }