From patchwork Mon Jul 22 18:29:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13739015 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.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 9C62C16C6B0 for ; Mon, 22 Jul 2024 18:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672978; cv=none; b=F4FEwhCxVYLtuNiOc4A63IQDJtq+AxkCW63MIgfyqYOf9wjzsI1LCwn9zZjlKkfrqd2/BtuF2RgjSGtX/E2ax10HulPL0lzY0BvEfDIh7QJ9zraCHayx/HxqXMIAwyqk0VlbWjDQGnUTfo4jMngNTBDIRPc+XXkyZrK69dPD8u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672978; c=relaxed/simple; bh=tagP61yNJmsAJHKBfhm8LSjmJzcOwd3jJl1WkTP1lMI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ND2/5i35Zun68xMlQ5kHToR81/q3ziIoHWrHaD7vb5tU9vjUM7NWY9uRx/pnoAoayP32UEbYXtVUTfNwznf7g2fH76ZTWFeyVmDvdddXjfxmiFAWlLdeZzNl2Y4qeQw8cWJo8QZCbEm8kfJb16lf+d+V18qcKaxeOiugiVje7/8= 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=WYYcwPPV; arc=none smtp.client-ip=209.85.214.179 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="WYYcwPPV" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1fb3b7d0d3aso26421455ad.2 for ; Mon, 22 Jul 2024 11:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721672975; x=1722277775; 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=WYYcwPPVsG82D1nwLl5E9rybmgEmmwb4UjB4/HXfiNhLD1o1yWVjZLiUC66Pa9Lhbn FlK8dpoRSNwOtliRCam+8gfdWfHCfN8RpoATS+/SNHDsqEZGQxuC/yKsiaWldHxHZOcB H96K+7NxSfvW3CQUgGMiVRzIl6/8RH6u3ejMKborg9MgZhHUV6G2GXVOYcZdkAw0PW/Z mAzTbKYEu2i3Shhd0aBO5DLxOmyVLCauEfKQlvNpPcQSwU3+CDNOHBBNt2/XwCcSfoBI Qb1OKl0krLXpA1z6Ne9nvvRLvB5HshcKKU+PEKY7auX35qABpsl4N0LQJsBMJWRjCJDT pbeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721672975; x=1722277775; 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=s6KY/k9As2cVsQG9I2C7lyZgOLpqdHL+rzfGsaL3Y6utIW2NI16GImYeirJIqYdPoK hRHu0DtT02VhGDztx6cQJY/avPCFJNHsqZhadIhXsTWcDYLqnnTr5w+p8N5CPzkq0RwQ LbmlpyzPYZkIxwq1uPDbgimUXdkowaOqkPu7v4kVAUDRCL/68i8MWwpT/56GE92n/5pP mS/UpAXoLz/rhTSqPleNl31Hn7DmnSZhLF4zrIhRp8l/nv/8439ApLkaGAnWDXvtypl7 dGG1Mo3vwzhX151gOT0dRq8UQlpLVQLL84nqf4IQkDxrMxKZSmzs05QcLKxqTMoLMypM Ea+Q== X-Gm-Message-State: AOJu0YxA9pQmva7MFRnJm910m1JWlwOjVoOUz1Gne1kNgvN9+rON+f0E Sf10msM77yNa1KmM4nHorMLwcsQE/JCXmE+ZMQF2gKewWKIwHluYzgpNOQ== X-Google-Smtp-Source: AGHT+IEUfNIw8aqPQt2qS8a/qfF81HzEaQ0+TzOY7KE+CZWS/uhTqLu4mnYbsB4bLr5P0+Ds3KBwCw== X-Received: by 2002:a17:903:190:b0:1fd:93d2:fb76 with SMTP id d9443c01a7336-1fd93d30197mr33752215ad.31.1721672975269; Mon, 22 Jul 2024 11:29:35 -0700 (PDT) Received: from LOCLAP699.localdomain (h69-130-12-20.bendor.broadband.dynamic.tds.net. [69.130.12.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd8dff753bsm33622625ad.243.2024.07.22.11.29.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 11:29:34 -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: Mon, 22 Jul 2024 11:29:28 -0700 Message-Id: <20240722182932.4091008-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 Mon Jul 22 18:29:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13739016 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.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 31CCA16C849 for ; Mon, 22 Jul 2024 18:29:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672978; cv=none; b=qFcMSswCk/+VF+hN/BLk2pPOJGP/0KGl+msxUV+NNsuzGOEXJ09ymw2QY6+5qFRMQDXfTGx/A7sMacsqI/x27Dixye1/frV6hr3nIPdZ5Nk4RBTK2vbXxxZxQi/R0mysVCm6qZ5odXQA0K+mkPoy9q6rrkOlsSpi0s0pVT7a3CU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672978; c=relaxed/simple; bh=KovdUaiRySIwerb98Kd+zhsa3wjgebvYTwUnK+k+Em0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ECA8TG26tWJbXszQH5aE4/KdIp/HveX9YpsLt8aChPrbCZ8igXvrT8SWjG1wptyddUyCT0dpUv44wcoYiCgkYoUNnEhKugIKl9HQ5ifUllZEjDIDS6O2Z1w9uUwk/46uHZwlPkAcUHuP4LzysiPWIiv8+g7tTM1DBJeTvxGzPbc= 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=Qzw18BMu; arc=none smtp.client-ip=209.85.214.180 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="Qzw18BMu" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1fc56fd4de1so265645ad.0 for ; Mon, 22 Jul 2024 11:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721672976; x=1722277776; 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=Qzw18BMuAPh6Pp1+ZwfnpxlDb0c8fklNP2aBViTzLyRtJysotGS+aMB5kcuuc6+edK pQCa7f9E4WfCprY3tblaeuiLxu9wgXeOrt9P62+QIKp/RqsxYPYvrwlRSHT+SaCtWDo4 JQDYbKEeRukW0CbmUF8LECitKqPUknlel3OSYywZgYh1TedLrghIGfs6sJfxSYxkoRQE /u2EdHInE2JeX3VN6C/XOjWHwfHenOSJtRxJKVSF8xuLM3P7BPg4RHei1lMJLHFEl0Gy m7OaV+zY29o0PTjsGsDGUJ/giGvu73cBgxakz2mj4Pp3DrnrR2JarNX1JlOou8d65Myz Mp6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721672976; x=1722277776; 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=wSrX1/9kCSQtAut3KHucbPD7+WF03TZutLqHhx4T6z7eV4v0/DAUZmbg8PvpO8kyEA kdcLUFc7jPC2z5cQaBHygyk+AAEcPFNkPw/A1uKPSAjBYVoqTnEBWaASwxa1lYD758nP ZKIHss2JChy0zdqBPOM9Nzmopq6HpKI9VnPhscaPKcyD8lwQQyXp+2pGlBHMmZaSby8h qjeK9XiZvuZAgqxzRg7iWxwe28qXpetWlqHlo8g1Odhh518lFb3phg+8kVsmFQEATwAf iMAocsuFFp5ffMPAxBr/CEY+/9qLje5fBZ+pMYHqVVvm3DXwnfL3CuWVbN000+WBl5PB 6ogw== X-Gm-Message-State: AOJu0YxGH7ZCwm1qWsBhC0Jk50Bkl5fkQ71Q1wbMp7eqbxvL8yIlYId5 oxDP2MwHyawt9cQ9AecQhZguCazRPYz22siXsnVyu4lyd7+jx2s++OsmCA== X-Google-Smtp-Source: AGHT+IHefumNCjKUIUGAX7Q5qYTOA4zUY7DVCgwcOFOxEPmXZgEGrNtH8adnN0DZ6bzt4kz/Sb0lOA== X-Received: by 2002:a17:902:dac9:b0:1f9:e2c0:d962 with SMTP id d9443c01a7336-1fc5b63500fmr185969015ad.31.1721672976065; Mon, 22 Jul 2024 11:29:36 -0700 (PDT) Received: from LOCLAP699.localdomain (h69-130-12-20.bendor.broadband.dynamic.tds.net. [69.130.12.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd8dff753bsm33622625ad.243.2024.07.22.11.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 11:29:35 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 2/5] station: add station_get_autoconnect Date: Mon, 22 Jul 2024 11:29:29 -0700 Message-Id: <20240722182932.4091008-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722182932.4091008-1-prestwoj@gmail.com> References: <20240722182932.4091008-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 Mon Jul 22 18:29:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13739017 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.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 6B2CF16C6B0 for ; Mon, 22 Jul 2024 18:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672980; cv=none; b=oVM6Gd2ddozX/xvwME9C8BCcq93Ir8LaAUxhvLopUc6LbI9caIePuruBJ70LKMaWeHiF3d/ndUJJZOCClvXrHNoMqC7rLmU4CjPNNN3XdJfQIQ1EpoS2CX5vGGAaeFQN28n3uAT1W9h90oullNVjZxwu878Qd3qamAZiCdTIWoM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672980; c=relaxed/simple; bh=0aKaNlchXAfpifcJRt69jwR82Y/yUOcGdPTqEana/Iw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hCHR/1Vd/vVChY9KU5Hm0UxHsj1sWMuqKCiPKlq0yfUhCceyX9SYSEBOyOOKJQ43QtcuWEtFAOBHYayK8sZNQwAJfAmJxJK5mf9J5+0hn7X1/FDc2XRg53RI6O0S2i2k+750s2fyXbJtLyHmOYaWoMdmIxewUZKJppSwwTbuFSM= 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=mNX+AuNk; arc=none smtp.client-ip=209.85.214.179 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="mNX+AuNk" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-1fd640a6454so22729505ad.3 for ; Mon, 22 Jul 2024 11:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721672977; x=1722277777; 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=EEMjiconc0/ACjkmCoOZFJDsYrqSNvF3TRXhZUy6ijw=; b=mNX+AuNkQ/8Bh9GGBS31/L5voWy/x+UZ3her3/DA2LBuhmtLRdj+3LROrr76R7nqg5 ANaqE6Y94TTHsD1e2jQjCiGkZfpQKnOXhgCI+f6Ul5hRtcL0u60grEHHwwmFpBAp78w1 Nx3b+N4r3XAXoVFwt88lxbvLS39MbOISwwcsZy7MXdcSWYH9RF/YcPrOs8IwICZjtx3R oU6OnNsx3beKO/isax0jbpDMN5wHsyWIrBXcdrEso0BINAvhLraZWXxnEo34Qv1B+Txq JiSjfgeVHDaZHL7dIC2OZiwA0hVmjyvw+eEIOlhuf/WiBSCKzBrHTUPJHWXZUyshA6Ek JJtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721672977; x=1722277777; 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=EEMjiconc0/ACjkmCoOZFJDsYrqSNvF3TRXhZUy6ijw=; b=f9C7Q0xxXXBnBkn4VRgYtqx10ub/kz4WFcuWd/dt9Y4OpcfD85+obFsC88wdDSecyZ Ntx+CBMubY5TUpJJQpVjV2FCIRwskKBbZOx4LlOnzLidvocDvsImwT8OSSoP+SiQ9AHG MujGWYSEkRoMRwTs3EZY1INWMDSAi3FZf0a6JoZewmX0yetElMjf/UjCr8cH3AKhsoxJ t9INXxOnHkmpNvAWGaQc0GDetYS96eSWg62q+T6RjwZEKN+EtUEcS67/fdyF9urOkAlH JWC/dsjmUeS/sIk/l6hUaLdhW2nYO+vv2k+VgfPsleYrmVGZEqoscU5uHjsHUu1H/gty Mu1w== X-Gm-Message-State: AOJu0Yy4iULxbzggksIWCd9pTIuQx0XifCuKAP9y0g/XkpgUTlWVQZZs zfn+iCAFdCYWme96PZNFDO6Fg4JCQbjcdTg2tfPJe7016yRECAlsfzb39g== X-Google-Smtp-Source: AGHT+IE9wSjVt0e5JVUlzedtMcjvFMxyVyhG8yJ8opGdLuceGBbU4zHCIXv7ktALgGLNl3krte77ng== X-Received: by 2002:a17:902:e88b:b0:1fd:672f:2b34 with SMTP id d9443c01a7336-1fd7457d357mr48764525ad.33.1721672977184; Mon, 22 Jul 2024 11:29:37 -0700 (PDT) Received: from LOCLAP699.localdomain (h69-130-12-20.bendor.broadband.dynamic.tds.net. [69.130.12.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd8dff753bsm33622625ad.243.2024.07.22.11.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 11:29:36 -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: Mon, 22 Jul 2024 11:29:30 -0700 Message-Id: <20240722182932.4091008-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722182932.4091008-1-prestwoj@gmail.com> References: <20240722182932.4091008-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 | 195 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 143 insertions(+), 52 deletions(-) diff --git a/src/dpp.c b/src/dpp.c index 6f05aae9..b04477ca 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_disconnect_started(struct dpp_sm *dpp) +{ + int ret = 0; + struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); + + /* Unusual case, but an enrollee could still be started */ + if (!station) + return false; + + 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: + ret = false; + goto register_watch; + 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) + goto error; + + /* fall through */ + case STATION_STATE_DISCONNECTING: + l_debug("Delaying DPP start until after disconnect"); + + ret = true; + goto register_watch; + } + +error: + l_warn("failed to start disconnecting (%d)", ret); + station_set_autoconnect(station, dpp->autoconnect); + + return ret; + +register_watch: + dpp->station_watch = station_add_state_watch(station, + dpp_station_state_watch, + dpp, NULL); + return ret; +} + 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,27 @@ 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)); + 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_disconnect_started(dpp); + if (ret < 0) { + dpp_reset(dpp); + return dbus_error_from_errno(ret, message); + } else if (ret == false) + 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 +4189,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 +4442,7 @@ 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)); + int ret; l_debug(""); @@ -4369,9 +4450,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,8 +4462,18 @@ 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)) - goto invalid_args; + ret = dpp_disconnect_started(dpp); + if (ret < 0) { + dpp_reset(dpp); + return dbus_error_from_errno(ret, message); + } else if (ret == false) + if (!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); @@ -4470,6 +4558,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 Mon Jul 22 18:29:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13739018 Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 42CEF16C849 for ; Mon, 22 Jul 2024 18:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672980; cv=none; b=b/nlLSTSjhqfFcKjefYAYruczihrrF+35VujYuKmSmgpznaY5EQ9pxpSA/jvyUxe52UQI1AgrtiYtdaTT/WyG0ilpVpPaI9g/5FhzVIOViBGUvo9TIg13EtwEWnen4BxjE6lLIphDtnMVozvPkEiyM5kMSAJsLEqugMnUWfxCkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672980; c=relaxed/simple; bh=BJHLYn4a21S7jdJH+9Q1Jmqq1q59HI4hcOCAJMco91g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jgTE/YqtgC9wTS1n34kua+1r9tVfWfroPBRZjlrffugHpu1hPn2U2hzW94bSlEmnHGphdKZxBeGL9vk3JGXN6qd7UGzdl6TTKY1MW+NIrWCqI01VLcbbNhNK77UUiUpFmnGviGzpL/4KwlwOuDjMdvYdABSQ72qMiy2VnOfpjAI= 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=IwP+emwf; arc=none smtp.client-ip=209.85.214.181 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="IwP+emwf" Received: by mail-pl1-f181.google.com with SMTP id d9443c01a7336-1fc49c1f3e5so34302635ad.1 for ; Mon, 22 Jul 2024 11:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721672978; x=1722277778; 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=IwP+emwfL1yRS6mmXphf8DDSmLDi86gLMsz/ZZvXjOlknx0vC3b2XOj2yGUfDmSIZ9 VusJbKT+/C3FThB6XvcnFfDq+X/+zm/dXYIiukfm4+EsmcN4XhoMnMAJ8jrcttJPmad9 dckL4xwILv/OCtuCIsX+8QVo0fVClW/kE6pNBUJFylrqwZat2kvRXoCZtgY9aNF7dYcw hdaLgi3sTC8MUPH5DshDSJ97q98vxGTHBTzweoY/zldJSI2WARUTyrB1SZQRh4A3cJli uSmMbfl9MGx72PEZ5Ufpl09OQVqMk28L/Q8taeLufN3c3Fd/u8KU5BZVRooaqbWruwSY J/Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721672978; x=1722277778; 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=KEo6u7ryjfw8/zE1XwXZuzqRL3hFU+ICXUbHBU1Cv5FyLaAsaytf7GfyD6HVwSIomY 2jDzHr2+tqYWl0MxGS3w9ajLSw3mDCW+xolRj2buBwV3ZJPEONRZbxYAbNsyxv4Aayox d8qroh7hnux3ev/6gxHaUpUJ2Qtiy+JpYQPE+W7ymVzPPPDpqYFnv+JGENo38v/1AXks uGISDBlJHsWlZc5BXr7cz09+0C2VioYf/g/S0su6bLUxxkrr622kmrUmAQdBpZFc8TCv UxI6AnYsT6KK3sioE83+CN+jG2foAtbxfLzPYmoTgY+xftTtUoKl0WxoXFP9d3l07RgS AeBw== X-Gm-Message-State: AOJu0YydUAkMWxEtGDyQE1behbMYG/bx47NB/KhrtvwyD/6LAwuunM07 6dpGfJAhNd8YJBY8UkcB0kh9wtNZy29FsL0fghBEgQcwJ3Sm6Uay50w/wg== X-Google-Smtp-Source: AGHT+IEEgmovHUoPz0OKYfZ/SO/7oop6AmN7hHPvIRhoBCKg1LM9nEK/5yR58DquQziEhM8JDrMt7A== X-Received: by 2002:a17:902:ec90:b0:1fd:9238:40f with SMTP id d9443c01a7336-1fd9238072amr33208245ad.22.1721672978054; Mon, 22 Jul 2024 11:29:38 -0700 (PDT) Received: from LOCLAP699.localdomain (h69-130-12-20.bendor.broadband.dynamic.tds.net. [69.130.12.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd8dff753bsm33622625ad.243.2024.07.22.11.29.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 11:29:37 -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: Mon, 22 Jul 2024 11:29:31 -0700 Message-Id: <20240722182932.4091008-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722182932.4091008-1-prestwoj@gmail.com> References: <20240722182932.4091008-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 Mon Jul 22 18:29:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13739019 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.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 5B72B16FF48 for ; Mon, 22 Jul 2024 18:29:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672981; cv=none; b=dWfRBVyw306SfAbXc3a17Quf5kvsBPWQNa2yRR0gV3LGQQ2p0GytVG1ZuUapCoHqF/obLY361ashT/AJwSdPiXQZqIep9KPAvBedj6yHGVsmlv1Ol07PvdyRqH84vnFMfA0ngUrYwo7RljRNYwAxIaREyFWjOKZVDRg0/W7x9nE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721672981; c=relaxed/simple; bh=mCt6Xtmel1g2crR4xVoXnJOIqgOGjh07XWdEPK1P49E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EocPj5tqDjYeJHYQhSNl597eBGbzaqrIE0jtwS9vnMQd3+qkIoWweCFCZ5c+jEmhaDENeoSEs89UiInyHpjzjSeWFA2jyovsQqZFkFamIy2Ij39viPUziD8gHech+eQNaSb4L14S/YmRd909nuAO4+NyozYW4GTxcxW4k0tp72Y= 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=Alu1RiD0; arc=none smtp.client-ip=209.85.215.180 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="Alu1RiD0" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-7163489149eso3547963a12.1 for ; Mon, 22 Jul 2024 11:29:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721672979; x=1722277779; 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=Alu1RiD0MlTp9mZovgecOrxB3ldPVciGHVBUsByC0FmPHmXG3hDzMKFvieOPvJ0/lc 1CvDOhv0qlVvOliiDdBNWothY6ldwIYnDTikPPYkv3MomxrsZuAHMHQVXcuXn7AWBR1k 41KKpwpDDQx/Uv6UvTthbD9S5oZIxC/HLHL52s9WIqWKRoSS8uxXXv+HmROiJqPbBgVf vcuYD0aphimsWx+JlzVH3ItH8yEaFPW9E+SL3VCZAQTm+RCrUpabu6hjKWOSAkrndKI/ qpFjBXNYs9Nl1TTwkdWRX3+iKsLKo3L+VXqxWhgvG7Iq7/zFczeueycJQNCwhWvOYoCV 17tw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721672979; x=1722277779; 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=NRykzWm8HiKPbQkrXQEk4cdzz651qox+3o696ggtvsu1iWnQJ6CBA5sifLiGsGjtxD IKfMdfqQV1Yv5cmrzyWp8gD80mjumXuhlQRrz2ziYQgU2J7Ao0XHNFYzKKaFRDta5lSK aVgw8lekOTDlbs2A3S9lPL+T8bFjYGZ8+cvTXA3cU04bGhab6o/yuh6Ixz8W77BsGl1F MSO6zuC+MD5/uGPB5KgPen44Gg4d5Ai/k3TxUI3Dz6Rs12asD/yFNc32BFCvtkAFgJyb caE9L6NMMMjEAZBZJp3R9nOKxjVkPLgneiHY29eEZpfuHyFPMhsQX70DfXbpnf47qmhz 0sCg== X-Gm-Message-State: AOJu0YwG0zuannPeSjzQUmWCA3yPS4xU0mMMZToH6BX1fPFknPgkBr6Q dJVHg7As0E6yKLjt1c8mjLbkPPPz6JdovFE7lnnRwtvnfGSoYLppPAkF2w== X-Google-Smtp-Source: AGHT+IEa7ym4GZpU12BxEche2vLV1fMjVlSaWt262UOOMuDzTA2fWHCGm+YvZZC27j8nt5NTohDcNw== X-Received: by 2002:a05:6a21:9986:b0:1be:ca24:9647 with SMTP id adf61e73a8af0-1c4285b75c4mr9861986637.8.1721672979427; Mon, 22 Jul 2024 11:29:39 -0700 (PDT) Received: from LOCLAP699.localdomain (h69-130-12-20.bendor.broadband.dynamic.tds.net. [69.130.12.20]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1fd8dff753bsm33622625ad.243.2024.07.22.11.29.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jul 2024 11:29:38 -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: Mon, 22 Jul 2024 11:29:32 -0700 Message-Id: <20240722182932.4091008-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240722182932.4091008-1-prestwoj@gmail.com> References: <20240722182932.4091008-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)