From patchwork Fri Jan 5 14:47:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13512238 Received: from mail-oi1-f176.google.com (mail-oi1-f176.google.com [209.85.167.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6C3892E3F1 for ; Fri, 5 Jan 2024 14:47: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="IEjt4s3x" Received: by mail-oi1-f176.google.com with SMTP id 5614622812f47-3bbbe583e04so996826b6e.3 for ; Fri, 05 Jan 2024 06:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704466076; x=1705070876; 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=8ixw0WwMMTzXC+ikewb+Rj26bB6LoAIDO9OXuMVh3xo=; b=IEjt4s3x3xM7UKaletDJcJetbV0CAdDoxpZxpjhtJBj3M9ftiIMaTTofSabWPvCHLU 7V/bOFPawmPdEv0rM/g6IPYPa3m4PA512O8ogX4K6n/7X14yBuhnrAfX0AzalTm4YCl6 D26YPCj+Kh/pe2f1T+n+Ln3QTB6UQ5Uc64/Hev+ViQsyajrczF1vpXpmrKcjY7ULbTHT 9cPmVBTguALIITNVrSlBivLpU3Tkxi33TCnIs9yfFWctlYBRPysofFVE6jQVibbi4U1M DXqKvIOzn8PZTFAIpFKYy5K8lkDrImR4WKUtMvSvVrTnyuHKuHPGD/kDy/+8p8b952IL Iieg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704466076; x=1705070876; 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=8ixw0WwMMTzXC+ikewb+Rj26bB6LoAIDO9OXuMVh3xo=; b=P1VsA7Te0me8jXOG/RmhtOexHnhjJroTstdrez3vcdwZuH1iD7xVXBFEAA4s0Mum1N 9h8U2yfs00tbR5P9QsyLvAiLGW56h8NU68oUrTXLlSgtKj4BXlXlFpsJ8Vf/nybH+9aB 6sWaP/n4wIuy3YjhNIfmsSr5VD+bIelxInEcKGbNqCkLUbHyskw1ZurQAIhEaH2UbwLI HptVpIx/qQr7s5e9iZQRQEBLDWO/8/wa47pR92vtkbpqHjifJlXcxrPWDB7fnLFXIEW3 9pEamQ1/WOMsZaKs7iPC/0luYNWK0Jgs9xA7iW+XwzaUTTnCnDOgQ7GW9T9whtDoJCNS P3QA== X-Gm-Message-State: AOJu0YytvhCdTM4mmR2Vo2HbWWvqtBnFmrdNWl2YimWkBHyIlXwwqCep hYNOJzwUN/HFNtjaf0AVEcc3sKI00EY= X-Google-Smtp-Source: AGHT+IEa3X3K2+rMt8dc9V1txQpSd/ZpcfMkdz+UwgcmE+Bny0naixSxJBQQ1hKQ7XIcRgKoEBZ8dA== X-Received: by 2002:a05:6808:1415:b0:3bb:bd76:ae5f with SMTP id w21-20020a056808141500b003bbbd76ae5fmr2195551oiv.7.1704466074743; Fri, 05 Jan 2024 06:47:54 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id pz30-20020ad4551e000000b0067f8f04a2fcsm656843qvb.57.2024.01.05.06.47.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 06:47:54 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 1/3] station: add additional internal state, STATION_STATE_NETCONFIG Date: Fri, 5 Jan 2024 06:47:48 -0800 Message-Id: <20240105144750.839705-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 This is still treated as "connecting" from a DBus perspective but will allow for better handling internally for some roaming corner cases. --- src/dpp.c | 1 + src/station.c | 5 +++++ src/station.h | 1 + src/wsc.c | 1 + 4 files changed, 8 insertions(+) diff --git a/src/dpp.c b/src/dpp.c index af6574fb..74b4c2bc 100644 --- a/src/dpp.c +++ b/src/dpp.c @@ -3761,6 +3761,7 @@ static void dpp_station_state_watch(enum station_state state, void *user_data) case STATION_STATE_CONNECTING: 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); diff --git a/src/station.c b/src/station.c index ac53bf2a..68cac945 100644 --- a/src/station.c +++ b/src/station.c @@ -1497,6 +1497,8 @@ static const char *station_state_to_string(enum station_state state) return "ft-roaming"; case STATION_STATE_FW_ROAMING: return "fw-roaming"; + case STATION_STATE_NETCONFIG: + return "connecting (netconfig)"; } return "invalid"; @@ -1635,6 +1637,7 @@ static void station_enter_state(struct station *station, station_set_drop_unicast_l2_multicast(station, false); break; case STATION_STATE_DISCONNECTING: + case STATION_STATE_NETCONFIG: break; case STATION_STATE_ROAMING: case STATION_STATE_FT_ROAMING: @@ -3342,6 +3345,7 @@ static void station_disconnect_event(struct station *station, void *event_data) case STATION_STATE_CONNECTED: case STATION_STATE_FT_ROAMING: case STATION_STATE_FW_ROAMING: + case STATION_STATE_NETCONFIG: station_disassociated(station); return; default: @@ -4272,6 +4276,7 @@ static bool station_property_get_state(struct l_dbus *dbus, break; case STATION_STATE_CONNECTING: case STATION_STATE_CONNECTING_AUTO: + case STATION_STATE_NETCONFIG: statestr = "connecting"; break; case STATION_STATE_CONNECTED: diff --git a/src/station.h b/src/station.h index 0d502a08..a38327e4 100644 --- a/src/station.h +++ b/src/station.h @@ -45,6 +45,7 @@ enum station_state { STATION_STATE_ROAMING, /* Reassociation */ STATION_STATE_FT_ROAMING, /* Fast transition */ STATION_STATE_FW_ROAMING, /* Firmware roamed by itself */ + STATION_STATE_NETCONFIG, }; enum station_event { diff --git a/src/wsc.c b/src/wsc.c index cda877cf..f88f5deb 100644 --- a/src/wsc.c +++ b/src/wsc.c @@ -654,6 +654,7 @@ static void wsc_check_can_connect(struct wsc_station_dbus *wsc, case STATION_STATE_CONNECTING: case STATION_STATE_CONNECTING_AUTO: case STATION_STATE_CONNECTED: + case STATION_STATE_NETCONFIG: if (station_disconnect(wsc->station) < 0) goto error; From patchwork Fri Jan 5 14:47:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13512239 Received: from mail-qv1-f45.google.com (mail-qv1-f45.google.com [209.85.219.45]) (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 9D8A52E3F2 for ; Fri, 5 Jan 2024 14:47: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="gc4SwiZC" Received: by mail-qv1-f45.google.com with SMTP id 6a1803df08f44-67fa018c116so7925776d6.3 for ; Fri, 05 Jan 2024 06:47:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704466076; x=1705070876; 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=qr8IxkfTm+OARkC8wd1qTikgUjVh3/KeOFW/Qt1SPuM=; b=gc4SwiZCGj99QrIhScoPJaF2lc0TjcghcQ4MDFoh7cHS8Zd3azyJ4P/C4cNpkQGbhh aU+cGiFs+xFB9gg7rQ0x4YxWDp71mlonkRKPY6A+iDdILb/SW7ohRb/Okc6N+BWueNzD QqjrWnpVQ0Gy3zkfYxrQZrjbwgEHzWtJrxqIlNQaqo768X21WaNaXXTjjzi4r3Eei+e0 u7rG/X/k3ErWuGPLOrFlpww6EHPQGgOKQ7cR+7goCe2M2Ot8YnNueaNa/nV/cUK7KyY8 eP045S91rwbzFRYaQyGxjxzd3uUe6KzkwrMeGnRM4d+6rOpUK8rDndIfxqF65kXcazfi 548Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704466076; x=1705070876; 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=qr8IxkfTm+OARkC8wd1qTikgUjVh3/KeOFW/Qt1SPuM=; b=AVosAwDK0q65yC7Eq1z5MErMCxV7FQx05tl0zLq8f7ppvu5TznD/zHMeOgGMisWShM Q2OQ9j1QT0/h/fzl0GTlPV989ksgqWE2ZKrNYTWDNFM2841KMfdL5uFhTBAkdTpIYZqu 549vnwHf7/W9DuhceygkR0MbJ3L2q7JVqiaJZM5ptpNHjkNB48Pd3hVyMDYQ5iYA5Lxw AYiyVCWI4/a2qf71it8j934AMYsioL0Vd14u5couu6dvMNJ1vtYfdZf8NTGKfrF80/jo jicynSvV8xiIy6TaHjo7Y3okv3BQ4cOjMLhm062xs8/MxIPB7QYsWGo0zh8Yh9ijdiBY QiIQ== X-Gm-Message-State: AOJu0YznB2kQRVxC2Tr2hXupnOIsTaAFPAiDQlSRe5F/WGylQurb/5Bo jljnR+h327YTQDc1vCNTcBmGUjEQcic= X-Google-Smtp-Source: AGHT+IEVlzYPHHRslEQuKiSn3yYJ5TeDwif5CmwHE/V7+vo9PrFev6xk+RBXeTP1DC8ABwuTYeeCnA== X-Received: by 2002:a05:6214:2303:b0:67a:c570:1528 with SMTP id gc3-20020a056214230300b0067ac5701528mr2353061qvb.20.1704466075859; Fri, 05 Jan 2024 06:47:55 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id pz30-20020ad4551e000000b0067f8f04a2fcsm656843qvb.57.2024.01.05.06.47.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 06:47:55 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 2/3] station: add handling for new NETCONFIG state Date: Fri, 5 Jan 2024 06:47:49 -0800 Message-Id: <20240105144750.839705-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240105144750.839705-1-prestwoj@gmail.com> References: <20240105144750.839705-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There was an unhandled corner case if netconfig was running and multiple roam conditions happened in sequence, all before netconfig had completed. A single roam before netconfig was already handled (23f0f5717c) but this did not take into account any additional roam conditions. If IWD is in this state, having started netconfig, then roamed, and again restarted netconfig it is still in a roaming state which will prevent any further roams. IWD will remain "stuck" on the current BSS until netconfig completes or gets disconnected. In addition the general state logic is wrong here. If IWD roams prior to netconfig it should stay in a connecting state (from the perspective of DBus). To fix this a new internal station state was added (no changes to the DBus API) to distinguish between a purely WiFi connecting state (STATION_STATE_CONNECTING/AUTO) and netconfig (STATION_STATE_NETCONFIG). This allows IWD roam as needed if netconfig is still running. Also, some special handling was added so the station state property remains in a "connected" state until netconfig actually completes, regardless of roams. For some background this scenario happens if the DHCP server goes down for an extended period, e.g. if its being upgraded/serviced. --- src/station.c | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) v2: * Stay in a "connecting" state if roaming before netconfig from a DBus property perspective. * Minor changes using L_IN_SET There are still improvements needed in this area, but this at least fixes the major issues related to the state change and allowing multiple roams. Still TODO: * Add a netconfig timeout (in ELL) * Put netconfig behind a wiphy work item. This requires some thought since we'd still need to allow roam scans, but just not any other scans/offchannel. diff --git a/src/station.c b/src/station.c index 68cac945..a6442d3e 100644 --- a/src/station.c +++ b/src/station.c @@ -1770,6 +1770,7 @@ static void station_reset_connection_state(struct station *station) if (station->state == STATION_STATE_CONNECTED || station->state == STATION_STATE_CONNECTING || station->state == STATION_STATE_CONNECTING_AUTO || + station->state == STATION_STATE_NETCONFIG || station_is_roaming(station)) network_disconnected(network); } @@ -2045,8 +2046,7 @@ static void station_netconfig_event_handler(enum netconfig_event event, dbus_pending_reply(&station->connect_pending, reply); } - if (L_IN_SET(station->state, STATION_STATE_CONNECTING, - STATION_STATE_CONNECTING_AUTO)) + if (station->state == STATION_STATE_NETCONFIG) network_connect_failed(station->connected_network, false); @@ -2072,9 +2072,14 @@ static bool netconfig_after_roam(struct station *station) network_get_settings(network))) return false; - return netconfig_configure(station->netconfig, + if (!netconfig_configure(station->netconfig, station_netconfig_event_handler, - station); + station)) + return false; + + station_enter_state(station, STATION_STATE_NETCONFIG); + + return true; } static void station_roamed(struct station *station) @@ -3253,6 +3258,8 @@ static void station_connect_ok(struct station *station) station_netconfig_event_handler, station))) return; + + station_enter_state(station, STATION_STATE_NETCONFIG); } else station_enter_state(station, STATION_STATE_CONNECTED); } @@ -4064,8 +4071,10 @@ static struct l_dbus_message *station_dbus_scan(struct l_dbus *dbus, if (station->dbus_scan_id) return dbus_error_busy(message); - if (station->state == STATION_STATE_CONNECTING || - station->state == STATION_STATE_CONNECTING_AUTO) + if (L_IN_SET(station->state, STATION_STATE_CONNECTING, + STATION_STATE_CONNECTING_AUTO, + STATION_STATE_NETCONFIG) || + station_is_roaming(station)) return dbus_error_busy(message); station->dbus_scan_subset_idx = 0; @@ -4288,7 +4297,14 @@ static bool station_property_get_state(struct l_dbus *dbus, case STATION_STATE_ROAMING: case STATION_STATE_FT_ROAMING: case STATION_STATE_FW_ROAMING: - statestr = "roaming"; + /* + * Stay in a connecting state if roaming before netconfig + * has finished + */ + if (station->netconfig_after_roam) + statestr = "connecting"; + else + statestr = "roaming"; break; } @@ -5022,8 +5038,10 @@ static struct l_dbus_message *station_debug_scan(struct l_dbus *dbus, if (station->dbus_scan_id) return dbus_error_busy(message); - if (station->state == STATION_STATE_CONNECTING || - station->state == STATION_STATE_CONNECTING_AUTO) + if (L_IN_SET(station->state, STATION_STATE_CONNECTING, + STATION_STATE_CONNECTING_AUTO, + STATION_STATE_NETCONFIG) || + station_is_roaming(station)) return dbus_error_busy(message); if (!l_dbus_message_get_arguments(message, "aq", &iter)) From patchwork Fri Jan 5 14:47:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13512240 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 ED0872DF66 for ; Fri, 5 Jan 2024 14:47:58 +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="aLY8CRp9" Received: by mail-qv1-f41.google.com with SMTP id 6a1803df08f44-680285e7ce8so7911906d6.0 for ; Fri, 05 Jan 2024 06:47:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704466077; x=1705070877; 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=/r+PrxhLULk0AIV/gOfDgqr0E3rZeZFz3B5cwT2Dg88=; b=aLY8CRp99X41iW9JfB5CqRGSi/5bIAqoGFqnXa6DrPsVXxnfUi8XIKfmulw4FWY7MK ll6NuQ5WEMRpZ5ZvHeR40/FYl34VrSDBCm9OAV99kF6WAxBn95XO0vFiaAw5yb/H0pn2 MchgNGw83rfQfarM5lYmBwLBk7MAtxQFrCwT7yQ1F/EVv34nIeHnE3zqi96YFQT8dl6u 3wo9Pq/l7Mve0FdjqApbOCMZWCZfVmEUfTLKNygmMQJ7Au7+EOxfdcdPMlEjrJ+ZAT1E GxAG3YX6VuSuCfYVEyRgbXe8C4L/JYMIOyamiOvf1TFRHyf9c2OcRLgp8vse30/EkW7m gMkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704466077; x=1705070877; 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=/r+PrxhLULk0AIV/gOfDgqr0E3rZeZFz3B5cwT2Dg88=; b=YeM0GnJKfsa5VqbYMz3Exixs34DLb3jReDxONLRX5/rvqEZr8mwq56WR95b0j/S82Y 5lo7xZZPPZAVNPTktjghnPift+J9JbwVTYR7hPNJ3QppGuiik0LRUjNyhEzMx7t6RYyZ sWTm/b6xqdGn3sZkyB9bPxkKwOyf4UvpYTXdetzT284EEPRONPTH5qUy31+vPph9AUGn LcXkBE53dH4RHG0PRLI9FFXftArsaZkVZUjsCnQKEM8MLjXmeu1spaYbE6iMM6KclfG6 yAs5QVQXz67nojTI/e/jnI4qecHf25XzvNO4AdoiXRZsxmafCIt+FTaKBAMUqLUcP0tQ whQA== X-Gm-Message-State: AOJu0YytTPnWQCZnc4ZZPxCbOMOeRjpFItgF+rPjZhvIeeiE1W3cLgnW fgI0hKO/Op20ShfWWZ7dBKO7GEEPIL8= X-Google-Smtp-Source: AGHT+IGehvA30TDOY3fQHW+v5m7nIbV/nELZxtYw4+g9lR1zypFPSlJXW6zaj1SNVWsYet7MRZZ9Rg== X-Received: by 2002:a05:6214:29c6:b0:67f:b763:81a with SMTP id gh6-20020a05621429c600b0067fb763081amr2732822qvb.47.1704466077366; Fri, 05 Jan 2024 06:47:57 -0800 (PST) Received: from LOCLAP699.rst-02.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id pz30-20020ad4551e000000b0067f8f04a2fcsm656843qvb.57.2024.01.05.06.47.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Jan 2024 06:47:56 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 3/3] auto-t: add test for roaming + netconfig Date: Fri, 5 Jan 2024 06:47:50 -0800 Message-Id: <20240105144750.839705-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240105144750.839705-1-prestwoj@gmail.com> References: <20240105144750.839705-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This test ensures IWD will continue to roam and restart netconfig if roam conditions are met prior to netconfig finishing. --- autotests/testNetconfigRoam/TestFT.psk | 2 + .../testNetconfigRoam/ft-psk-ccmp-1.conf | 41 +++++++++ .../testNetconfigRoam/ft-psk-ccmp-2.conf | 41 +++++++++ autotests/testNetconfigRoam/hw.conf | 8 ++ autotests/testNetconfigRoam/main.conf | 3 + .../testNetconfigRoam/netconfig_roam_test.py | 91 +++++++++++++++++++ 6 files changed, 186 insertions(+) create mode 100644 autotests/testNetconfigRoam/TestFT.psk create mode 100644 autotests/testNetconfigRoam/ft-psk-ccmp-1.conf create mode 100644 autotests/testNetconfigRoam/ft-psk-ccmp-2.conf create mode 100644 autotests/testNetconfigRoam/hw.conf create mode 100644 autotests/testNetconfigRoam/main.conf create mode 100644 autotests/testNetconfigRoam/netconfig_roam_test.py v2: * Updated to check/ensure that IWD remains "connecting" even through multiple roams. diff --git a/autotests/testNetconfigRoam/TestFT.psk b/autotests/testNetconfigRoam/TestFT.psk new file mode 100644 index 00000000..e82d1295 --- /dev/null +++ b/autotests/testNetconfigRoam/TestFT.psk @@ -0,0 +1,2 @@ +[Security] +Passphrase=EasilyGuessedPassword diff --git a/autotests/testNetconfigRoam/ft-psk-ccmp-1.conf b/autotests/testNetconfigRoam/ft-psk-ccmp-1.conf new file mode 100644 index 00000000..b46d1f27 --- /dev/null +++ b/autotests/testNetconfigRoam/ft-psk-ccmp-1.conf @@ -0,0 +1,41 @@ +hw_mode=g +channel=1 +ssid=TestFT +utf8_ssid=1 +ctrl_interface=/var/run/hostapd + +r1_key_holder=120000000001 +nas_identifier=dummy1 + +wpa=2 +# Can support WPA-PSK and FT-PSK (space separated list) and/or EAP at the same +# time but we want to force FT +wpa_key_mgmt=FT-PSK +wpa_pairwise=CCMP +wpa_passphrase=EasilyGuessedPassword +ieee80211w=1 +rsn_preauth=1 +rsn_preauth_interfaces=lo +disable_pmksa_caching=0 +# Allow PMK cache to be shared opportunistically among configured interfaces +# and BSSes (i.e., all configurations within a single hostapd process). +okc=1 +mobility_domain=1234 +reassociation_deadline=60000 +r0kh=12:00:00:00:00:01 dummy1 000102030405060708090a0b0c0d0e0f +r0kh=12:00:00:00:00:02 dummy2 000102030405060708090a0b0c0d0e0f +r1kh=12:00:00:00:00:01 00:00:00:00:00:01 000102030405060708090a0b0c0d0e0f +r1kh=12:00:00:00:00:02 00:00:00:00:00:02 000102030405060708090a0b0c0d0e0f +# Push mode only needed for 8021x, not PSK mode since msk already known +pmk_r1_push=0 +# Allow locally generated FT response so we don't have to configure push/pull +# between BSSes running as separate hostapd processes as in the test-runner +# case. Only works with FT-PSK, otherwise brctl needs to be installed and +# CONFIG_BRIDGE enabled in the kernel. +ft_psk_generate_local=1 +rkh_pull_timeout=50 +ft_over_ds=0 +ap_table_expiration_time=36000 +ap_table_max_size=10 +rrm_neighbor_report=1 +ocv=1 diff --git a/autotests/testNetconfigRoam/ft-psk-ccmp-2.conf b/autotests/testNetconfigRoam/ft-psk-ccmp-2.conf new file mode 100644 index 00000000..3e215457 --- /dev/null +++ b/autotests/testNetconfigRoam/ft-psk-ccmp-2.conf @@ -0,0 +1,41 @@ +hw_mode=g +channel=2 +ssid=TestFT +utf8_ssid=1 +ctrl_interface=/var/run/hostapd + +r1_key_holder=120000000002 +nas_identifier=dummy2 + +wpa=2 +# Can support WPA-PSK and FT-PSK (space separated list) and/or EAP at the same +# time but we want to force FT +wpa_key_mgmt=FT-PSK +wpa_pairwise=CCMP +wpa_passphrase=EasilyGuessedPassword +ieee80211w=1 +rsn_preauth=1 +rsn_preauth_interfaces=lo +disable_pmksa_caching=0 +# Allow PMK cache to be shared opportunistically among configured interfaces +# and BSSes (i.e., all configurations within a single hostapd process). +okc=1 +mobility_domain=1234 +reassociation_deadline=60000 +r0kh=12:00:00:00:00:01 dummy1 000102030405060708090a0b0c0d0e0f +r0kh=12:00:00:00:00:02 dummy2 000102030405060708090a0b0c0d0e0f +r1kh=12:00:00:00:00:01 00:00:00:00:00:01 000102030405060708090a0b0c0d0e0f +r1kh=12:00:00:00:00:02 00:00:00:00:00:02 000102030405060708090a0b0c0d0e0f +# Push mode only needed for 8021x, not PSK mode since msk already known +pmk_r1_push=0 +# Allow locally generated FT response so we don't have to configure push/pull +# between BSSes running as separate hostapd processes as in the test-runner +# case. Only works with FT-PSK, otherwise brctl needs to be installed and +# CONFIG_BRIDGE enabled in the kernel. +ft_psk_generate_local=1 +rkh_pull_timeout=50 +ft_over_ds=0 +ap_table_expiration_time=36000 +ap_table_max_size=10 +rrm_neighbor_report=1 +ocv=1 diff --git a/autotests/testNetconfigRoam/hw.conf b/autotests/testNetconfigRoam/hw.conf new file mode 100644 index 00000000..c2b35d6e --- /dev/null +++ b/autotests/testNetconfigRoam/hw.conf @@ -0,0 +1,8 @@ +[SETUP] +num_radios=3 +start_iwd=0 +hwsim_medium=yes + +[HOSTAPD] +rad0=ft-psk-ccmp-1.conf +rad1=ft-psk-ccmp-2.conf diff --git a/autotests/testNetconfigRoam/main.conf b/autotests/testNetconfigRoam/main.conf new file mode 100644 index 00000000..aedd4ebd --- /dev/null +++ b/autotests/testNetconfigRoam/main.conf @@ -0,0 +1,3 @@ +[General] +EnableNetworkConfiguration=true +RoamRetryInterval=1 diff --git a/autotests/testNetconfigRoam/netconfig_roam_test.py b/autotests/testNetconfigRoam/netconfig_roam_test.py new file mode 100644 index 00000000..63e5eabf --- /dev/null +++ b/autotests/testNetconfigRoam/netconfig_roam_test.py @@ -0,0 +1,91 @@ +#! /usr/bin/python3 + +import unittest +import sys, os + +sys.path.append('../util') +import iwd +from iwd import IWD +from iwd import PSKAgent +from iwd import NetworkType +from iwd import DeviceState +from hwsim import Hwsim +from hostapd import HostapdCLI +import testutil + +class Test(unittest.TestCase): + def test_roam_before_netconfig(self): + wd = IWD(True) + + device = wd.list_devices(1)[0] + device.get_ordered_network('TestFT', full_scan=True) + device.connect_bssid(self.bss_hostapd[1].bssid) + + self.bss_hostapd[1].wait_for_event(f'AP-STA-CONNECTED {device.address}') + device.wait_for_event("connecting (netconfig)") + + roam_to = 0 + roam_from = 1 + + # Roam back and forth, ensuring that the state transitions between + # roaming and connecting (netconfig). + for _ in range(0, 5): + self.rules[roam_to].signal = -2000 + self.rules[roam_from].signal = -8000 + + # Station should internally transition to roaming, but remain in a + # connecting state on DBus + device.wait_for_event("ft-roaming") + self.assertEqual(device.state, DeviceState.connecting) + + self.bss_hostapd[roam_to].wait_for_event(f'AP-STA-CONNECTED {device.address}') + device.wait_for_event("connecting (netconfig)") + + tmp = roam_from + roam_from = roam_to + roam_to = tmp + + self.bss_hostapd[roam_from].deauthenticate(device.address) + condition = 'obj.state == DeviceState.disconnected' + wd.wait_for_object_condition(device, condition) + + def tearDown(self): + os.system('ip link set "' + self.bss_hostapd[0].ifname + '" down') + os.system('ip link set "' + self.bss_hostapd[1].ifname + '" down') + os.system('ip link set "' + self.bss_hostapd[0].ifname + '" up') + os.system('ip link set "' + self.bss_hostapd[1].ifname + '" up') + + @classmethod + def setUpClass(cls): + hwsim = Hwsim() + + IWD.copy_to_storage('TestFT.psk') + + cls.bss_hostapd = [ HostapdCLI(config='ft-psk-ccmp-1.conf'), + HostapdCLI(config='ft-psk-ccmp-2.conf') ] + + rule0 = hwsim.rules.create() + rule0.source = cls.bss_hostapd[0].bssid + rule0.signal = -6000 + rule0.enabled = True + + rule1 = hwsim.rules.create() + rule1.source = cls.bss_hostapd[1].bssid + rule1.signal = -2000 + rule1.enabled = True + + cls.rules = [rule0, rule1] + + cls.bss_hostapd[0].set_address('12:00:00:00:00:01') + cls.bss_hostapd[1].set_address('12:00:00:00:00:02') + + HostapdCLI.group_neighbors(*cls.bss_hostapd) + + @classmethod + def tearDownClass(cls): + IWD.clear_storage() + cls.bss_hostapd = None + cls.rules = None + +if __name__ == '__main__': + unittest.main(exit=True)