From patchwork Wed Jul 24 15:46:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13741130 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) (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 426D626287 for ; Wed, 24 Jul 2024 15:46:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836010; cv=none; b=L4L6CzD5lPcaWuXsCNfSKCm8cOAKG2hMjtcLljROFQ7ljlFhO//9F3ytasVJXiPyPw/bd8/sR614D4ZGTQeMrf5fP5zZvr/WlshAiM6v5fVnhXI/5QqAGDeSXDXhcjYe0rUZyCeMUpDFHOJgUpmGjTo+xM2eT9Qhn0eUU6kkMsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836010; c=relaxed/simple; bh=tagP61yNJmsAJHKBfhm8LSjmJzcOwd3jJl1WkTP1lMI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=fpSzOMG1cMK3IlMbSQJXospHsKqaPOkRyuqrBZLMTZ9mjybkuGaW3zxiAK43ZCdwxrXM7ppIT1Z2uNrDcIp7dZfqWxlyNDuny829S8ZWmtlRE+klGBYN2aaKFwOzP4CCgd72R0dKlkvFV9mqavw0tBN8mIcqKXCAG39P+PnTvX4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XmlxLxfM; arc=none smtp.client-ip=209.85.210.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XmlxLxfM" Received: by mail-ot1-f54.google.com with SMTP id 46e09a7af769-703631c4930so3557091a34.1 for ; Wed, 24 Jul 2024 08:46:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721836008; x=1722440808; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Vr4cagXRKHoGrtK5CjJX/9SHrVXecHUstDwjaCnMSGk=; b=XmlxLxfMbATWdMOwieAzA/rrvBTvVoHKRO6Co/jmmm6xZI1je0sY5e1bQfcaAIJ4HO XmFvRN/1e/xjtQeM8/AsZkImJtlcBERqFC6zIAaVGobXf0fj0I4W3Nf3fDDuixdwRSjW Ehoetq6S/S8c9rwGfUNBKwr7RpNndCeCdIhQGHWY8i9GLjYCwHTZcQyH3m8yQbxyHILb LcF710GlCEnuH0qr7fh/fWMEfivQ413aZAtFK7u0u4PM1INfwKU3bH7nw7/2+H9rE53I lAEnAF+sUn2LQExZqgR6xcagQ/BY59AhMJU4XfmDJJ5/elMrU0YpYU1qw56RsEODlU4H j62w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721836008; x=1722440808; 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=Vr4cagXRKHoGrtK5CjJX/9SHrVXecHUstDwjaCnMSGk=; b=pqhZzuOhYQTMBIcE+V7bPi0c0A9I2Rte/JRVP2Q7vxY9WWGtl8GaH5EGQ46ImGgtg7 Ovs9Jj3sjSCbz5aKO1gLD0Mz3pdu9wUPYIU+eXg4qTORbuJgG+DX3USiHA/tpNEOJrSy mYEzWZa8lTFbiBTEHxxZzmuyE7zb4g3WpozqQqu9vvH9PD3MKM6DdPtVNVFNbfEmbD3K O48V+QaNPIIyRgXVU7rsf9ktWnnLFeS+ocVaFlWfrFnYrUzYNFET0j+rVN3ZLUptkE7A HBQmHstT/jj9xy7DOQ+OYr046PCwu1CPC8E49d+i8t2GtSUyhUK0FcHiIa+yWszb8WGT GZ7g== X-Gm-Message-State: AOJu0YzUKpMX2MY8IJama/60NqQcaQZUVQhuE55LcrTvOlx6AlDUpUzn pUL+I+0bcn2Q4BImgoZN1HZW+a3A1CeP2PiRfMigE9nlUgMEzW+z6zHcKQ== X-Google-Smtp-Source: AGHT+IFMB7GeTSegAyHpd8DAegjjw69MqBMyhyt+r2NsZaw7iWEY8WKDwoiDpC5AqgMUNgSWsJe9Ag== X-Received: by 2002:a05:6830:3883:b0:703:5b40:1925 with SMTP id 46e09a7af769-7092e76183bmr104610a34.28.1721836007886; Wed, 24 Jul 2024 08:46:47 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a199013905sm589001485a.67.2024.07.24.08.46.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:46:47 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 1/5] dpp: factor out PKEX/DPP start prep into function Date: Wed, 24 Jul 2024 08:46:37 -0700 Message-Id: <20240724154641.1461593-1-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to slightly rework the DPP state machine to handle automatically disconnecting (for enrollees) functions need to be created that isolate everything needed to start DPP/PKEX in case a disconnect needs to be done first. --- src/dpp.c | 64 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 36 insertions(+), 28 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index 567fe8d2..6f05aae9 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -3927,12 +3927,34 @@ static void dpp_start_presence(struct dpp_sm *dpp, uint32_t *limit_freqs, dpp_start_offchannel(dpp, dpp->current_freq); } +static void dpp_start_enrollee(struct dpp_sm *dpp) +{ + uint32_t freq = band_channel_to_freq(6, BAND_FREQ_2_4_GHZ); + + dpp->uri = dpp_generate_uri(dpp->own_asn1, dpp->own_asn1_len, 2, + netdev_get_address(dpp->netdev), &freq, + 1, NULL, NULL); + + l_ecdh_generate_key_pair(dpp->curve, &dpp->proto_private, + &dpp->own_proto_public); + + l_debug("DPP Start Enrollee: %s", dpp->uri); + + /* + * Going off spec here. Select a single channel to send presence + * announcements on. This will be advertised in the URI. The full + * presence procedure can be implemented if it is ever needed. + */ + dpp_start_presence(dpp, &freq, 1); + + dpp_property_changed_notify(dpp); +} + static struct l_dbus_message *dpp_dbus_start_enrollee(struct l_dbus *dbus, struct l_dbus_message *message, void *user_data) { struct dpp_sm *dpp = user_data; - uint32_t freq = band_channel_to_freq(6, BAND_FREQ_2_4_GHZ); struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); if (dpp->state != DPP_STATE_NOTHING || @@ -3949,30 +3971,14 @@ static struct l_dbus_message *dpp_dbus_start_enrollee(struct l_dbus *dbus, } else if (!station) l_debug("No station device, continuing anyways..."); - dpp->uri = dpp_generate_uri(dpp->own_asn1, dpp->own_asn1_len, 2, - netdev_get_address(dpp->netdev), &freq, - 1, NULL, NULL); - dpp->state = DPP_STATE_PRESENCE; dpp->role = DPP_CAPABILITY_ENROLLEE; dpp->interface = DPP_INTERFACE_DPP; - l_ecdh_generate_key_pair(dpp->curve, &dpp->proto_private, - &dpp->own_proto_public); - - l_debug("DPP Start Enrollee: %s", dpp->uri); + dpp_start_enrollee(dpp); dpp->pending = l_dbus_message_ref(message); - /* - * Going off spec here. Select a single channel to send presence - * announcements on. This will be advertised in the URI. The full - * presence procedure can be implemented if it is ever needed. - */ - dpp_start_presence(dpp, &freq, 1); - - dpp_property_changed_notify(dpp); - return NULL; } @@ -4246,19 +4252,12 @@ static void dpp_pkex_scan_destroy(void *user_data) dpp->pkex_scan_id = 0; } -static bool dpp_start_pkex_enrollee(struct dpp_sm *dpp, const char *key, - const char *identifier) +static bool dpp_start_pkex_enrollee(struct dpp_sm *dpp) { _auto_(l_ecc_point_free) struct l_ecc_point *qi = NULL; - if (identifier) - dpp->pkex_id = l_strdup(identifier); - - dpp->pkex_key = l_strdup(key); memcpy(dpp->peer_addr, broadcast, 6); - dpp->role = DPP_CAPABILITY_ENROLLEE; - dpp->state = DPP_STATE_PKEX_EXCHANGE; - dpp->interface = DPP_INTERFACE_PKEX; + /* * In theory a driver could support a lesser duration than 200ms. This * complicates things since we would need to tack on additional @@ -4376,7 +4375,16 @@ static struct l_dbus_message *dpp_dbus_pkex_start_enrollee(struct l_dbus *dbus, if (!dpp_parse_pkex_args(message, &key, &id)) goto invalid_args; - if (!dpp_start_pkex_enrollee(dpp, key, id)) + dpp->pkex_key = l_strdup(key); + + if (id) + dpp->pkex_id = l_strdup(id); + + dpp->role = DPP_CAPABILITY_ENROLLEE; + dpp->state = DPP_STATE_PKEX_EXCHANGE; + dpp->interface = DPP_INTERFACE_PKEX; + + if (!dpp_start_pkex_enrollee(dpp)) goto invalid_args; return l_dbus_message_new_method_return(message); From patchwork Wed Jul 24 15:46:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13741131 Received: from mail-oo1-f54.google.com (mail-oo1-f54.google.com [209.85.161.54]) (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 692C415DBBA for ; Wed, 24 Jul 2024 15:46:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836011; cv=none; b=bCanNAANuJpksHOd4wGhW9bsQVjF39diYjeKs9zp3DWiLg4HBVLFDKhMp8IhYniX7kP9Sf8O5pU8qmeECo0p3bXx56gHinky4qjslAhOnAaacX3tMqQJsAsrtZxTTEbGHiI55nl5PpO1nFfwbppF/Fn6R1Av2mTeav93VBdGyXw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836011; c=relaxed/simple; bh=KovdUaiRySIwerb98Kd+zhsa3wjgebvYTwUnK+k+Em0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GriRyndgzLgVzbck59BEi7dNwk++SlzB5LQqLTG4yDAkNr4lw8NDeGi+jqMOsLWLeZDlbWI17ZkLf96Yryo2cHPNMOAmQqUBGKBD8q1ZIbx5mEfL25oPRNiojtS79BxwZgm0cPsFgEL64jLY5RZXntwzt1o4lx6kyMxfhNAew34= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=DRQeNvU3; arc=none smtp.client-ip=209.85.161.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="DRQeNvU3" Received: by mail-oo1-f54.google.com with SMTP id 006d021491bc7-5cdf7edddc5so1187eaf.0 for ; Wed, 24 Jul 2024 08:46:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721836009; x=1722440809; darn=lists.linux.dev; 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=ATevjVQZFZhSyTTg7te/+mB6KTD3bHMCcurSBbbb+Ow=; b=DRQeNvU3P1mzjFCc8cW0nSOPRtIesa7pcLkjEsqQfs45J34MUGWfLL/XD0mBSGmqXc p5levLxoUBlszxYe49TlBbGE+dqn0oUKWozL9PKJ6KnXVlWzxyzeGFRQGcvBjl40XsK1 JfkuTfyyiU5chO3CCu2gy/pfTmYXscgxW2ZkUdrRAabtuoFh5mkei3ZS868hjxwerHoD 748t8vLgpgj8yweQTRunTLEd1nBx6qJee1RK4KzDPkU2I+5ezMN94U7922Ofy6FDN/Gu H9JYXsZtRiK1+7fnJJUZyRaNvpQ4Ny8Gp01/o5vSzJEYemR2fBXgdrIk0nC41vWgIcrp GbHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721836009; x=1722440809; 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=ATevjVQZFZhSyTTg7te/+mB6KTD3bHMCcurSBbbb+Ow=; b=SYS4bIGr9UR+aWmBsU1kJbkv5un8F1Iv+EnmFhkQghjbTBEjisrIXJgpkAL+antblG F8+EE+EXpNEJ4963SiL7LSJvCYkixSQ6UWjbK1qV4Poy1+itOm77cXAoLrMzbIT0gj/a uPjoZv9ZAJHjqKNpru/y7fdNCc4/mZd+GBIglWrKAvqU9+mlD0K1PpAId2hytQl5OelL WVLCiTzlEikUr4tRl9o5CtNHgROxDKWdeYuZGhLJUcIRdK9Zk1kAyo2aNawz2Lbbgba9 +arT7gyhSH1hswPppaEPoHo7K/85mABaDq0mxlqiJQtM71QcP2AFDxnll2HibTyXkczt h7aA== X-Gm-Message-State: AOJu0YwzIfLS2IOKQQevcrD0EnimcAakQTDRVDR4sr6Z2GORfO3lQxXD c4Ru3FTTMzMC/7mN2ZCCoIccWqJCjhIDcMyYz3L1TFkusRA/DWlSnxA5Wg== X-Google-Smtp-Source: AGHT+IGBfcTM2gnRXNNG2JPNU2sn6BCejb6txGU2TE/z2uBZ8G0HRFyk15iCD1eLFFKbl8KsUuip+A== X-Received: by 2002:a05:6358:e4a3:b0:1ac:f13e:49ab with SMTP id e5c5f4694b2df-1acf891a11fmr29484155d.26.1721836009069; Wed, 24 Jul 2024 08:46:49 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a199013905sm589001485a.67.2024.07.24.08.46.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:46:48 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 2/5] station: add station_get_autoconnect Date: Wed, 24 Jul 2024 08:46:38 -0700 Message-Id: <20240724154641.1461593-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240724154641.1461593-1-prestwoj@gmail.com> References: <20240724154641.1461593-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Gets the current autoconenct setting. This is not the current autoconnect state. Will be used in DPP to reset station's autoconnect setting back to what it was prior to DPP, in case of failure. --- src/station.c | 5 +++++ src/station.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/station.c b/src/station.c index ca0e6a38..db069981 100644 --- a/src/station.c +++ b/src/station.c @@ -1726,6 +1726,11 @@ bool station_set_autoconnect(struct station *station, bool autoconnect) return true; } +bool station_get_autoconnect(struct station *station) +{ + return station->autoconnect; +} + static void station_roam_state_clear(struct station *station) { l_debug("%u", netdev_get_ifindex(station->netdev)); diff --git a/src/station.h b/src/station.h index a38327e4..50f0be12 100644 --- a/src/station.h +++ b/src/station.h @@ -88,6 +88,7 @@ uint32_t station_add_event_watch(station_event_watch_func_t func, void station_remove_event_watch(uint32_t id); bool station_set_autoconnect(struct station *station, bool autoconnect); +bool station_get_autoconnect(struct station *station); int __station_connect_network(struct station *station, struct network *network, struct scan_bss *bss, enum station_state state); From patchwork Wed Jul 24 15:46:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13741132 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.178]) (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 CCD3926287 for ; Wed, 24 Jul 2024 15:46:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836013; cv=none; b=C6ArbStEoc6pzPvSU8CJSZkGK2LX1dpN6kndkBRhjHEchB1JQnPxxaYjE/fUbj8frKXFJD//h7U+DlrCr9D85lwXRJ6VVqaLM3aNsm3byjSxoM3slptKYoCR33VRhf4NrRanmQruv3KVGi8Zm/+UkmDxEnrvQkak2R/bpLawVN8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836013; c=relaxed/simple; bh=OOGTiGgLTeU7mlHLVPiqWqc0PjC1RxhI6e6KCUE29ik=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EVSAbDjjkt023VuUq0OoDo7PbHVyRklfzZfFmIWh4iNR8l9F3LAIxn9UnXMBYevhSUDT305chxOyoYYuYDXJn63KscBmZK8mV/dYVitV3u3GkecKRa6ev30P2w8fIfff1LKY2BBxgicKFstBInPmoRiBO91APuJ4yz6BFHevUhw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZgYFDjmA; arc=none smtp.client-ip=209.85.222.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZgYFDjmA" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7a1c4475113so97228185a.1 for ; Wed, 24 Jul 2024 08:46:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721836010; x=1722440810; darn=lists.linux.dev; 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=NnLC1m5xQAW3JJxH0wKuVck7tULL6CKQ4NXfkNZDcWM=; b=ZgYFDjmAnP2wAlO/ihttVAKI92iCDCjx6tPtRt1OHfGsgW+9CZhmiG6FkypYE3+W/i 44MMiXSksYcWrOytm3AJkFKP/p8/SR2p+Z0n245ayI0hHkpawc6FJBahDPMAeYJbG/SW SI6x9Ia7lQHCqQBQbqHEGdLACG6TOS/FX3HRJpV1ZAcVH9JKioPIVoDZ6LggfU+pC8ax 7cZcdQCoFEMX0aYpUlE+P1ImYtQuEeEeLFQevKFWaAgPR+W7/ZCwJGTu7Yl9vTuPG1Wu /2HoEKkU0hkVhRP8muV4/wKe+PFYyUUYyMNxErgYJPg4oyW5cS8AAx/MTqST/Egf8JsT KSlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721836010; x=1722440810; 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=NnLC1m5xQAW3JJxH0wKuVck7tULL6CKQ4NXfkNZDcWM=; b=n/wAdNSD9jU9YIWHoS/PuePBkJSNPEny+rZU1JKZa1OvFCALL0Fmot5DaBzflVfUQC Xcv+nJRtb0p+ecG103JaItTrcIxLEwpGD0ukybRANVL5GEd6zPluVd17MBKZePN04aqu oH7JaM0FX5mEHoWfXaTJgs2VFtCiqnUy+prDkKdLz5aSW31581R/NsiPlpkePoqwa9Gx pBcmxEu0LSrb7UjcLyzZkqoQImWtP9+FieCUq+mDDzPIelpAn7miPNLq3cVno74YijkT iC8nO+0CA9C9XHJJ1Zw1OWXch2MjXYDKDODgw5PsnvdMX2dAKoOASTvb+QpCgKoqEuHC v40Q== X-Gm-Message-State: AOJu0YwOfJW6p4PesIWGcSDu1vDBQL71n+Mv75aD/OcqAOifk2drYGSQ CqLrzLuvF1ZJgQZ2r608DUALmjAjy+Yyis6FdMrQkfNhoynnLG4ym+CtKA== X-Google-Smtp-Source: AGHT+IGJne6NmKUUB09DwpNmrwfuevoMeM5BakJt4Pu8m434+6RfvkySElPIzB5FGC4eo3B14Qbm8A== X-Received: by 2002:a05:620a:460c:b0:7a1:456b:fd69 with SMTP id af79cd13be357-7a1d5cbe6cemr7988085a.20.1721836010367; Wed, 24 Jul 2024 08:46:50 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a199013905sm589001485a.67.2024.07.24.08.46.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:46:50 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 3/5] dpp: explicitly disconnect station if enrollee is started Date: Wed, 24 Jul 2024 08:46:39 -0700 Message-Id: <20240724154641.1461593-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240724154641.1461593-1-prestwoj@gmail.com> References: <20240724154641.1461593-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Prior to now the DPP state was required to be disconnected before DPP would start. This is inconvenient for the user since it requires extra state checking and/or DBus method calls. Instead model this case like WSC and issue a disconnect to station if DPP is requested to start. The other conditions on stopping DPP are also preserved and no changes to the configurator role have been made, i.e. being disconnected while configuring still stops DPP. Similarly any connection made during enrolling will stop DPP. It should also be noted that station's autoconfigure setting is also preserved and set back to its original value upon DPP completing. --- src/dpp.c | 198 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 147 insertions(+), 51 deletions(-) v2: * Used an bool out parameter to distinguish if a disconnect is in progress as opposed to a true/false/< 0 return diff --git a/src/dpp.c b/src/dpp.c index 6f05aae9..d89c3056 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -193,6 +193,7 @@ struct dpp_sm { bool roc_started : 1; bool channel_switch : 1; bool mutual_auth : 1; + bool autoconnect : 1; }; static const char *dpp_role_to_string(enum dpp_capability role) @@ -469,6 +470,8 @@ static void dpp_free_auth_data(struct dpp_sm *dpp) static void dpp_reset(struct dpp_sm *dpp) { + struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); + if (dpp->uri) { l_free(dpp->uri); dpp->uri = NULL; @@ -549,12 +552,19 @@ static void dpp_reset(struct dpp_sm *dpp) dpp_property_changed_notify(dpp); dpp->interface = DPP_INTERFACE_UNBOUND; + + if (station) { + if (dpp->station_watch) + station_remove_state_watch(station, dpp->station_watch); + + /* Set the old autoconnect state back to what it was */ + if (dpp->role == DPP_CAPABILITY_ENROLLEE) + station_set_autoconnect(station, dpp->autoconnect); + } } static void dpp_free(struct dpp_sm *dpp) { - struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); - dpp_reset(dpp); if (dpp->own_asn1) { @@ -572,13 +582,6 @@ static void dpp_free(struct dpp_sm *dpp) dpp->boot_private = NULL; } - /* - * Since this is called when the netdev goes down, station may already - * be gone in which case the state watch will automatically go away. - */ - if (station) - station_remove_state_watch(station, dpp->station_watch); - known_networks_watch_remove(dpp->known_network_watch); l_free(dpp); @@ -3721,6 +3724,9 @@ static void dpp_frame_watch(struct dpp_sm *dpp, uint16_t frame_type, L_UINT_TO_PTR(frame_type), NULL); } +static void dpp_start_enrollee(struct dpp_sm *dpp); +static bool dpp_start_pkex_enrollee(struct dpp_sm *dpp); + /* * Station is unaware of DPP's state so we need to handle a few cases here so * weird stuff doesn't happen: @@ -3734,27 +3740,50 @@ static void dpp_frame_watch(struct dpp_sm *dpp, uint16_t frame_type, * DPP finishes. * * Other conditions shouldn't ever happen i.e. configuring and going into a - * connecting state or enrolling and going to a disconnected/roaming state. + * connecting state or enrolling and going to a roaming state. */ static void dpp_station_state_watch(enum station_state state, void *user_data) { struct dpp_sm *dpp = user_data; - if (dpp->state == DPP_STATE_NOTHING) + if (dpp->state == DPP_STATE_NOTHING || + dpp->interface == DPP_INTERFACE_UNBOUND) return; switch (state) { case STATION_STATE_DISCONNECTED: + /* DPP-initiated disconnect, the enrollee can now start */ + if (dpp->role == DPP_CAPABILITY_ENROLLEE) { + l_debug("Starting enrollee after disconnect"); + + if (dpp->interface == DPP_INTERFACE_DPP) + dpp_start_enrollee(dpp); + else + dpp_start_pkex_enrollee(dpp); + + return; + } + + break; case STATION_STATE_DISCONNECTING: + /* Normal part of disconnecting prior to enrolling */ + if (dpp->role == DPP_CAPABILITY_ENROLLEE) + return; + + /* fall through */ case STATION_STATE_ROAMING: case STATION_STATE_FT_ROAMING: case STATION_STATE_FW_ROAMING: + /* + * An enrollee will always be disconnected prior to starting + * so a roaming condition should never happen. + */ if (L_WARN_ON(dpp->role == DPP_CAPABILITY_ENROLLEE)) - dpp_reset(dpp); + goto reset; if (dpp->role == DPP_CAPABILITY_CONFIGURATOR) { l_debug("Disconnected while configuring, stopping DPP"); - dpp_reset(dpp); + goto reset; } break; @@ -3762,28 +3791,22 @@ static void dpp_station_state_watch(enum station_state state, void *user_data) case STATION_STATE_CONNECTED: case STATION_STATE_CONNECTING_AUTO: case STATION_STATE_NETCONFIG: - if (L_WARN_ON(dpp->role == DPP_CAPABILITY_CONFIGURATOR)) - dpp_reset(dpp); - - if (dpp->role == DPP_CAPABILITY_ENROLLEE) { - l_debug("Connecting while enrolling, stopping DPP"); - dpp_reset(dpp); - } - - break; - - /* - * Autoconnect states are fine for enrollees. This makes it nicer for - * the user since they don't need to explicity Disconnect() to disable - * autoconnect, then re-enable it if DPP fails. - */ case STATION_STATE_AUTOCONNECT_FULL: case STATION_STATE_AUTOCONNECT_QUICK: - if (L_WARN_ON(dpp->role == DPP_CAPABILITY_CONFIGURATOR)) - dpp_reset(dpp); + /* + * The user could have issued a connection request during + * enrolling, in which case DPP should be canceled. We should + * never hit this case as a configurator as a disconnect would + * need to come prior. + */ + L_WARN_ON(dpp->role == DPP_CAPABILITY_CONFIGURATOR); - break; + goto reset; } + +reset: + l_debug("Resetting DPP after station state change (state=%u)", state); + dpp_reset(dpp); } static void dpp_create(struct netdev *netdev) @@ -3793,7 +3816,6 @@ static void dpp_create(struct netdev *netdev) uint8_t dpp_conf_response_prefix[] = { 0x04, 0x0b }; uint8_t dpp_conf_request_prefix[] = { 0x04, 0x0a }; uint64_t wdev_id = netdev_get_wdev_id(netdev); - struct station *station = station_find(netdev_get_ifindex(netdev)); dpp->netdev = netdev; dpp->state = DPP_STATE_NOTHING; @@ -3839,8 +3861,6 @@ static void dpp_create(struct netdev *netdev) sizeof(dpp_conf_request_prefix), dpp_handle_config_request_frame, dpp, NULL); - dpp->station_watch = station_add_state_watch(station, - dpp_station_state_watch, dpp, NULL); dpp->known_network_watch = known_networks_watch_add( dpp_known_network_watch, dpp, NULL); @@ -3927,6 +3947,64 @@ static void dpp_start_presence(struct dpp_sm *dpp, uint32_t *limit_freqs, dpp_start_offchannel(dpp, dpp->current_freq); } +static int dpp_try_disconnect_station(struct dpp_sm *dpp, + bool *out_disconnect_started) +{ + struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); + int ret; + bool started = false; + + /* Unusual case, but an enrollee could still be started */ + if (!station) + goto done; + + dpp->autoconnect = station_get_autoconnect(station); + station_set_autoconnect(station, false); + + switch (station_get_state(station)) { + case STATION_STATE_AUTOCONNECT_QUICK: + case STATION_STATE_AUTOCONNECT_FULL: + /* Should never happen since we just set autoconnect false */ + l_warn("Still in autoconnect state after setting false!"); + + /* fall through */ + case STATION_STATE_DISCONNECTED: + break; + case STATION_STATE_ROAMING: + case STATION_STATE_FT_ROAMING: + case STATION_STATE_FW_ROAMING: + case STATION_STATE_CONNECTING: + case STATION_STATE_CONNECTING_AUTO: + case STATION_STATE_CONNECTED: + case STATION_STATE_NETCONFIG: + /* + * For any connected or connection in progress state, start a + * disconnect + */ + ret = station_disconnect(station); + if (ret < 0) { + l_warn("failed to start disconnecting (%d)", ret); + station_set_autoconnect(station, dpp->autoconnect); + + return ret; + } + /* fall through */ + case STATION_STATE_DISCONNECTING: + l_debug("Delaying DPP start until after disconnect"); + started = true; + + break; + } + + dpp->station_watch = station_add_state_watch(station, + dpp_station_state_watch, + dpp, NULL); +done: + *out_disconnect_started = started; + + return 0; +} + static void dpp_start_enrollee(struct dpp_sm *dpp) { uint32_t freq = band_channel_to_freq(6, BAND_FREQ_2_4_GHZ); @@ -3955,27 +4033,30 @@ static struct l_dbus_message *dpp_dbus_start_enrollee(struct l_dbus *dbus, void *user_data) { struct dpp_sm *dpp = user_data; - struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); + bool wait_for_disconnect; + int ret; if (dpp->state != DPP_STATE_NOTHING || dpp->interface != DPP_INTERFACE_UNBOUND) return dbus_error_busy(message); - /* - * Station isn't actually required for DPP itself, although this will - * prevent connecting to the network once configured. - */ - if (station && station_get_connected_network(station)) { - l_warn("cannot be enrollee while connected, please disconnect"); - return dbus_error_busy(message); - } else if (!station) - l_debug("No station device, continuing anyways..."); - dpp->state = DPP_STATE_PRESENCE; dpp->role = DPP_CAPABILITY_ENROLLEE; dpp->interface = DPP_INTERFACE_DPP; - dpp_start_enrollee(dpp); + ret = dpp_try_disconnect_station(dpp, &wait_for_disconnect); + if (ret < 0) { + dpp_reset(dpp); + return dbus_error_from_errno(ret, message); + } + + if (!wait_for_disconnect) + dpp_start_enrollee(dpp); + + /* + * If a disconnect was started/in progress the enrollee will start once + * that has finished + */ dpp->pending = l_dbus_message_ref(message); @@ -4111,6 +4192,9 @@ static struct l_dbus_message *dpp_start_configurator_common( dpp_property_changed_notify(dpp); + dpp->station_watch = station_add_state_watch(station, + dpp_station_state_watch, dpp, NULL); + l_debug("DPP Start Configurator: %s", dpp->uri); reply = l_dbus_message_new_method_return(message); @@ -4361,7 +4445,8 @@ static struct l_dbus_message *dpp_dbus_pkex_start_enrollee(struct l_dbus *dbus, struct dpp_sm *dpp = user_data; const char *key; const char *id; - struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); + bool wait_for_disconnect; + int ret; l_debug(""); @@ -4369,9 +4454,6 @@ static struct l_dbus_message *dpp_dbus_pkex_start_enrollee(struct l_dbus *dbus, dpp->interface != DPP_INTERFACE_UNBOUND) return dbus_error_busy(message); - if (station && station_get_connected_network(station)) - return dbus_error_busy(message); - if (!dpp_parse_pkex_args(message, &key, &id)) goto invalid_args; @@ -4384,9 +4466,20 @@ static struct l_dbus_message *dpp_dbus_pkex_start_enrollee(struct l_dbus *dbus, dpp->state = DPP_STATE_PKEX_EXCHANGE; dpp->interface = DPP_INTERFACE_PKEX; - if (!dpp_start_pkex_enrollee(dpp)) + ret = dpp_try_disconnect_station(dpp, &wait_for_disconnect); + if (ret < 0) { + dpp_reset(dpp); + return dbus_error_from_errno(ret, message); + } + + if (!wait_for_disconnect && !dpp_start_pkex_enrollee(dpp)) goto invalid_args; + /* + * If a disconnect was started/in progress the PKEX enrollee will start + * once that has finished + */ + return l_dbus_message_new_method_return(message); invalid_args: @@ -4470,6 +4563,9 @@ static struct l_dbus_message *dpp_start_pkex_configurator(struct dpp_sm *dpp, dpp_reset_protocol_timer(dpp, DPP_PKEX_PROTO_TIMEOUT); dpp_property_changed_notify(dpp); + dpp->station_watch = station_add_state_watch(station, + dpp_station_state_watch, dpp, NULL); + if (dpp->pkex_key) l_debug("Starting PKEX configurator for single enrollee"); else From patchwork Wed Jul 24 15:46:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13741133 Received: from mail-oo1-f49.google.com (mail-oo1-f49.google.com [209.85.161.49]) (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 CF7B215DBAE for ; Wed, 24 Jul 2024 15:46:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836014; cv=none; b=mM5aj8C7VB1EeKFZ2uRLY1sinyJeLcHmggf7MFZbp0Zp8bXe1TgohBJ++bfWt2Q5+j7y+o9HK1GpNAqPZMSIdtvZUma03btoKYdeLVaRUiGdn5Td+DxjwEuedZtd3f4MzfVdOk2wcv0cgKK7q3gn/ZDNpm89df609S4M4gvd8yQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836014; c=relaxed/simple; bh=BJHLYn4a21S7jdJH+9Q1Jmqq1q59HI4hcOCAJMco91g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sC7sVKLMbfWdnu930hd1Y/oxjO9nMaJeDQGEos92YtClvq05nz+YetAlC59oN1LztgucjE6Szegz2nGwe/NoGLEFqI28ukXAFnJi+ZP5S3bf6TI0p6eGQCb1SG9NVdMytvENdAp+HrxPbiKzAp67JjgTBzs2lBHClxwfTMeVpA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i/DElXSz; arc=none smtp.client-ip=209.85.161.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i/DElXSz" Received: by mail-oo1-f49.google.com with SMTP id 006d021491bc7-5d5846f7970so1609103eaf.3 for ; Wed, 24 Jul 2024 08:46:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721836011; x=1722440811; darn=lists.linux.dev; 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=DBXouCzHAGxvW2umhZYkML822JM3qwt4qA7iC1rTMpw=; b=i/DElXSzKKsu6jlGYssBMp1OY/rnO0xAfblBhAWm9l8/3wkUOHG9AJyntmUc0+y9hb y21tbdkypuANCS9nDr7C/QD3HzH70Pv89PDD79gKJoMuvGpsuE7vbaj2afezYl6Z7Sq2 8fZDSXGANoMNqcMbEi2RcuUkMMJTUFJlgaD1X0RlZJNvE9DJFpLBXWazO2gPxu3xnDEe 9PmkK7ZDagLS2eYfI+xr+Kilvsr+XG3gFdyXOJzx32YnLoBkPQrG7+lLam8DaL8l9FVl E4vL05pBkpBLJVcGzwpbMAtiQIyzT9MC1SS0PzGoHvt/ifT3vMNo/U1QsmNrX6DonX5M ybCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721836011; x=1722440811; 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=DBXouCzHAGxvW2umhZYkML822JM3qwt4qA7iC1rTMpw=; b=vJ6j/7rf9gIOvxuTrUaiLePv/TlpwT8aqkcbCuj6YbzjnTvmky2umd+iQaupKxNE07 b8/AhkT9myk1TFFgMhNkqE/giO1/4lG6HSYQVSi6ATzzkR4kjE7GZyAIVpNQILgC6ujF zK7VV85PT4pZkJl+ACVoMB1pAY4rvLCJUQnTQhmV5PRR2n6rj9jL/7D2eXm/TAojdeDx wgUU0JrlcKjShbXiq+oQLGlmWXqkRkRsMT8Vg6qr3ZKSmy7I910DcAk/eMa+aiFGpQG0 RieNvIMaKvdF1ACUMVsZhYnocrLdP6k30GQ1Dlw8oITqwpXzWsa2wk406MppF9ee+ro+ DyzA== X-Gm-Message-State: AOJu0YxuwVF6PgLROU4c80l5DEMGPbEuBeuHKrwAwcH0vvks1dm17RLA jL7EeFa7C+2dQbAP6tp6qjIZbJIIXauF0TPT/qUf0nRwl65CmH8CIylQ3w== X-Google-Smtp-Source: AGHT+IHB23mEOpTFePnTiAxnTvNKkClTw1iB2i97taoh4VDd8PM/fR7KOGgojvYmzpNTQKNKQu0QoA== X-Received: by 2002:a05:6358:3389:b0:1aa:c4ea:8e5e with SMTP id e5c5f4694b2df-1acf8a32cfdmr27440155d.13.1721836011490; Wed, 24 Jul 2024 08:46:51 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a199013905sm589001485a.67.2024.07.24.08.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:46:51 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 4/5] auto-t: add DPP tests for state change checks Date: Wed, 24 Jul 2024 08:46:40 -0700 Message-Id: <20240724154641.1461593-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240724154641.1461593-1-prestwoj@gmail.com> References: <20240724154641.1461593-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- autotests/testDPP/pkex_test.py | 20 ++++- autotests/testDPP/state_change_test.py | 107 +++++++++++++++++++++++++ 2 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 autotests/testDPP/state_change_test.py diff --git a/autotests/testDPP/pkex_test.py b/autotests/testDPP/pkex_test.py index db355225..3d3ea6d1 100644 --- a/autotests/testDPP/pkex_test.py +++ b/autotests/testDPP/pkex_test.py @@ -4,7 +4,7 @@ import unittest import sys sys.path.append('../util') -from iwd import IWD, SharedCodeAgent +from iwd import IWD, SharedCodeAgent, DeviceState from iwd import DeviceProvisioning from wpas import Wpas from hostapd import HostapdCLI @@ -210,6 +210,24 @@ class Test(unittest.TestCase): self.assertIn("SendHostname=true", settings) + def test_existing_incorrect_profile(self): + self.hapd.reload() + self.hapd.wait_for_event('AP-ENABLED') + IWD.copy_to_storage("existingProfile.psk", "/tmp/ns0/", "ssidCCMP.psk") + + # Start connecting + self.device[1].autoconnect = True + self.wd.wait_for_object_condition(self.device[1], 'obj.state == DeviceState.connecting') + + # We should be able to start DPP despite the connecting state + self.device[1].dpp_pkex_enroll('secret123', identifier="test") + + self.start_iwd_pkex_configurator(self.device[0]) + self.assertEqual(self.device[1].state, DeviceState.disconnected) + + condition = 'obj.state == DeviceState.connected' + self.wd.wait_for_object_condition(self.device[1], condition) + def test_existing_hidden_network(self): self.hapd_hidden.reload() self.hapd_hidden.wait_for_event('AP-ENABLED') diff --git a/autotests/testDPP/state_change_test.py b/autotests/testDPP/state_change_test.py new file mode 100644 index 00000000..d52f2b12 --- /dev/null +++ b/autotests/testDPP/state_change_test.py @@ -0,0 +1,107 @@ +#!/usr/bin/python3 + +import unittest +import sys + +sys.path.append('../util') +from iwd import IWD, SharedCodeAgent, DeviceState +from iwd import DeviceProvisioning +from wpas import Wpas +from hostapd import HostapdCLI +from hwsim import Hwsim +from config import ctx +from time import time +import os + +class Test(unittest.TestCase): + def auto_connect(self): + IWD.copy_to_storage('ssidCCMP.psk') + self.device.autoconnect = True + + condition = 'obj.state == DeviceState.connected' + self.wd.wait_for_object_condition(self.device, condition) + + def test_configurator_stops_on_disconnect(self): + self.auto_connect() + + self.device.dpp_start_configurator() + + self.device.disconnect() + + condition = 'obj.state == DeviceState.disconnected' + self.wd.wait_for_object_condition(self.device, condition) + + self.assertEqual(self.device._device_provisioning.started, False) + + def test_enrollee_stops_on_connect(self): + # Scan to get a list of networks + self.device.scan() + self.wd.wait_for_object_condition(self.device, 'obj.scanning == True') + self.wd.wait_for_object_condition(self.device, 'obj.scanning == False') + + self.device.dpp_start_enrollee() + + network = self.device.get_ordered_network("ssidCCMP") + network.network_object.connect() + + condition = 'obj.state == DeviceState.connected' + self.wd.wait_for_object_condition(self.device, condition) + + self.assertEqual(self.device._device_provisioning.started, False) + + def test_enrollee_disconnects_automatically(self): + self.auto_connect() + + self.device.dpp_start_enrollee() + + condition = 'obj.state == DeviceState.disconnected' + self.wd.wait_for_object_condition(self.device, condition) + + def test_enrollee_autoconnect_stays_on(self): + # Put in an autoconnecting state, no saved profile though + self.device.autoconnect = True + + self.device.dpp_start_enrollee() + + # DPP should set autoconnect false, but then re-enable after it stops + self.wd.wait_for_object_condition(self.device, "obj.autoconnect == False") + self.wd.wait_for_object_condition(self.device._device_provisioning, "obj.started == True") + + # Stop DPP + self.device.dpp_stop() + self.wd.wait_for_object_condition(self.device, "obj.autoconnect == True") + + def test_enrollee_autoconnect_stays_off(self): + # Autoconnect should be off by default + + self.device.dpp_start_enrollee() + + # DPP should set autoconnect false, but stay off after it stops + self.wd.wait_for_object_condition(self.device, "obj.autoconnect == False") + self.wd.wait_for_object_condition(self.device._device_provisioning, "obj.started == True") + + # Stop DPP + self.device.dpp_stop() + self.wd.wait_for_object_condition(self.device, "obj.autoconnect == False") + + def setUp(self): + self.wd = IWD(True) + self.device = self.wd.list_devices(1)[0] + + def tearDown(self): + self.wd.stop() + self.wd = None + + @classmethod + def setUpClass(cls): + hapd = HostapdCLI(config="hostapd.conf") + hapd.reload() + + hapd.wait_for_event("AP-ENABLED") + + @classmethod + def tearDownClass(cls): + pass + +if __name__ == '__main__': + unittest.main(exit=True) \ No newline at end of file From patchwork Wed Jul 24 15:46:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13741134 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 46D5815AD9C for ; Wed, 24 Jul 2024 15:46:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836015; cv=none; b=hvzo71YEJO8Q8rl8QxTXLpCW22WYbmD/y2OWAqTn3eduvbhukm8FeVVIMRNH86uwnnnF60FR77Xizo6WifK81IUwR8ESw796zm+nQgNBnhF/jjt8g1nwksVpJy5dPypw4QEJ1g6KZHSs4lChhcUswFqvpZEww5f9234Z/ldeWrc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721836015; c=relaxed/simple; bh=mCt6Xtmel1g2crR4xVoXnJOIqgOGjh07XWdEPK1P49E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=NfA7343O9VRFBaJLt85RholJa638/pghIzf9qZX0Ud/foUCATwsEvpSGuxQrfxVVuiev2YMVN19Mb8yHxsM6Z7bToQSMZPeM9aIrP1TDzyTrQxnOPCpiA5OJoOzqkTdBU2DKPsT4XaslzBgqEdHumpubjYioLHaBJWh4u/uUp6k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gGxg3+fu; arc=none smtp.client-ip=209.85.210.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gGxg3+fu" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-7044c085338so3884977a34.2 for ; Wed, 24 Jul 2024 08:46:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721836013; x=1722440813; darn=lists.linux.dev; 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=/cgZmPeKwEp2fof8B0EwCkazZEK5jk3BKEv55QGJ6d0=; b=gGxg3+fuxDuxmVcXxUrbQUipl8b9jXotUtoOXNkI82rQFGWKcM77RlZKe2yuie5+JX VuRwd0CWzpghHCwfqfldfiXI7wcVTUORp9qxniI1YSBTLIM35nQpA/x8+HRQ5RUq8kw6 ie0dlGZbw7npiSfi5uSSLiG+mxHwPtfnnYg0o3NOZ4SF6WwGTXZw/usdONEANEvGsg+T kerEHvj3t/hMwdxpiTvAfAMRGO/f4tkLQOAQDEJzP9b9dMy3fS+THwgM4YVsV3LT5sjR bEk4NVWlhSQ+PXUfOVqHJIS7iHxVinJq9YI3uMpcU2/GmERBc5KRecXEk0m+AmQSmir6 IL1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721836013; x=1722440813; 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=/cgZmPeKwEp2fof8B0EwCkazZEK5jk3BKEv55QGJ6d0=; b=imZXxbbvXR5YOq/7Y3RAB4y/sahIAl0esoLwlgwO+Sfo9Jk/dBJ9oRkwceAq8OkQ86 G20X+pfcv6m+VWKw+5bvHFaI1qm1ZtA6lIrXSa290W2Z5cUw0teTAMgTF0yEU0Yx9oN5 jKmOZzTDLzUzurWnHDyp9XUqhgmbjX6bBDdzUpnC1fGScECQhiCPBKZLSBHmGwlrKMyT 7zd8uW0NI+3fskZvUEqh9Zgsol5z5FMrUepuxEaPQZdGtZKadrewvO3vB8a4mvtO7q7m eT2mzKYRPfOUxOBEKg8YIPwqmkXGyfoJJ0BnCmnA76qrv6LnO8UH8JODvJlBml8LknBQ /yPw== X-Gm-Message-State: AOJu0YxnRuPIpODZLMXsTPhkn+xNVyUa+4ZzoXLgK3HPQ3K2NPhx8G2a oXYQg8TwzJkHXiviIucKX4s1d/o6VA4KCInCrPmid9gJCrPQ/b/t1zVnRA== X-Google-Smtp-Source: AGHT+IE7s9g0JcF0etlXK/1tRqj3b+veRn6EH4N/q4Ih+KnVPHYfObZBlYWXxZ1rvnuB6gRI3QWyDg== X-Received: by 2002:a05:6359:4582:b0:1ac:f00b:8d5c with SMTP id e5c5f4694b2df-1acf889286emr36844655d.8.1721836012722; Wed, 24 Jul 2024 08:46:52 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a199013905sm589001485a.67.2024.07.24.08.46.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jul 2024 08:46:52 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 5/5] auto-t: fix several DPP tests after station state changes Date: Wed, 24 Jul 2024 08:46:41 -0700 Message-Id: <20240724154641.1461593-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240724154641.1461593-1-prestwoj@gmail.com> References: <20240724154641.1461593-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 After the station state changes in DPP setting autoconnect=True was causing DPP to stop prior to being able to scan for the network. Instead we can start autoconnect earlier so we aren't toggling the property while DPP is running. --- autotests/testDPP/connection_test.py | 6 ++---- autotests/testDPP/pkex_test.py | 15 ++++++--------- 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/autotests/testDPP/connection_test.py b/autotests/testDPP/connection_test.py index f72a412d..e4f07af7 100644 --- a/autotests/testDPP/connection_test.py +++ b/autotests/testDPP/connection_test.py @@ -38,20 +38,18 @@ class Test(unittest.TestCase): def test_iwd_as_enrollee_scan_after(self): self.wpas.disconnect() + self.device.autoconnect = True uri = self.device.dpp_start_enrollee() self.wpas.dpp_configurator_create(uri) self.wpas.dpp_configurator_start('ssidCCMP', 'secret123') - self.hapd.reload() - with self.assertRaises(Exception): self.device.get_ordered_network('ssidCCMP', scan_if_needed=False) + self.hapd.reload() self.hapd.wait_for_event('AP-ENABLED') - self.device.autoconnect = True - condition = 'obj.state == DeviceState.connected' self.wd.wait_for_object_condition(self.device, condition) diff --git a/autotests/testDPP/pkex_test.py b/autotests/testDPP/pkex_test.py index 3d3ea6d1..a651c6f6 100644 --- a/autotests/testDPP/pkex_test.py +++ b/autotests/testDPP/pkex_test.py @@ -160,10 +160,8 @@ class Test(unittest.TestCase): def test_pkex_iwd_to_iwd(self): self.start_iwd_pkex_configurator(self.device[0]) - - self.device[1].dpp_pkex_enroll('secret123', identifier="test") - self.device[1].autoconnect = True + self.device[1].dpp_pkex_enroll('secret123', identifier="test") condition = 'obj.state == DeviceState.connected' self.wd.wait_for_object_condition(self.device[1], condition) @@ -176,10 +174,8 @@ class Test(unittest.TestCase): def test_pkex_configurator_with_agent(self): self.start_iwd_pkex_configurator(self.device[0], agent=True) - - self.device[1].dpp_pkex_enroll('secret123', identifier="test") - self.device[1].autoconnect = True + self.device[1].dpp_pkex_enroll('secret123', identifier="test") condition = 'obj.state == DeviceState.connected' self.wd.wait_for_object_condition(self.device[1], condition) @@ -198,8 +194,8 @@ class Test(unittest.TestCase): self.start_iwd_pkex_configurator(self.device[0]) - self.device[1].dpp_pkex_enroll('secret123', identifier="test") self.device[1].autoconnect = False + self.device[1].dpp_pkex_enroll('secret123', identifier="test") condition = 'obj.state == DeviceState.connected' self.wd.wait_for_object_condition(self.device[1], condition) @@ -240,8 +236,9 @@ class Test(unittest.TestCase): self.start_iwd_pkex_configurator(self.device[0], profile='ssidHidden.psk') - self.device[1].dpp_pkex_enroll('secret123', identifier="test") self.device[1].autoconnect = False + self.device[1].dpp_pkex_enroll('secret123', identifier="test") + condition = 'obj.state == DeviceState.connected' self.wd.wait_for_object_condition(self.device[1], condition) @@ -257,8 +254,8 @@ class Test(unittest.TestCase): self.hapd_hidden.wait_for_event('AP-ENABLED') self.start_iwd_pkex_configurator(self.device[0], profile='ssidHidden.psk') - self.device[1].dpp_pkex_enroll('secret123', identifier="test") self.device[1].autoconnect = False + self.device[1].dpp_pkex_enroll('secret123', identifier="test") condition = 'obj.state == DeviceState.connected' self.wd.wait_for_object_condition(self.device[1], condition)