From patchwork Mon Dec 18 14:12:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13497045 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (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 1E4323A1B6 for ; Mon, 18 Dec 2023 14:12:54 +0000 (UTC) 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="DW3FVgCa" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-67f33cf014cso15354996d6.0 for ; Mon, 18 Dec 2023 06:12:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702908774; x=1703513574; 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=MBVDdlyHnnA0wXrMujX4B4p2w87HUn+cZPW+6YI8iRk=; b=DW3FVgCaF5tOzLP9wakuqpFbeMwI0ixebZ2P0RbZOaSbpEpirqPf0jv0fPMsf7c2G1 SBT0AgIAiC2gIAukLfkwfPTPj9i73mh4Mvzgu6xs+U+kyXrbqzodJ1necC27Is74gUMW YT/yDMGJx+2XqH+b093Jp1U7I5V3L6Y3xJfWOOtSwm0E9ELIKuzO9XN0thAiPpMSUCp5 CU+L9RqjrcSe4lNH8R0xRVTXxAZ7qU2HWs8JK+d0H5nMFTXGfGcLjXI6b0HfoeYxV7KW R/BPuGSUP/vsRBQpsTnX4+1ftJJb/PDih2Qh1UAvZyRLr6qvBkkER5d5a+fqypOC9tp7 dT9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702908774; x=1703513574; 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=MBVDdlyHnnA0wXrMujX4B4p2w87HUn+cZPW+6YI8iRk=; b=xSaaVPV3EM+aqw8R6Rd6kQozZ+cR37Eam4gWh63kS7FPpwcf00gqNpXRS7SAS5449J EmH8b4tK8zi9F7gGQVRsBYxEe10tyGgkONIpQb2PGxdf3BtBUSdv2U1bwL6y9JRH3vSd c8o2DDHh/UaSHhu1Mnn+hilRyDZErStxJyTm3gZDiaQ/u72ylF8juq2emCKCl2e2TJnw Rxvju3ZnkBtgjpsABaAKKF3vyDomg+O8TMbVN4K3cLDTKEPym3lMJgydz1u3G9fNJEjz 7nNQMCqMvRd4XF3JAdAnCYx2BGNJ1qqXVY4O3nQI9lJawQRERBC7XzmtPGhraw61AVVV OJFA== X-Gm-Message-State: AOJu0Yw4nayvMCAY18GovYC5got5CTosVHUBYOrsPKyC6TWs6Ups00SO wXcdFgjhr/zHQO7jLwR4FwoNXek0SHY= X-Google-Smtp-Source: AGHT+IEl+S5IbdWwH1v/+n2pW2K1BWFddQjF+cmy4OofON6US1c9fLx5ynHV7YwzArP0TGz9kzFQ0A== X-Received: by 2002:a05:6214:40c:b0:67a:a721:f32d with SMTP id z12-20020a056214040c00b0067aa721f32dmr22808571qvx.109.1702908773618; Mon, 18 Dec 2023 06:12:53 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id b2-20020a0cbf42000000b0067ec8702d1dsm7816355qvj.137.2023.12.18.06.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 06:12:53 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 1/4] knownnetworks: network: support updating known network settings Date: Mon, 18 Dec 2023 06:12:47 -0800 Message-Id: <20231218141250.202157-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 Currently if a known network is modified on disk the settings are not reloaded by network. Only disconnecting/reconnecting to the network would update the settings. This poses an issue to DPP since its creating or updating a known network after configuration then trying to connect. The connection itself works fine since the PSK/passphrase is set to the network object directly, but any additional settings are not updated. To fix this add a new UPDATED known network event. This is then handled from within network and all settings read from disk are applied to the network object. --- src/knownnetworks.c | 4 ++++ src/knownnetworks.h | 1 + src/network.c | 27 ++++++++++++++++++++++++--- 3 files changed, 29 insertions(+), 3 deletions(-) v2: * Instead of bothering with individual settings we can just use the new l_settings object. This would still prefer agent-obtained creds set into the network object but also honor any new settings written to the profile if there is an ongoing connection. This is a much simpler approach (unless I'm missing something). Only questionable piece is what to do with the Security group. I hesitate to skip it because its what we have on disk, but it could mean the network object isn't synced with its settings. But I'm not sure this is any different than what we have today, if a profile is modified during an ongoing connection its settings (including security) won't get updated until a disconnect/reconnect. * Remove frequency sync on UPDATED event diff --git a/src/knownnetworks.c b/src/knownnetworks.c index d4d50a6f..04ce74ec 100644 --- a/src/knownnetworks.c +++ b/src/knownnetworks.c @@ -468,6 +468,10 @@ void known_network_update(struct network_info *network, known_network_set_autoconnect(network, new->is_autoconnectable); memcpy(&network->config, new, sizeof(struct network_config)); + + WATCHLIST_NOTIFY(&known_network_watches, + known_networks_watch_func_t, + KNOWN_NETWORKS_EVENT_UPDATED, network); } bool known_networks_foreach(known_networks_foreach_func_t function, diff --git a/src/knownnetworks.h b/src/knownnetworks.h index 0a5c9e25..e8ffac0b 100644 --- a/src/knownnetworks.h +++ b/src/knownnetworks.h @@ -35,6 +35,7 @@ struct network_info; enum known_networks_event { KNOWN_NETWORKS_EVENT_ADDED, KNOWN_NETWORKS_EVENT_REMOVED, + KNOWN_NETWORKS_EVENT_UPDATED, }; struct network_info_ops { diff --git a/src/network.c b/src/network.c index 3918ae08..f19482d8 100644 --- a/src/network.c +++ b/src/network.c @@ -2001,7 +2001,8 @@ static void network_update_hotspot(struct network *network, void *user_data) match_hotspot_network(info, network); } -static void match_known_network(struct station *station, void *user_data) +static void match_known_network(struct station *station, void *user_data, + bool new) { struct network_info *info = user_data; struct network *network; @@ -2011,7 +2012,14 @@ static void match_known_network(struct station *station, void *user_data) if (!network) return; - network_set_info(network, info); + if (new) + network_set_info(network, info); + + if (network->settings) + l_settings_free(network->settings); + + network->settings = network_info_open_settings(info); + return; } @@ -2019,17 +2027,30 @@ static void match_known_network(struct station *station, void *user_data) station_network_foreach(station, network_update_hotspot, info); } +static void add_known_network(struct station *station, void *user_data) +{ + match_known_network(station, (struct network_info *)user_data, true); +} + +static void update_known_network(struct station *station, void *user_data) +{ + match_known_network(station, (struct network_info *)user_data, false); +} + static void known_networks_changed(enum known_networks_event event, const struct network_info *info, void *user_data) { switch (event) { case KNOWN_NETWORKS_EVENT_ADDED: - station_foreach(match_known_network, (void *) info); + station_foreach(add_known_network, (void *) info); /* Syncs frequencies of newly known network */ known_network_frequency_sync((struct network_info *)info); break; + case KNOWN_NETWORKS_EVENT_UPDATED: + station_foreach(update_known_network, (void *) info); + break; case KNOWN_NETWORKS_EVENT_REMOVED: station_foreach(emit_known_network_removed, (void *) info); break; From patchwork Mon Dec 18 14:12:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13497046 Received: from mail-qv1-f41.google.com (mail-qv1-f41.google.com [209.85.219.41]) (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 0E9B93A1B9 for ; Mon, 18 Dec 2023 14:12:55 +0000 (UTC) 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="VmJwX7ob" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-67f27a4c6fbso20881646d6.1 for ; Mon, 18 Dec 2023 06:12:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702908775; x=1703513575; 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=3FDQMnG2OHQ2fSTypPJWq7cND67gFwlPxXaqEyxRWIo=; b=VmJwX7ob3YLg1tW1sKWS4sOnubnljuy57eG4SeP/VWhRM7eBH/vm83Yz7hMuNjJdIi pZHhysghq8KcfzSeNv5GpUpc6lZSN7IArAm6BavG2mE1RtUDVJ9jZkpTafrGWK4CBTdT SlAqzZGRUM5/YZJriygPZeXKpWidvoCbodgpJ5kELO79qphH3BhUpzFHFE5NE0O4DgSX yoZssGQbv/yAYqRvakPik9CCI/Hy1JqBwTKpbJ6GCYdCS0L0Ex3BWjscgrDroNwFPqZN tcEjlz8oqpF8vrqrut0DnnG4g2t0iHWZapKkcgCcbfKaRMbYXBR7YbO8kxUI6gGzv0yZ 1mig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702908775; x=1703513575; 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=3FDQMnG2OHQ2fSTypPJWq7cND67gFwlPxXaqEyxRWIo=; b=jUx0hDhvqDJKt8ylKQ4ogZfi2IoA3Ck2Z51lHm8nyWIwj7lhcvoKqGyfA3WLJa8N1Z r+36el9G74nZf+WEipEEcthebzi9eZiN9KSWu1IJm0/MNiBGnD4eh2JGlccW+Mx1OEm6 Gw+gyCoeRVO6Yaqcs1+K5IBPnVrO4+Mr1HiNQ8P6zpq23a/vTxn/R6UJtVQYolZDz08x nao9QvAAQKGy5iRTvBUrRr6RgOBv4paOS1T2GlsZP2XWef7iZFUzlkqQQtD5Kou/xSAU mmVWhmlESqWDMiWoXd41Q4Btm1MhMjk/3Mx7sOlIMY2S6d7vVsRHO4IPXXWdGMolkgT1 EjYA== X-Gm-Message-State: AOJu0Ywb6c3nn6tCU/rlDTqVooBneY78iYwmseKag+1RPzIaZg4Lmm32 UHUEYs1elKb/gjVOEn5SuyE0W0EDzfg= X-Google-Smtp-Source: AGHT+IG/a5b+hAL5ro6DJMwAkV0y1tTtbb1yTkr9F/a8OIKEiKL6ne5bzx1T3glbCxBQ+8NTtnnGLA== X-Received: by 2002:a05:6214:29ca:b0:67f:2e2e:4897 with SMTP id gh10-20020a05621429ca00b0067f2e2e4897mr5339412qvb.80.1702908774613; Mon, 18 Dec 2023 06:12:54 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id b2-20020a0cbf42000000b0067ec8702d1dsm7816355qvj.137.2023.12.18.06.12.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 06:12:54 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 2/4] dpp: fix extra settings not being used when connecting Date: Mon, 18 Dec 2023 06:12:48 -0800 Message-Id: <20231218141250.202157-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218141250.202157-1-prestwoj@gmail.com> References: <20231218141250.202157-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 After DPP completes all settings are written and synced to disk as well as credentials set into the network object itself. The way network/knownnetworks worked at the time did not actually re-load these settings before the connection attempt was made which means that extra settings not set into the network object were not used, i.e. Hidden/Sendhostname. The connection itself always succeeded because the network object was given the credentials directly via setters. Now network and knownnetworks support updating on the directory watch callback and ADDED/UPDATED known network events. Take advantage of this and if the network object already exists after DPP (from a prior scan) wait unil known networks adds/updates the network and issue the connection after that. --- src/dpp.c | 124 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 93 insertions(+), 31 deletions(-) v2: * Fix strerror call to use a positive error code. diff --git a/src/dpp.c b/src/dpp.c index 1ff4b99e..af6574fb 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -53,6 +53,7 @@ #include "src/network.h" #include "src/handshake.h" #include "src/nl80211util.h" +#include "src/knownnetworks.h" #define DPP_FRAME_MAX_RETRIES 5 #define DPP_FRAME_RETRY_TIMEOUT 1 @@ -101,6 +102,7 @@ struct dpp_sm { uint8_t role; int refcount; uint32_t station_watch; + uint32_t known_network_watch; uint64_t wdev_id; @@ -168,6 +170,8 @@ struct dpp_sm { struct l_dbus_message *pending; + struct l_idle *connect_idle; + /* PKEX-specific values */ char *pkex_id; char *pkex_key; @@ -515,6 +519,11 @@ static void dpp_reset(struct dpp_sm *dpp) dpp->pkex_scan_id = 0; } + if (dpp->connect_idle) { + l_idle_remove(dpp->connect_idle); + dpp->connect_idle = NULL; + } + dpp->state = DPP_STATE_NOTHING; dpp->new_freq = 0; dpp->frame_retry = 0; @@ -570,6 +579,8 @@ static void dpp_free(struct dpp_sm *dpp) if (station) station_remove_state_watch(station, dpp->station_watch); + known_networks_watch_remove(dpp->known_network_watch); + l_free(dpp); } @@ -812,8 +823,6 @@ static void dpp_write_config(struct dpp_configuration *config, { _auto_(l_settings_free) struct l_settings *settings = l_settings_new(); _auto_(l_free) char *path; - _auto_(l_free) uint8_t *psk = NULL; - size_t psk_len; path = storage_get_network_file_path(SECURITY_PSK, config->ssid); @@ -822,22 +831,13 @@ static void dpp_write_config(struct dpp_configuration *config, l_settings_remove_group(settings, "Security"); } - if (config->passphrase) { + if (config->passphrase) l_settings_set_string(settings, "Security", "Passphrase", config->passphrase); - if (network) - network_set_passphrase(network, config->passphrase); - - } else if (config->psk) { + else if (config->psk) l_settings_set_string(settings, "Security", "PreSharedKey", config->psk); - psk = l_util_from_hexstring(config->psk, &psk_len); - - if (network) - network_set_psk(network, psk); - } - if (config->send_hostname) l_settings_set_bool(settings, "IPv4", "SendHostname", true); @@ -856,14 +856,39 @@ static void dpp_scan_triggered(int err, void *user_data) l_error("Failed to trigger DPP scan"); } +static void dpp_start_connect(struct l_idle *idle, void *user_data) +{ + struct dpp_sm *dpp = user_data; + struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); + struct scan_bss *bss; + struct network *network; + int ret; + + network = station_network_find(station, dpp->config->ssid, + SECURITY_PSK); + + dpp_reset(dpp); + + if (!network) { + l_debug("Network was not found!"); + return; + } + + l_debug("connecting to %s from DPP", network_get_ssid(network)); + + bss = network_bss_select(network, true); + ret = network_autoconnect(network, bss); + if (ret < 0) + l_warn("failed to connect after DPP (%d) %s", ret, + strerror(-ret)); +} + static bool dpp_scan_results(int err, struct l_queue *bss_list, const struct scan_freq_set *freqs, void *userdata) { struct dpp_sm *dpp = userdata; struct station *station = station_find(netdev_get_ifindex(dpp->netdev)); - struct scan_bss *bss; - struct network *network; if (err < 0) goto reset; @@ -880,18 +905,7 @@ static bool dpp_scan_results(int err, struct l_queue *bss_list, station_set_scan_results(station, bss_list, freqs, false); - network = station_network_find(station, dpp->config->ssid, - SECURITY_PSK); - - dpp_reset(dpp); - - if (!network) { - l_debug("Network was not found after scanning"); - return true; - } - - bss = network_bss_select(network, true); - network_autoconnect(network, bss); + dpp_start_connect(NULL, dpp); return true; @@ -907,6 +921,51 @@ static void dpp_scan_destroy(void *userdata) dpp_reset(dpp); } +static void dpp_known_network_watch(enum known_networks_event event, + const struct network_info *info, + void *user_data) +{ + struct dpp_sm *dpp = user_data; + + /* + * Check the following + * - DPP is enrolling + * - DPP finished (dpp->config is set) + * - This is for the network DPP just configured + * - DPP isn't already trying to connect (e.g. if the profile was + * immediately modified after DPP synced it). + * - DPP didn't start a scan for the network. + */ + if (dpp->role != DPP_CAPABILITY_ENROLLEE) + return; + if (!dpp->config) + return; + if (strcmp(info->ssid, dpp->config->ssid)) + return; + if (dpp->connect_idle) + return; + if (dpp->connect_scan_id) + return; + + switch (event) { + case KNOWN_NETWORKS_EVENT_ADDED: + case KNOWN_NETWORKS_EVENT_UPDATED: + /* + * network.c takes care of updating the settings for the + * network. This callback just tells us to begin the connection. + * We do have use an idle here because there is no strict + * guarantee of ordering between known network events, e.g. DPP + * could have been called into prior to network and the network + * object isn't updated yet. + */ + dpp->connect_idle = l_idle_create(dpp_start_connect, dpp, NULL); + break; + case KNOWN_NETWORKS_EVENT_REMOVED: + l_warn("profile was removed before DPP could connect"); + break; + } +} + static void dpp_handle_config_response_frame(const struct mmpdu_header *frame, const void *body, size_t body_len, int rssi, void *user_data) @@ -1074,10 +1133,11 @@ static void dpp_handle_config_response_frame(const struct mmpdu_header *frame, offchannel_cancel(dpp->wdev_id, dpp->offchannel_id); - if (network && bss) - __station_connect_network(station, network, bss, - STATION_STATE_CONNECTING); - else if (station) { + if (network && bss) { + l_debug("delaying connect until settings are synced"); + dpp->config = config; + return; + } else if (station) { struct scan_parameters params = {0}; params.ssid = (void *) config->ssid; @@ -3780,6 +3840,8 @@ static void dpp_create(struct netdev *netdev) 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); l_queue_push_tail(dpp_list, dpp); } From patchwork Mon Dec 18 14:12:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13497047 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (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 05A531D144 for ; Mon, 18 Dec 2023 14:12:56 +0000 (UTC) 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="mkJB0esE" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-425a76bb53fso32613441cf.1 for ; Mon, 18 Dec 2023 06:12:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702908775; x=1703513575; 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=Ik0TpLbzBGGyA9CN4Lx6Q7/i/gSeXuVLaDc4xi3xR0A=; b=mkJB0esEqw59Rphl6WHondqhG2z+KfqR3gaj2Gjxvq+DU9xfdTNLkBNmiyMhkC0rFr ofO5rXOhIUe2S43BpLvE0+FVNbokaWF7JwhZcP8RvJ1PC9ODT50y9Z5z1PZoChVfuona NGlJxVK8kadBGNr/cp177ct+gquk3zHx0xDxCVPgkzSieXRzWAz3rkVN5PwtvQDrQuR2 yzOGg2+eK+EXVVMQ420pm/6EDDjomCJl4OrSJC41Rk7RLw9MrTVoo6geG6JXz4+PAIeG 4EmDsv8l/SrcDhQPQT96zE1IcsNF2vrks4Z38P4Zp6xa6zFXJZB9yiZ6BTSpd9xWrvEC 3WrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702908775; x=1703513575; 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=Ik0TpLbzBGGyA9CN4Lx6Q7/i/gSeXuVLaDc4xi3xR0A=; b=OSVF0DeDlRePWxg5u5aytGaA+ABDTl4i2oKW52j8W61yGszl5ubVrA1e1Ape5djKeg GiS/18IxMKz1GdVDJlc52hPpqJ/c4L4NrAnk5y5nMORqDsCG7YRUk9zyr6UbHHb4bF0H ACSikoVSPS04cX/Ucczi6jtYup13ieiGEJknJ7vs0/yUKNyDN5q5Lw2dBS3hscjLd0Yy mSIyAHW6OdURyGfzEvzYQPk0Sedo82w/3YEuNVG/uYyxGCcCmZLSecuHbu8aCUwZfTY9 bJ9xVxEhn6K+eNsvW4gdY65T8agucYsVr/Ac6qcmTH1geewChkHzsct5vKgpsnObGWMp 4y3g== X-Gm-Message-State: AOJu0YwffisgkXyn7rY1XsggX00XnXpvvBUH7HN93mhkhQh173ujl2tK jopn6otagbn6Jb6nNYXOMBWKXNccyWE= X-Google-Smtp-Source: AGHT+IFSMLGxbJYvm2NoIo7VFvRxwHD80P8zZyEA+aTrM6XBnUFt4HVLFWiB9cx5M9Om15zfnx3SgA== X-Received: by 2002:a05:6214:411b:b0:67a:a721:721c with SMTP id kc27-20020a056214411b00b0067aa721721cmr25144821qvb.57.1702908775605; Mon, 18 Dec 2023 06:12:55 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id b2-20020a0cbf42000000b0067ec8702d1dsm7816355qvj.137.2023.12.18.06.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 06:12:55 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 3/4] auto-t: add DPP tests to check extra settings are applied Date: Mon, 18 Dec 2023 06:12:49 -0800 Message-Id: <20231218141250.202157-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218141250.202157-1-prestwoj@gmail.com> References: <20231218141250.202157-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In order to test that extra settings are applied prior to connecting two tests were added for hidden networks as well as one testing if there is already an existing profile after DPP. The reason hidden networks were used was due to the requirement of the "Hidden" settings in the profile. If this setting doesn't get sync'ed to disk the connection will fail. --- autotests/testDPP/hw.conf | 5 ++- autotests/testDPP/pkex_test.py | 72 ++++++++++++++++++++++++++++++- autotests/testDPP/ssidHidden.conf | 9 ++++ autotests/testDPP/ssidHidden.psk | 5 +++ 4 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 autotests/testDPP/ssidHidden.conf create mode 100644 autotests/testDPP/ssidHidden.psk diff --git a/autotests/testDPP/hw.conf b/autotests/testDPP/hw.conf index a2b1470e..85f33777 100644 --- a/autotests/testDPP/hw.conf +++ b/autotests/testDPP/hw.conf @@ -1,5 +1,5 @@ [SETUP] -num_radios=4 +num_radios=5 start_iwd=0 hwsim_medium=yes @@ -8,6 +8,7 @@ rad0=wpas.conf [HOSTAPD] rad1=hostapd.conf +rad2=ssidHidden.conf [NameSpaces] -ns0=rad2 +ns0=rad3 diff --git a/autotests/testDPP/pkex_test.py b/autotests/testDPP/pkex_test.py index 9e0b5dd8..5df6c47d 100644 --- a/autotests/testDPP/pkex_test.py +++ b/autotests/testDPP/pkex_test.py @@ -26,11 +26,11 @@ class Test(unittest.TestCase): self.wpas.dpp_stop_listen() self.wpas.dpp_configurator_remove() - def start_iwd_pkex_configurator(self, device, agent=False): + def start_iwd_pkex_configurator(self, device, agent=False, profile='ssidCCMP.psk'): self.hapd.reload() self.hapd.wait_for_event('AP-ENABLED') - IWD.copy_to_storage('ssidCCMP.psk') + IWD.copy_to_storage(profile) device.autoconnect = True condition = 'obj.state == DeviceState.connected' @@ -186,6 +186,71 @@ class Test(unittest.TestCase): self.agent = None + def test_existing_network(self): + self.hapd.reload() + self.hapd.wait_for_event('AP-ENABLED') + IWD.copy_to_storage("existingProfile.psk", "/tmp/ns0/", "ssidCCMP.psk") + + # Scan first so a network object exists, and its a known network + self.device[1].scan() + self.wd.wait_for_object_condition(self.device[1], 'obj.scanning == True') + self.wd.wait_for_object_condition(self.device[1], 'obj.scanning == False') + + self.start_iwd_pkex_configurator(self.device[0]) + + self.device[1].dpp_pkex_enroll('secret123', identifier="test") + self.device[1].autoconnect = True + + condition = 'obj.state == DeviceState.connected' + self.wd.wait_for_object_condition(self.device[1], condition) + + # Check additional settings were carried over + with open('/tmp/ns0/ssidCCMP.psk', 'r') as f: + settings = f.read() + + self.assertIn("SendHostname=true", settings) + + def test_existing_hidden_network(self): + self.hapd_hidden.reload() + self.hapd_hidden.wait_for_event('AP-ENABLED') + IWD.copy_to_storage("existingProfile.psk", "/tmp/ns0/", "ssidHidden.psk") + + # Scan first so a network object exists, and its a known network + self.device[1].scan() + self.wd.wait_for_object_condition(self.device[1], 'obj.scanning == True') + self.wd.wait_for_object_condition(self.device[1], 'obj.scanning == False') + + self.start_iwd_pkex_configurator(self.device[0], profile='ssidHidden.psk') + + self.device[1].dpp_pkex_enroll('secret123', identifier="test") + self.device[1].autoconnect = True + + condition = 'obj.state == DeviceState.connected' + self.wd.wait_for_object_condition(self.device[1], condition) + + # Check additional settings were carried over + with open('/tmp/ns0/ssidHidden.psk', 'r') as f: + settings = f.read() + + self.assertIn("Hidden=true", settings) + + def test_hidden_network(self): + self.hapd_hidden.reload() + 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 = True + + condition = 'obj.state == DeviceState.connected' + self.wd.wait_for_object_condition(self.device[1], condition) + + # Check additional settings were carried over + with open('/tmp/ns0/ssidHidden.psk', 'r') as f: + settings = f.read() + + self.assertIn("Hidden=true", settings) + def setUp(self): ns0 = ctx.get_namespace('ns0') self.wpas = Wpas('wpas.conf') @@ -197,6 +262,8 @@ class Test(unittest.TestCase): self.device.append(self.wd_ns0.list_devices(1)[0]) self.hapd = HostapdCLI('hostapd.conf') self.hapd.disable() + self.hapd_hidden = HostapdCLI('ssidHidden.conf') + self.hapd_hidden.disable() self.hwsim = Hwsim() self.rule_xchg_resp = self.hwsim.rules.create() @@ -240,6 +307,7 @@ class Test(unittest.TestCase): self.hapd = None self.rule_xchg_resp = None IWD.clear_storage() + IWD.clear_storage('/tmp/ns0') @classmethod def setUpClass(cls): diff --git a/autotests/testDPP/ssidHidden.conf b/autotests/testDPP/ssidHidden.conf new file mode 100644 index 00000000..1055fb9c --- /dev/null +++ b/autotests/testDPP/ssidHidden.conf @@ -0,0 +1,9 @@ +hw_mode=g +channel=6 +ssid=ssidHidden + +wpa=1 +wpa_pairwise=TKIP +wpa_passphrase=secret123 + +ignore_broadcast_ssid=1 diff --git a/autotests/testDPP/ssidHidden.psk b/autotests/testDPP/ssidHidden.psk new file mode 100644 index 00000000..9917294e --- /dev/null +++ b/autotests/testDPP/ssidHidden.psk @@ -0,0 +1,5 @@ +[Security] +Passphrase=secret123 + +[Settings] +Hidden=true From patchwork Mon Dec 18 14:12:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13497048 Received: from mail-oo1-f51.google.com (mail-oo1-f51.google.com [209.85.161.51]) (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 C34B53D564 for ; Mon, 18 Dec 2023 14:12:57 +0000 (UTC) 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="nTAtxhLD" Received: by mail-oo1-f51.google.com with SMTP id 006d021491bc7-590711b416fso2145117eaf.2 for ; Mon, 18 Dec 2023 06:12:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1702908776; x=1703513576; 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=17kjngjl4clw+g5Gdna9lJMGodPIyyvLG/4MzZRUlT8=; b=nTAtxhLD6FwVdtIGKCR96d8HxD5XHxuyLEp+d5ZoUNUenbss/efHVFESYAo43chh/l AkKDiYlZbYkNaq4wTD8BbIs90grPNY5RcPQQ9NZhoJPRgXTny9mUWeaf0HABLUXqKNE0 e2C63BdGqvbgnlRgcvkCDrp3d2tkdYUxwQEUJEeh2o6hk+y+k4U7nZghA2zl21Y/EuN5 2CaeS/88zz8keODUlMYHbVHs9UDLjPZ390wsTLotsJriHST5NS0MfwCmAus2q3gPRu4j 9ksv2o0DGlkCgEIFpYuP6r8WUQyC+iHLKscTMnLS1x4zC35zsQm+wyzyBE13gTGN9XAt tWAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702908776; x=1703513576; 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=17kjngjl4clw+g5Gdna9lJMGodPIyyvLG/4MzZRUlT8=; b=Eyx93WllSzSphpg9Jt2iUwrF3gJC4vOMdF6CrgJmuGw578vgK5tu2kbGMS/cuLmDja JxaT0YLrKqf0RUPRuRmFW9/3WQvo6Y7hVvrfi0pQBToVnkY+w4Hv2l5lfNQwckqPM0mg wxgOmv5tZrZUNuZLp0kN0J6ElSoshD4mYQfCy50XzAyRHstKxZ55wFqOrtGPy8rLP0J7 QatDHAQMuvr4VJisaga3SAmgqUpzbFYIa5DUozSUwOdakhQm4/rJU+KCjUPFnq8Ap93+ ZmCNg4rKjtux+M25auhqDa9DyyRT8aHOVixrqcCwf90N6O7k2dBfFr0ze/YHDlD3erp0 A1eg== X-Gm-Message-State: AOJu0YzfZBKhk04opeTvh7sjLrqZeLLZJZkK1b5k/EYVxA+QTEWAjG8T YOaAGP54akbD/4JI6PndIIvqDAtTsLU= X-Google-Smtp-Source: AGHT+IFycYAr2mS5OeIW+/XrpCitQjf5HGKcxJt4gOgtZJWVN7eOJbX6r4UC2C97ojyUGBPr+aeTtQ== X-Received: by 2002:a05:6358:9199:b0:170:da5a:d24e with SMTP id j25-20020a056358919900b00170da5ad24emr16006386rwa.51.1702908776567; Mon, 18 Dec 2023 06:12:56 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id b2-20020a0cbf42000000b0067ec8702d1dsm7816355qvj.137.2023.12.18.06.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 06:12:56 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 4/4] auto-t: increase RAM when running with valgrind (UML) Date: Mon, 18 Dec 2023 06:12:50 -0800 Message-Id: <20231218141250.202157-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231218141250.202157-1-prestwoj@gmail.com> References: <20231218141250.202157-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This was done for QEMU but not for UML. Running more than a few tests with --valgrind will generally thrown an OOM error pretty quick. --- tools/runner.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/runner.py b/tools/runner.py index 03f44611..e50ba9c0 100644 --- a/tools/runner.py +++ b/tools/runner.py @@ -552,7 +552,12 @@ class UmlRunner(RunnerAbstract): kern_log = "ignore_loglevel" if "kernel" in args.verbose else "quiet" - cmd = [args.kernel, 'rootfstype=hostfs', 'ro', 'mem=256M', 'mac80211_hwsim.radios=0', + if self.args.valgrind: + ram = 512 + else: + ram = 256 + + cmd = [args.kernel, 'rootfstype=hostfs', 'ro', f'mem={ram}M', 'mac80211_hwsim.radios=0', 'time-travel=inf-cpu', 'eth0=mcast', 'eth1=mcast', '%s' % kern_log, 'init=%s' % self.init] cmd.extend(args.to_cmd().split(' '))