From patchwork Tue Aug 13 15:56: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: 13762252 Received: from mail-qv1-f54.google.com (mail-qv1-f54.google.com [209.85.219.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6145C2AF0D for ; Tue, 13 Aug 2024 15:56:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564610; cv=none; b=mAorqufKfGE+nzcqTVIFVL371sfOa5Fq6UYJGxdUkShmel4b+e2vZVij5s+izUZQ92KwziwiLfdccRR04uFDb8MhlmouF4RDBbb+ZnlUaL1iZvCJ2qyPxTv1Zt0zjTW6BCHaiXmZ+6RSMMaj3qpaJRIF6ObtQjzEjQiRliJ1bCU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564610; c=relaxed/simple; bh=byiZLcV6pA6id6Gy+LKn5EwNdxbROpBsMc+Yi3++VNQ=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IODIbNWkgUQjZK+4N1zSSgrlpijEBqXLuOp0a7Kgehv9RHM8IUNyzzGcDyczrg1EHfOho/cxoZI5xpu+reA4CQNLigocCK5DCU4pZf2dipKAZRRE3OC3GUXZTdPiSkC3uuhGyt1rFIaqLDPxkL85FECWQcYx1dty1Y3HILdU+B0= 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=mMqbSXNY; arc=none smtp.client-ip=209.85.219.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mMqbSXNY" Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-6b7af49e815so33538606d6.0 for ; Tue, 13 Aug 2024 08:56:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723564608; x=1724169408; 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=7V8k437GCDQwUFghUh4TPRC2xNSXCkrUBYe4l/5vTxo=; b=mMqbSXNYL22mjWwhqHksL2ic9b+XWGz/gc43pa/c4kVUtTywsLgM8Rz0LZ5paAhcU6 gwG1oAJFMHTHCMOubC7FcV88z9HdmjRmqzBOzUWicr5gaBYDlT//s46KSOo3VsTIcVLP gnLb99lw9hcSXK/0FroJMuu0PvZIyGdrfvu7T6fsDFqV6bsddxi9l3UD3W9DMn3bLI68 FQrTuVkOhgWFBswZthyD6aXmkFezVdtXrroDGOWCv9DJHPEptLiif8eS84vXwNd4jOac yWxYbNJmnUkaN4Kp7oFgD3D/LKbpE1+Ubp4NtO/2FJCiVBb0OAz8znii8Ooy7GPuWyMu eNjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564608; x=1724169408; 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=7V8k437GCDQwUFghUh4TPRC2xNSXCkrUBYe4l/5vTxo=; b=Wu7MrAGxA2gdrNwSJe+N8OhgQbCZh7rkE4FCi+Mq9K4qfDWxraED++HVda8ilxk/sF fk1kJymWtA7BoP7LCQppH5Ssr2SsCbsVmDAxuH1jjtL/yM1HzJnbfYzDZJtr3Qdd5ekU uflx4avBj++ZnrvZtb/0UAGTf16hLS186Zy0R8LqR64C0YZcZirdgOoNdrZqHho06K81 y16VC9tfj2SdhHDxR3hrmgAQ8Eybrq6EAmlijtUXsrg5tPMnzx27fMs2NtJ+ExExHHt4 wyppAB3q8pErKnWJz6oEFFoC+V4meVyQS9CAoVxUcQKnaXA98okaS4z4ZIROHaEO77rc a6rg== X-Gm-Message-State: AOJu0YyUzpba3aVolAaNkta5jtwF+aAZtvCkrzmLgsqeu5DbUu7dKHz3 vf8u1wslm2hprPSBX2Uuco2hsZgM09d6XaVHsGaXz0mjBS2ZlFjd9TmQ6Q== X-Google-Smtp-Source: AGHT+IFs7CcRWhBgTY4hxsz2kM/AaNxCt1c6EXZmpuOhdgCP6jdV7ttNzbOH5NtCZuvi5e1msvX8dA== X-Received: by 2002:a05:6214:2f8f:b0:6b4:ff80:ee0e with SMTP id 6a1803df08f44-6bf4f44398fmr54783856d6.0.1723564607953; Tue, 13 Aug 2024 08:56:47 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bd82ca2024sm35825706d6.72.2024.08.13.08.56.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 08:56:47 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/9] doc: Document station Affinities property Date: Tue, 13 Aug 2024 08:56:30 -0700 Message-Id: <20240813155638.74987-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 documents new DBus property that expose a bit more control to how IWD roams. Setting the affinity on the connected BSS effectively "locks" IWD to that BSS (except at critical RSSI levels, explained below). This can be useful for clients that have access to more information about the environment than IWD. For example, if a client is stationary there is likely no point in trying to roam until it has moved elsewhere. Setting the affinity on a BSS (regardless if the connected BSS) will also cause a modified ranking factor to be applied to the BSS. This could be used to push IWD to certain BSS's over others. Similar to above, the affinity ranking factor for a BSS will only be applied if that BSS's signal is above the crtical roaming threshold. A new main.conf option would also be added: [General].CriticalRoamThreshold This would be the new roam threshold set if the currently connected BSS is in the Affinities list. If the RSSI continues to drop below this level IWD will still attempt to roam. --- doc/station-api.txt | 19 +++++++++++++++++++ src/iwd.config.rst | 20 ++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/doc/station-api.txt b/doc/station-api.txt index 84f1b7bf..c22c57d4 100644 --- a/doc/station-api.txt +++ b/doc/station-api.txt @@ -170,6 +170,25 @@ Properties string State [readonly] BSS the device is currently connected to or to which a connection is in progress. + ao Affinities [optional] + + Array of net.connman.iwd.BasicServiceSet object paths + that will be treated with higher affinity compared to + other BSS's. The affinity comes into play in two + scenarios: + + 1. If the connected BSS is in the Affinities list the + roaming threshold will be lowered to loosly lock IWD + to its current BSS. This prevents IWD from roaming + unless the signal drops below the critical threshold + (i.e. main.conf: [General].CriticalRoamThreshold). + + 2. A ranking factor will be applied to all BSS in the + Affinities list while choosing a roaming candidate. + The only exception here is if the BSS's signal + is below the critical roaming threshold. + (i.e. main.conf: [General].CriticalRoamTreshold) + SignalLevelAgent hierarchy ========================== diff --git a/src/iwd.config.rst b/src/iwd.config.rst index d9c94e01..7221c149 100644 --- a/src/iwd.config.rst +++ b/src/iwd.config.rst @@ -130,6 +130,26 @@ The group ``[General]`` contains general settings. This value can be used to control how aggressively **iwd** roams when connected to a 5GHz access point. + * - CriticalRoamThreshold + - Value: rssi dBm value, from -100 to 1, default: **-80** + + The threshold (for 2.4GHz) at which IWD will roam regardless of the + affinity set to the current BSS. This is used in two ways: + + 1. If the connected BSS has affinity (set in Station's Affinities list) + the roam threshold will be lowed to this value and IWD will not + attempt to roam (or roam scan) until either the affinity is cleared, + or the signal drops below this threshold. + + 2. The affinity ranking factor will not be appled if the BSS's signal is + below this threshold. + + * - CriticalRoamThreshold5G + - Value: rssi dBm value, from -100 to 1, default: **-82** + + This has the same effect as ``CriticalRoamThreshold``, but for the 5GHz + band. + * - RoamRetryInterval - Value: unsigned int value in seconds (default: **60**) From patchwork Tue Aug 13 15:56: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: 13762253 Received: from mail-qt1-f173.google.com (mail-qt1-f173.google.com [209.85.160.173]) (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 8DE0E1A0730 for ; Tue, 13 Aug 2024 15:56:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564612; cv=none; b=VXNBkuIahLgkszdPRcGhcD88e8soUiUgaCK3vWTcohQib9c1iYA0fx/f3Oq1oNyDo3en64Nq9R2jfx3W9HkBPNS47ZDGj3aK0nSnFXenDNG8Rfaa0z1ntH59KtYw1pVitrmJfWfZmiYbmKYtxG7gsSJ0AG9YBvtf5jcIcZzg0n8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564612; c=relaxed/simple; bh=3ACyH0wBcHI5aXAjWAcnc1ZlymMSvIai99xD4di9yuI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=VR65CJLDyQhFerP5q0dxaICiXmkQ6JYeYugozhHBzz/8G1xURaetlY+VScsdpn3aPeZcwb07VE5Pw+mpVXVnKtQ9CdZtvEKtLMpXrsiQWAHltWWvfDsy/UbUDejG3jtIGhVJUVde6+GPu72qtRZazmBHg8dtKAO+8sPHH17f5GM= 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=Yf/fg2w6; arc=none smtp.client-ip=209.85.160.173 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="Yf/fg2w6" Received: by mail-qt1-f173.google.com with SMTP id d75a77b69052e-44ff50affc5so30433411cf.1 for ; Tue, 13 Aug 2024 08:56:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723564609; x=1724169409; 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=8lU2YFi0z6iWwdFzjptg9xLGk32SzO7YL037hOMc5X4=; b=Yf/fg2w6qnSnHTZQg1Qvihgk2Al3T/3+e6Cm6qd0n7oLgx3E4X0jYKVDtBVJfCnpHL /TJgetn6H5GKzhrbUBvm/NP9QzO2wND143+v6VCgFMc3LPBVnGDZc8b3Zq/9AJNHqt9y QcJGy4pQRXe5H4b7n2DlwmopWp4SwdiCnmaLECaDDzFqaNHyDNvMNETjyltBoY0p3DuS oXndUUAdnRJyr4ff4fRQPy9n5U+FkT7u+TnEu+t9Qz/GPsKvmRf+pdHqfQhH0+8u1np6 J1rj2Sw9n8GfbBx9oFktX1Ox9+mJP7RgV/UFM1PVsPgFT6qKNDDmaHxhRl3uSSINXWBL Fq6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564609; x=1724169409; 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=8lU2YFi0z6iWwdFzjptg9xLGk32SzO7YL037hOMc5X4=; b=oeRLk1wAwexUHMrzqpYvrL/+qsrXbRr4MHn+fFqFHvsS+NoxgGCWq9LinPkRYgvihu ndp3Ttj5ERwWG05X+WIPpronKwAWL+HRmVf+860KXpI6QbTTPWlfXtfru0vGbdsdsH/e XLhb3vHNhKWB/TC4ymf/dJ8gAnmyP93EfKWWNQ4FvSvNSfVKAseKAiqd6ehH55zpjuY9 XYyyRaKve8D0XE5p/tVP8OJ3DKPZz/d93cYGvam61brYArUoUJeRJiksjBpoY52Ci/CO YPiXlMuWX+z1iQS7V9KI1PeEg0SHyDGoot/psJHGNaFr/JHefXyowpUJfOpFEtkViIBu bosg== X-Gm-Message-State: AOJu0YytAFyYu7ePWGoQUL5S5FOjhhMjqEZOdE7/cz3EtOT1gAUSjMtA 8Yx9j+q2Am+fYE9OpIHWxQGhk/gB/Cb8fEipCztFkHKsD+dfcRLqF2l9Fg== X-Google-Smtp-Source: AGHT+IFIt5Vvu77AAELJyWWug78/En1dS9PqXkZ79rgOPHg5eL10E+IaOqs1/mbCIGbAn/gg4U8CcA== X-Received: by 2002:a05:6214:4a89:b0:6b5:4249:7c4 with SMTP id 6a1803df08f44-6bf4f66d7a1mr37815246d6.2.1723564609050; Tue, 13 Aug 2024 08:56:49 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bd82ca2024sm35825706d6.72.2024.08.13.08.56.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 08:56:48 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/9] netdev: store signal threshold in netdev object, not globally Date: Tue, 13 Aug 2024 08:56:31 -0700 Message-Id: <20240813155638.74987-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813155638.74987-1-prestwoj@gmail.com> References: <20240813155638.74987-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This prepares for the ability to toggle between two signal thresholds in netdev. Since each netdev may not need/want the same threshold store it in the netdev object rather than globally. --- src/netdev.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/netdev.c b/src/netdev.c index 494e46a5..a9648fbc 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -172,6 +172,9 @@ struct netdev { struct netdev_ext_key_info *ext_key_info; + int low_signal_threshold; + int low_signal_threshold_5ghz; + bool connected : 1; bool associated : 1; bool operational : 1; @@ -206,6 +209,9 @@ static struct l_genl_family *nl80211; static struct l_queue *netdev_list; static struct watchlist netdev_watches; static bool mac_per_ssid; +/* Threshold RSSI for roaming to trigger, configurable in main.conf */ +static int LOW_SIGNAL_THRESHOLD; +static int LOW_SIGNAL_THRESHOLD_5GHZ; static unsigned int iov_ie_append(struct iovec *iov, unsigned int n_iov, unsigned int c, @@ -1058,10 +1064,6 @@ struct netdev *netdev_find(int ifindex) return l_queue_find(netdev_list, netdev_match, L_UINT_TO_PTR(ifindex)); } -/* Threshold RSSI for roaming to trigger, configurable in main.conf */ -static int LOW_SIGNAL_THRESHOLD; -static int LOW_SIGNAL_THRESHOLD_5GHZ; - static void netdev_cqm_event_rssi_threshold(struct netdev *netdev, uint32_t rssi_event) { @@ -1089,8 +1091,9 @@ static void netdev_cqm_event_rssi_value(struct netdev *netdev, int rssi_val) { bool new_rssi_low; uint8_t prev_rssi_level_idx = netdev->cur_rssi_level_idx; - int threshold = netdev->frequency > 4000 ? LOW_SIGNAL_THRESHOLD_5GHZ : - LOW_SIGNAL_THRESHOLD; + int threshold = netdev->frequency > 4000 ? + netdev->low_signal_threshold_5ghz : + netdev->low_signal_threshold; if (!netdev->connected) return; @@ -3585,8 +3588,9 @@ static struct l_genl_msg *netdev_build_cmd_cqm_rssi_update( uint32_t hyst = 5; int thold_count; int32_t thold_list[levels_num + 2]; - int threshold = netdev->frequency > 4000 ? LOW_SIGNAL_THRESHOLD_5GHZ : - LOW_SIGNAL_THRESHOLD; + int threshold = netdev->frequency > 4000 ? + netdev->low_signal_threshold_5ghz : + netdev->low_signal_threshold; if (levels_num == 0) { thold_list[0] = threshold; @@ -6163,6 +6167,8 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg, l_strlcpy(netdev->name, ifname, IFNAMSIZ); netdev->wiphy = wiphy; netdev->pae_over_nl80211 = pae_io == NULL; + netdev->low_signal_threshold = LOW_SIGNAL_THRESHOLD; + netdev->low_signal_threshold_5ghz = LOW_SIGNAL_THRESHOLD_5GHZ; if (set_mac) memcpy(netdev->set_mac_once, set_mac, 6); From patchwork Tue Aug 13 15:56: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: 13762254 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 D059F2AF0D for ; Tue, 13 Aug 2024 15:56:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564613; cv=none; b=nShLwp2JVJ3vIvC+Ui2kfHEnKQkoiqPnWhe3Zuq3sX4M1LMnA1UJ/EcZ5bvdf7meLg3yPg0nBRdVnncKxWmsRGFSOBbQKZtblYmlisC1X1xptPWrCzN9iaT9VLVjPgNcHRZQ0XBMnxHKV9aUMkPUGQsFXjXhPPf7WQaxY5EyAB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564613; c=relaxed/simple; bh=dth8Om/dpd2WPGLKj86XfvoQcZ106g4uJ095+68o3+k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dFI1zxm+CU0BYdPoaAoa0a2PEaLeyfpMes1wyH4xLzARrL97LyjyyjE0+fNVdv7czd35iwgB8YYfMfd+Uu4OAAbUP9v2bfqnkr3/YVltLAKF5iho2tH6FoozetYkJo2S+dtHKPLEylE2VZXGcdM4oFTE1Ri5ERG7FGrkGV5cKuw= 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=AjJP0So2; arc=none smtp.client-ip=209.85.219.47 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="AjJP0So2" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-6b79293a858so30596016d6.3 for ; Tue, 13 Aug 2024 08:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723564610; x=1724169410; 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=Kbjh8fJNxFHHlj8pSoOE9/0QiON10umIEqjdMpqkxO8=; b=AjJP0So2BeeCfH99FZF7bX2wEonttOfU1x8weDuL62MK6AWbtRKkcmEKB3cgtU09sk DXylCrzpgLU90IMYGFdF87C1zgfyS2gR+7/vUCNkbITzdbI58nUTms1jEIqrco9tv2U2 XOhJcodQJ7kYyjO1Lei6eYxTguGY45E67eM4as4X3SgBNgFqI94EX3/GS3o0vPAUOX+T e894UgvYSIzZsXcVjn3nGw+Ml/G72q00/ZDjM9i1PoX/zPi5gLZq0gfVPsI9Jx1esJlh 47IA01varqDY4/EXA6JU/QJNJchOaLRX4xkhDUxNmJ0q0DTs9k/mN9h/JsK9H0wZFcM6 68qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564610; x=1724169410; 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=Kbjh8fJNxFHHlj8pSoOE9/0QiON10umIEqjdMpqkxO8=; b=Nbq7x3u4skKXCc2QwXSld8hsMCpSMEs89WHgacJewd3x5HtuG4/O02Lq1FN+1e9aV+ OkjeigOknvd1+t4qB50X2TsfbFaxNbvbMheEH4uTI8WSSt2ZTsJf8ZlrfjDWfukhYwpJ Q43P5uCaFvYcI4Vvsb2BhUhcenq0rHCMWzsVWJF8+6R2O2zZzds0qA1zEaPBbeICBOSL dIx0wy1PLV07OedaUsUPNg1MA48YYYa47SH22bJzW7mUnZ+YOPzqkNl2bjohHtEakvws oDA/sDamr3Vr5eVNlEsb+ZWBAi5+LHnWcBLTW6ZAkXaZ7EQ7pYh/FHxc7PXME2naxYP5 R5xw== X-Gm-Message-State: AOJu0YwC7Bus86btNq2Dy0ZvWF9gJm/7jyj7sINLhVaWBaG6+Tzoc/km YsmPDDtlud4S+SHn+SrUZvzfCQjsxieJd2CPHX56BIFd8BYEYq9YiRnqNg== X-Google-Smtp-Source: AGHT+IHe/5tyP1+I3pIefLl/T26anRHEvx/XTO1xEwlZxGvIdAsa61pMBf32u3yHL2h/dlbrwDapeA== X-Received: by 2002:a05:6214:2b9a:b0:6b5:116:eb54 with SMTP id 6a1803df08f44-6bf4f86ea4bmr42432326d6.47.1723564610172; Tue, 13 Aug 2024 08:56:50 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bd82ca2024sm35825706d6.72.2024.08.13.08.56.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 08:56:49 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/9] netdev: add critical signal threshold level Date: Tue, 13 Aug 2024 08:56:32 -0700 Message-Id: <20240813155638.74987-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813155638.74987-1-prestwoj@gmail.com> References: <20240813155638.74987-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This adds a secondary set of signal thresholds. The purpose of these are to provide more flexibility in how IWD roams. The critical threshold is intended to be temporary and is automatically reset upon any connection changes: disconnects, roams, or new connections. --- src/netdev.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/netdev.h | 2 ++ 2 files changed, 53 insertions(+) diff --git a/src/netdev.c b/src/netdev.c index a9648fbc..94766552 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -212,6 +212,8 @@ static bool mac_per_ssid; /* Threshold RSSI for roaming to trigger, configurable in main.conf */ static int LOW_SIGNAL_THRESHOLD; static int LOW_SIGNAL_THRESHOLD_5GHZ; +static int CRITICAL_SIGNAL_THRESHOLD; +static int CRITICAL_SIGNAL_THRESHOLD_5GHZ; static unsigned int iov_ie_append(struct iovec *iov, unsigned int n_iov, unsigned int c, @@ -841,6 +843,10 @@ static void netdev_connect_free(struct netdev *netdev) l_genl_family_cancel(nl80211, netdev->get_oci_cmd_id); netdev->get_oci_cmd_id = 0; } + + /* Reset thresholds back to default */ + netdev->low_signal_threshold = LOW_SIGNAL_THRESHOLD; + netdev->low_signal_threshold_5ghz = LOW_SIGNAL_THRESHOLD_5GHZ; } static void netdev_connect_failed(struct netdev *netdev, @@ -3674,6 +3680,39 @@ static int netdev_cqm_rssi_update(struct netdev *netdev) return 0; } +static int netdev_set_signal_thresholds(struct netdev *netdev, int threshold, + int threshold_5ghz) +{ + int current = netdev->frequency > 4000 ? + netdev->low_signal_threshold_5ghz : + netdev->low_signal_threshold; + int new = netdev->frequency > 4000 ? threshold_5ghz : threshold; + + if (current == new) + return -EALREADY; + + l_debug("changing low signal threshold to %d", new); + + netdev->low_signal_threshold = threshold; + netdev->low_signal_threshold_5ghz = threshold_5ghz; + + netdev_cqm_rssi_update(netdev); + + return 0; +} + +int netdev_lower_signal_threshold(struct netdev *netdev) +{ + return netdev_set_signal_thresholds(netdev, CRITICAL_SIGNAL_THRESHOLD, + CRITICAL_SIGNAL_THRESHOLD_5GHZ); +} + +int netdev_raise_signal_threshold(struct netdev *netdev) +{ + return netdev_set_signal_thresholds(netdev, LOW_SIGNAL_THRESHOLD, + LOW_SIGNAL_THRESHOLD_5GHZ); +} + static bool netdev_connection_work_ready(struct wiphy_radio_work_item *item) { struct netdev *netdev = l_container_of(item, struct netdev, work); @@ -3887,6 +3926,8 @@ done: netdev->handshake = hs; netdev->sm = sm; netdev->cur_rssi = bss->signal_strength / 100; + netdev->low_signal_threshold = LOW_SIGNAL_THRESHOLD; + netdev->low_signal_threshold_5ghz = LOW_SIGNAL_THRESHOLD_5GHZ; if (netdev->rssi_levels_num) netdev_set_rssi_level_idx(netdev); @@ -4260,6 +4301,8 @@ int netdev_ft_reassociate(struct netdev *netdev, netdev->event_filter = event_filter; netdev->connect_cb = cb; netdev->user_data = user_data; + netdev->low_signal_threshold = LOW_SIGNAL_THRESHOLD; + netdev->low_signal_threshold_5ghz = LOW_SIGNAL_THRESHOLD_5GHZ; /* * Cancel commands that could be running because of EAPoL activity @@ -6278,6 +6321,14 @@ static int netdev_init(void) &LOW_SIGNAL_THRESHOLD_5GHZ)) LOW_SIGNAL_THRESHOLD_5GHZ = -76; + if (!l_settings_get_int(settings, "General", "CriticalRoamThreshold", + &CRITICAL_SIGNAL_THRESHOLD)) + CRITICAL_SIGNAL_THRESHOLD = -80; + + if (!l_settings_get_int(settings, "General", "CriticalRoamThreshold5G", + &CRITICAL_SIGNAL_THRESHOLD_5GHZ)) + CRITICAL_SIGNAL_THRESHOLD_5GHZ = -82; + rand_addr_str = l_settings_get_value(settings, "General", "AddressRandomization"); if (rand_addr_str && !strcmp(rand_addr_str, "network")) diff --git a/src/netdev.h b/src/netdev.h index db0440d0..3a772256 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -197,6 +197,8 @@ int netdev_neighbor_report_req(struct netdev *netdev, int netdev_set_rssi_report_levels(struct netdev *netdev, const int8_t *levels, size_t levels_num); +int netdev_lower_signal_threshold(struct netdev *netdev); +int netdev_raise_signal_threshold(struct netdev *netdev); int netdev_get_station(struct netdev *netdev, const uint8_t *mac, netdev_get_station_cb_t cb, void *user_data, From patchwork Tue Aug 13 15:56:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13762255 Received: from mail-yb1-f175.google.com (mail-yb1-f175.google.com [209.85.219.175]) (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 B517F1A08AB for ; Tue, 13 Aug 2024 15:56:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564614; cv=none; b=jopy2+KTysl45K95IKHkXESpT/DXB0pcuzk3dtAP3dtYagH8tNg5/7nhGWeua+OlVHbJx8rRLb6X8iX1pG1Ey8SMcauBBi9sGThxwFzMTmyvXDsPNuMG9qZg0k7wdmUue4xrqZC25LtXx3DA5IRR8tUYiJShWjn6VAcGP47aKyU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564614; c=relaxed/simple; bh=7zC6ykoUJCb6Jt8r+4q72RjpJW+OKWUBOovnk/6cJKg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=THcRLQmQTZICmUFchSwr7FZ6jF2lamvbFqA6q/GQwBxODcuSPIwBbnG1FmgqmUseoI1pwp3goKE62CnBHx05qESOqU4kwL6irzom+y3xiFnUEiyJSH3dS/AlFQ3Fu4gnfEllzSOBXyHOpEcNUmfnUDkMjHxVOexDAn+opdxqhZ4= 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=IQ/2YbDw; arc=none smtp.client-ip=209.85.219.175 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="IQ/2YbDw" Received: by mail-yb1-f175.google.com with SMTP id 3f1490d57ef6-e0857a11862so5655726276.1 for ; Tue, 13 Aug 2024 08:56:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723564611; x=1724169411; 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=3RBbbQQ27ghq0kvYe6nKRsI9oUMREb0TxyQIFOqk6Mo=; b=IQ/2YbDwf3g47ARLE6wD+1xG/Ekj4sGwsUh6XA+lRIdt2VZ944fdnekl4AYSpvMjZJ 7kfngsOhJ4Wk7m9WyhQjJ1IsK+HZcUtRDDRfnwkfk4ibGDqMlbD8ggELTEnWQI0kGzDi 6T96ogYPaPpBkqgLUeuDBXt8TkPeHX1pUCPwswS4Qe7vOYMTDtwKJ2Cw5EZNMqcsqkfR hHFvtuQlflxx8qn6FkRGyEbk5Qxr6xgo6+G+Kgg5DAaabMqcd/uScJPKpFRpAy8FHSj3 Wm4IVLmKAZJG4ufFrP8SLHv3YyFeCzahBu8tCnmpayjj1tbr4IKkDfM3We/165gaJh7g +Dfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564611; x=1724169411; 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=3RBbbQQ27ghq0kvYe6nKRsI9oUMREb0TxyQIFOqk6Mo=; b=AL6x8vr2TgyrHmkM+IJ5iYIgwGC2fj8IKW75SkVrFKuV6F16FJ9heNMJ46Fj8ZhLss E582HY0TQHCE9JwFwMYVCOe0p3AhIfOvhzanNAtg5Aj/FqJoU7Tfvf2BCh/gLbmO5VfC E4DJ5u444nYEr8e/MObn42hs5aV29qqMEapaL/k+5KUDuAJTTVLGFp34padBVwwR7ihy iYIkNd0TAUbOULnhslL+fft4s3ABMsSJQK1hVMpPc+k097CcbiAMg8OSOGPVpQbdJukh b8q6ZuufYqehnAczmCF5qOUstcxznL/x73b07VUB90GyTPxASVrPDU8PqtfeCTMkRbo0 NrQg== X-Gm-Message-State: AOJu0YxcTvkHnl7OmBUqYrFMNHlgzE8Ln8nAQysIxWPVs8qP53iJ2BEs YhZp2za/oZFev5jefZTHdekZdxvV2lmwDh9a7e6QqPNsNpK8yWajedVEfA== X-Google-Smtp-Source: AGHT+IHlHZ5HTJd47Vj9gbYzUySLMvCjTllAij6CjzsrRqNJh/RwinbVTlIMtIBWenvhInKgnYi32w== X-Received: by 2002:a05:6902:1026:b0:e03:55f1:319d with SMTP id 3f1490d57ef6-e113d27b97fmr4768265276.39.1723564611333; Tue, 13 Aug 2024 08:56:51 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bd82ca2024sm35825706d6.72.2024.08.13.08.56.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 08:56:50 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 4/9] netdev: add netdev_get_critical_signal_threshold Date: Tue, 13 Aug 2024 08:56:33 -0700 Message-Id: <20240813155638.74987-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813155638.74987-1-prestwoj@gmail.com> References: <20240813155638.74987-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This is set via a main.conf option but to avoid duplicated settings parsing in station add a getter API. --- src/netdev.c | 6 ++++++ src/netdev.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/netdev.c b/src/netdev.c index 94766552..c7d0d880 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -3713,6 +3713,12 @@ int netdev_raise_signal_threshold(struct netdev *netdev) LOW_SIGNAL_THRESHOLD_5GHZ); } +int netdev_get_critical_signal_threshold(struct netdev *netdev) +{ + return netdev->frequency > 4000 ? CRITICAL_SIGNAL_THRESHOLD_5GHZ : + CRITICAL_SIGNAL_THRESHOLD; +} + static bool netdev_connection_work_ready(struct wiphy_radio_work_item *item) { struct netdev *netdev = l_container_of(item, struct netdev, work); diff --git a/src/netdev.h b/src/netdev.h index 3a772256..f89aa572 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -199,6 +199,7 @@ int netdev_set_rssi_report_levels(struct netdev *netdev, const int8_t *levels, size_t levels_num); int netdev_lower_signal_threshold(struct netdev *netdev); int netdev_raise_signal_threshold(struct netdev *netdev); +int netdev_get_critical_signal_threshold(struct netdev *netdev); int netdev_get_station(struct netdev *netdev, const uint8_t *mac, netdev_get_station_cb_t cb, void *user_data, From patchwork Tue Aug 13 15:56:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13762256 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (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 B77352AF0D for ; Tue, 13 Aug 2024 15:56:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564615; cv=none; b=BVM3iOWtCMw9fRMe3FKefxOGXy5xdJR54SM2cRh/xGAxx877YlSpoMdq2eIJfngiF0vDuVBzj+U76CpMp66rwVp/5L3g8eDHXDqJrZzOkM236uzc+dGXh1+F0uUeQkbn0pm4MAwNl1jS4cLeUKkDR10OIbxd85OmZjfpRmEjwfw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564615; c=relaxed/simple; bh=kMTA5n6IXRmtW6cDWYfD0Ws9JWGuCj4GfDlR3uc3VWg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jzV+bg3JpgymR7Nm+0D/j3pTWgqtR44dksXQD2DQDCBprUzuY8sApMoTn+UdKDHiSDtAe4cze6bpswQPeg5JwvDfEQQSDS+uAIYJ6UJm6nWsrL1Mf6ZBRGjdKDYBTAMA89h3dV+rjAYJhk1WRg6VHVrgqjUVfPNLFbzhAffdvoc= 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=P017gfJD; arc=none smtp.client-ip=209.85.160.169 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="P017gfJD" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-4503ccbc218so53184981cf.1 for ; Tue, 13 Aug 2024 08:56:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723564612; x=1724169412; 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=EX7DQ8XWfm7Wx1d9c/9k0ifUHByA3qMM3NT2FMgRDnU=; b=P017gfJDiGuL+Um1lstFxZ3p3GDOxINgun7stlSkNQVXcR9plguOJD82W5hg6vVG41 wzKRIT4kcJWxsMVxf25vDG7PN8mik5uLrNy/Q3T5oj8qCnK+WWYDUflmGCYrSNntYhpp hEYndwn+ZWUxxSuCNjvStbWCUPiEKtUjii9EoHLgEZYr4vMjsVRz5p8vOXjZU9D38yg7 F5xyklRyT6T+hCNpZbn7A6cRwsfy7heDit+bqVk7Wa5vMQuo38qhivPWtStGrm8RZkKk Zgop+MaNvA9/g3o0OBUKEyVidxBPRJmexAWDXDQ6PXn0KG4vSL4W4ULXHMHGrr300owt ybPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564612; x=1724169412; 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=EX7DQ8XWfm7Wx1d9c/9k0ifUHByA3qMM3NT2FMgRDnU=; b=fy/U4Ny36n884II/JXSSrLkVTale4ktXHDb/8m3Kx1WF88e+81M9ffmd+9F5sF+tLy u90kJHbOCwJQtOfsBr3+tmIdO7lXBggbtFquNM06r0ZAoa4SsDSebhL2E62bcLCPtSBy ATtGIGHjRzJQfDD/KtrWZcoZVj1IqrSrrm6CUiJJnuJ52tB7Vg+73b2wOqr1pOH6igC3 K3EfcryvMvaQglIEWnmS58Aa1AxQwmKeL8chsGsnbndQbj3gYz/QLeMcGf5N66C0ZQDr Q4tqNllXdi5vf86AIX9I7S2SaXKH41nQmf/PpYm9kYpmqe/JjtgwjiRTc6f9ydBC9oF5 h+pQ== X-Gm-Message-State: AOJu0YxShKgjWvVX5bA3+t7cxnJWJ6O6FK9PwR2LLPLp82v16KQUoLgj xVs9Spy5PMGXdwQh+pMDnUETJWltKtw+6yctE3wJIS2353VUFkLSKvxeKw== X-Google-Smtp-Source: AGHT+IE8AyduAh7HnY+r6+MVKBlpQYt+DgnXhcxETII18VFaloEWRz2fQxdPqMfsmqXA9D61WHMi0A== X-Received: by 2002:ad4:5d4d:0:b0:6b7:8c94:cd15 with SMTP id 6a1803df08f44-6bf50bebf82mr63575996d6.10.1723564612445; Tue, 13 Aug 2024 08:56:52 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bd82ca2024sm35825706d6.72.2024.08.13.08.56.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 08:56:52 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 5/9] station: emit property changed for ConnectedAccessPoint Date: Tue, 13 Aug 2024 08:56:34 -0700 Message-Id: <20240813155638.74987-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813155638.74987-1-prestwoj@gmail.com> References: <20240813155638.74987-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 missed in a prior patch set. When station is connecting or disconnecting ConnectedAccessPoint property change should be emitted. --- src/station.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/station.c b/src/station.c index 06b19db3..3b61f264 100644 --- a/src/station.c +++ b/src/station.c @@ -1639,6 +1639,8 @@ static void station_enter_state(struct station *station, l_dbus_property_changed(dbus, netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "ConnectedNetwork"); + l_dbus_property_changed(dbus, netdev_get_path(station->netdev), + IWD_STATION_INTERFACE, "ConnectedAccessPoint"); l_dbus_property_changed(dbus, network_get_path(station->connected_network), IWD_NETWORK_INTERFACE, "Connected"); @@ -1810,6 +1812,8 @@ static void station_reset_connection_state(struct station *station) l_dbus_property_changed(dbus, netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "ConnectedNetwork"); + l_dbus_property_changed(dbus, netdev_get_path(station->netdev), + IWD_STATION_INTERFACE, "ConnectedAccessPoint"); l_dbus_property_changed(dbus, network_get_path(network), IWD_NETWORK_INTERFACE, "Connected"); l_dbus_object_remove_interface(dbus, netdev_get_path(station->netdev), From patchwork Tue Aug 13 15:56:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13762257 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 D0C651A08AF for ; Tue, 13 Aug 2024 15:56:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564616; cv=none; b=J0jIZvWkXZnSUvUx6oCqKwQ3bfTQJ/8JvQjEwglfCiqNuzoAf+IcmZPI4e0BxrO2SzRrNCSfgOi5RWF+4LPg5Weu1ZJD7/Ehlp0173Afvn1SYkl8+VOUBtFSiQWCA3QNVMcnP6UVtPeQP+2yPcR90I6DMT/y5KAYXESrahv45yU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564616; c=relaxed/simple; bh=5cS2Ng99j8FvnlYVAL2agErIfEhzVRe2cCiT95Pst7U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dRhCT1s3ugis8T1zLRbLh26lQgjyKdU7ffXKjUvTx1gC9IhtJtgFHiJ2lbKuZY6m357Ac3gvDUv/lcgNHyB2TYE8WVQ49c6e3BXqg9xWERmfukqsBW4EaMtj/cqxc+WV/lDjCRFs1p2QF7A+YlK2ppBpJ6NhGeGtdupHEdhyuuc= 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=Y9QoiQvx; arc=none smtp.client-ip=209.85.219.43 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="Y9QoiQvx" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6b79fc76d03so32346916d6.1 for ; Tue, 13 Aug 2024 08:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723564613; x=1724169413; 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=L9RiH8vthCTFHuc0Xkd7Boj5/77AjlJKly806m0IT0c=; b=Y9QoiQvxFyB3jCX9mjd0eviE8gk8qx0p6jlBOBDlI8rKlw8f/WuOx9oeWCwHZ2JaOB 2V3ChBWrZCS44TuTPjvu2x92ec4WCp7CHFelGXx3dAhaIpGPKgzd7uJ38l5kthE32UI9 F9yhP6ak2LiDXFqx53Yf2GKR5ro4LosDZLMC1esX5RO8qGVhpFNvNkorSc+ndR5U+wGD C/4PB39gAPa575QCnBL1fjBAeuuIy/aJEWbfKcjj6Tchiq3Q/WnivIdnGprnj+PTh8HC HHCZm/8yc3VK6hTSBVXbXk6jhS6gqpA4YKvzUjWeHYbXU9ZTtiVQ8oHrmiy4+L2n/eEK TYXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564613; x=1724169413; 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=L9RiH8vthCTFHuc0Xkd7Boj5/77AjlJKly806m0IT0c=; b=t21IazMiXevhhQruTkmNURRvNKpRUvhgoZBcatGFrGq7KgcW8gVqoAYnhT+OLQCRXx od0hytprJKRjYshp17n+Dsk4VZpR+Hp3tH+Vn6B8e6Rk8qroZfFC1srUIEu17XpsWpZN bA1nDpa2gMUyU6pTUEMqE/8sLM/4b4XnbWL7LFGmDZ0qSF/3FRnPtcZoDraRI80d7uEj irwmjR5t4e35QHxMhdgiG7hNr9hti6+rHf2j5+eXiMZBsRXAhdbw1xNQP6ElMwpmknLZ +/bKw7sI0vLflz/HFW+ybeHNjviNH+tYbuwPd3tL1PnfM2t7eRA1j5oJ7TFOTLOSAkQi BO2w== X-Gm-Message-State: AOJu0YwTCJouxW7Ub+bwkUD5SZzZ8luJB0mtz1js4B/tS5PKXdsL47+D bhsYcq6spr3P4PxQCt+VaUfbXdnfm1ByUgM3WfnZXRz+X2lKaSftSUm3Dg== X-Google-Smtp-Source: AGHT+IENDketRdmis9NfJelxC4udnPJM5iezA9de+vTrEzqhT7vO1zOhxooOdAyw3AA1dq/IOeE32g== X-Received: by 2002:a05:6214:2f8f:b0:6b5:ea0e:98f with SMTP id 6a1803df08f44-6bf4f444f9dmr55814476d6.0.1723564613549; Tue, 13 Aug 2024 08:56:53 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bd82ca2024sm35825706d6.72.2024.08.13.08.56.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 08:56:53 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 6/9] station: add Affinities DBus property Date: Tue, 13 Aug 2024 08:56:35 -0700 Message-Id: <20240813155638.74987-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813155638.74987-1-prestwoj@gmail.com> References: <20240813155638.74987-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This property will hold an array of object paths for BasicServiceSet (BSS) objects. For the purpose of this patch only the setter/getter and client watch is implemented. The purpose of this array is to guide or loosly lock IWD to certain BSS's provided that some external client has more information about the environment than what IWD takes into account for its roaming decisions. For example: - If the device is stationary an external client could reduce the likelihood of roaming by setting the affinity to the current BSS. - If an external client has knowledge of the devices planned route though the environment it could plan a path to roam between particular APs to reduce and optimize roaming. --- src/station.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) diff --git a/src/station.c b/src/station.c index 3b61f264..75dd13bb 100644 --- a/src/station.c +++ b/src/station.c @@ -128,6 +128,10 @@ struct station { uint64_t last_roam_scan; + char **affinities; + unsigned int affinity_watch; + char *affinity_client; + bool preparing_roam : 1; bool roam_scan_full : 1; bool signal_low : 1; @@ -1685,6 +1689,13 @@ static void station_enter_state(struct station *station, station_set_evict_nocarrier(station, true); station_set_drop_neighbor_discovery(station, false); station_set_drop_unicast_l2_multicast(station, false); + + if (station->affinity_watch) { + l_dbus_remove_watch(dbus_get_bus(), + station->affinity_watch); + station->affinity_watch = 0; + } + break; case STATION_STATE_DISCONNECTING: case STATION_STATE_NETCONFIG: @@ -4463,6 +4474,112 @@ static bool station_property_get_state(struct l_dbus *dbus, return true; } +static bool station_property_get_affinities(struct l_dbus *dbus, + struct l_dbus_message *message, + struct l_dbus_message_builder *builder, + void *user_data) +{ + struct station *station = user_data; + char **path = station->affinities; + + if (!station->connected_network) + return false; + + l_dbus_message_builder_enter_array(builder, "o"); + + while (path && *path) { + l_dbus_message_builder_append_basic(builder, 'o', *path); + path++; + } + + l_dbus_message_builder_leave_array(builder); + + return true; +} + +static void station_affinity_disconnected_cb(struct l_dbus *dbus, + void *user_data) +{ + struct station *station = user_data; + + l_dbus_remove_watch(dbus_get_bus(), station->affinity_watch); + station->affinity_watch = 0; + + l_debug("client that set affinity has disconnected"); +} + +static void station_affinity_watch_destroy(void *user_data) +{ + struct station *station = user_data; + + l_free(station->affinity_client); + station->affinity_client = NULL; + + l_strv_free(station->affinities); + station->affinities = NULL; +} + +static struct l_dbus_message *station_property_set_affinities( + struct l_dbus *dbus, + struct l_dbus_message *message, + struct l_dbus_message_iter *new_value, + l_dbus_property_complete_cb_t complete, + void *user_data) +{ + struct station *station = user_data; + struct l_dbus_message_iter array; + const char *sender = l_dbus_message_get_sender(message); + const char *path; + char **new_affinities; + + if (!station->connected_network) + return dbus_error_not_connected(message); + + if (!station->affinity_watch) { + station->affinity_client = l_strdup(sender); + station->affinity_watch = l_dbus_add_disconnect_watch(dbus, + sender, + station_affinity_disconnected_cb, + station, + station_affinity_watch_destroy); + } else if (strcmp(station->affinity_client, sender)) { + l_warn("Only one client may manage Affinities property"); + return dbus_error_not_available(message); + } + + if (!l_dbus_message_iter_get_variant(new_value, "ao", &array)) + return dbus_error_invalid_args(message); + + new_affinities = l_strv_new(); + + while (l_dbus_message_iter_next_entry(&array, &path)) { + const char *p = network_get_path(station->connected_network); + + /* + * It can't be assumed that the specific BSS has been seen, but + * at least validate the device/network portion matches the + * connected network. + */ + if (strncmp(p, path, strlen(p))) { + l_warn("Can't set affinity to BSS (%s)", path); + l_strv_free(new_affinities); + return dbus_error_invalid_args(message); + } + + new_affinities = l_strv_append(new_affinities, path); + } + + l_strv_free(station->affinities); + station->affinities = new_affinities; + + l_dbus_property_changed(dbus, netdev_get_path(station->netdev), + IWD_STATION_INTERFACE, "Affinities"); + + complete(dbus, message, NULL); + + return NULL; +} + void station_foreach(station_foreach_func_t func, void *user_data) { const struct l_queue_entry *entry; @@ -4693,6 +4810,7 @@ static struct station *station_create(struct netdev *netdev) station_set_autoconnect(station, autoconnect); station->roam_bss_list = l_queue_new(); + station->affinities = l_strv_new(); return station; } @@ -4785,6 +4903,9 @@ static void station_free(struct station *station) l_queue_destroy(station->roam_bss_list, l_free); + if (station->affinity_watch) + l_dbus_remove_watch(dbus_get_bus(), station->affinity_watch); + l_free(station); } @@ -4821,6 +4942,9 @@ static void station_setup_interface(struct l_dbus_interface *interface) station_property_get_scanning, NULL); l_dbus_interface_property(interface, "State", 0, "s", station_property_get_state, NULL); + l_dbus_interface_property(interface, "Affinities", 0, "ao", + station_property_get_affinities, + station_property_set_affinities); } static void station_destroy_interface(void *user_data) From patchwork Tue Aug 13 15:56:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13762258 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (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 B58CE1A0AEA for ; Tue, 13 Aug 2024 15:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564618; cv=none; b=I5rE8FlV/L9CSmtO1AVmPDDf6SFoce9Xr6NfPBA2fcF5Xyi7HVJedf5hAKpfrZVngpog+J4Hzj0qxEXdX2KHDpt9PAnGVSj1Oq4SeDh8J3qBwKyt7yts6Tmm3phPRb7ig/8ePwyMnVeZxqYxgZFSfqW+4cs6bH0LiN1QI4h77u0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564618; c=relaxed/simple; bh=+JGkrbS5gRabEE/gZQytXyVytzo5CjkcleAJqqcbBQY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rIQlfI4v28DEs6whT5rjFJ1YbOGv2FcDyMtXk1GZdkSOWrdQV8Qry6NHQmiOd+I2xYkOdqP0ia24q5V4axmK7IypekD6AmWDWeBNd8g5tRkWyygiKNEqqk6BhdMeLbQRKqoBM0e7XI6kT+JAnE/9aCYJsgI9FHtyMpCzF03Z4fA= 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=J8kbm0VG; arc=none smtp.client-ip=209.85.160.182 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="J8kbm0VG" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-44fdcd7a622so28891141cf.0 for ; Tue, 13 Aug 2024 08:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723564615; x=1724169415; 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=5dmXZytG3ukuaCtKImFchOvWdu9wvkdksozRnpw0aPM=; b=J8kbm0VGVitCGMK1FM3PTlQPm4ynwCXBOtjXEYViOTAvdLDvFNhIwo1BktdVKEZTk+ Fb34VUPoQVIJ+CE7hQhzxNWfyD9eTzW9tU4R6pBfSV+G/yUgcH1kxYOnTUhBVPVk2cy+ qdLujTqlTSQgohvEyixpPvkmbw2Ui+4XEaPXa+VCn0EgQMF60j8VaxLNlj2G4qzOqStl 49TAIGA3WOx2+s2LutzDAt7R/KsvtSbhCMD6qtWv1g6GaBUO4Ht7qe7SQ+T+R7YL5aL6 1ArP+8EauJNjgncI9Ci2EZm5u//QXroDo4w65AfO5cfIEjnflkuJ64cYmtDJEE1GCLEW d6AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564615; x=1724169415; 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=5dmXZytG3ukuaCtKImFchOvWdu9wvkdksozRnpw0aPM=; b=s3Fx71mO7RIza+4DXsrpxWHcBLRrDCrqSKqfe1HmQmUuArOOjiFPRF8YQ4+k87knjA 7HRlbGQo0Zd1MxkcjFmzhqvbOQEf9LXzq+i4lxJsI46Yn4An+EYD5KAEx8dUJ3H4v7is sXocUcMgOTyjObHveEP/2zxNXBlKezdIscuNDfqwF2AYmUTKRlGRBwd2t7kpbGygl78v NJ4asSRGeggmCjyFiXtf1pC7oPrq115xfGNhlS6DEWPbERqW/j/Ek9HExiBU0kguQVsO dJrrmiLi0wzfnbu2LlzukLdbg7TjRwsXFLEeAsOpwXzr2qa+OqLmRUhbxAkaHScLiHTL 8q5g== X-Gm-Message-State: AOJu0YwJLSuE3xP7kvM5pZ4SgQWaFOdl5HvoY76xp57aLD3cafbSCVeI dm3xAWpjUb0ZURCFY3WmiZ7yVAeGEXalTJfO7a5cYBh8prIz4A/LwdwmBg== X-Google-Smtp-Source: AGHT+IGwKT+p6JPYpDiQo9bug+dlVl/KzOxonGONuHp+KqJ83a7XgRX/McQXTMjIft7JGn5WRUY3eQ== X-Received: by 2002:a05:6214:2f8f:b0:6b5:e190:435 with SMTP id 6a1803df08f44-6bf4f8c13f3mr52433726d6.50.1723564614673; Tue, 13 Aug 2024 08:56:54 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bd82ca2024sm35825706d6.72.2024.08.13.08.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 08:56:54 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 7/9] station: Use Affinities property for roaming/ranking decisions Date: Tue, 13 Aug 2024 08:56:36 -0700 Message-Id: <20240813155638.74987-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813155638.74987-1-prestwoj@gmail.com> References: <20240813155638.74987-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 There are two pieces where the affinity to a BSS will come into play: The first is while connected to a BSS with the affinity set. In this scenario station will lower the roaming threshold in order to loosly lock IWD to this BSS. By lowering the roaming threshold we can avoid roaming/scanning in cases where the device is not moving i.e. if an external client knows this information. The second effect BSS affinity has is to modify ranking when choosing a roam candidate. A new ranking modifier has been added that will be applied to a BSS rank given: - The BSS is in the Affinities array - The BSS signal is above the critical threshold (set in main.conf [General].CriticalRoamThreshold{_5GHZ}). --- src/station.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/station.c b/src/station.c index 75dd13bb..ab04dcf2 100644 --- a/src/station.c +++ b/src/station.c @@ -1682,6 +1682,11 @@ static void station_enter_state(struct station *station, if (station->connected_bss->hs20_dgaf_disable) station_set_drop_unicast_l2_multicast(station, true); + if (l_strv_contains(station->affinities, + network_bss_get_path(station->connected_network, + station->connected_bss))) + netdev_lower_signal_threshold(station->netdev); + break; case STATION_STATE_DISCONNECTED: periodic_scan_stop(station); @@ -2673,6 +2678,23 @@ static void station_update_roam_bss(struct station *station, scan_bss_free(old); } +static bool station_apply_bss_affinity(struct station *station, + struct scan_bss *bss) +{ + struct network *network = station->connected_network; + const char *path = network_bss_get_path(network, bss); + + /* + * Even if the BSS has the affinity set, don't apply the factor if its + * RSSI is below the critical threshold. + */ + if (bss->signal_strength / 100 < + netdev_get_critical_signal_threshold(station->netdev)) + return false; + + return l_strv_contains(station->affinities, path); +} + static bool station_roam_scan_notify(int err, struct l_queue *bss_list, const struct scan_freq_set *freqs, void *userdata) @@ -2684,6 +2706,7 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list, struct scan_bss *bss; double cur_bss_rank = 0.0; static const double RANK_FT_FACTOR = 1.3; + static const double RANK_AFFINITY_FACTOR = 1.7; uint16_t mdid; enum security orig_security, security; @@ -2715,6 +2738,9 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list, if (hs->mde && bss->mde_present && l_get_le16(bss->mde) == mdid) cur_bss_rank *= RANK_FT_FACTOR; + + if (station_apply_bss_affinity(station, bss)) + cur_bss_rank *= RANK_AFFINITY_FACTOR; } /* @@ -2765,6 +2791,9 @@ static bool station_roam_scan_notify(int err, struct l_queue *bss_list, if (hs->mde && bss->mde_present && l_get_le16(bss->mde) == mdid) rank *= RANK_FT_FACTOR; + if (station_apply_bss_affinity(station, bss)) + rank *= RANK_AFFINITY_FACTOR; + if (rank <= cur_bss_rank) goto next; @@ -4506,6 +4535,9 @@ static void station_affinity_disconnected_cb(struct l_dbus *dbus, station->affinity_watch = 0; l_debug("client that set affinity has disconnected"); + + /* The client who set the affinity disconnected, raise the threshold */ + netdev_raise_signal_threshold(station->netdev); } static void station_affinity_watch_destroy(void *user_data) @@ -4531,6 +4563,8 @@ static struct l_dbus_message *station_property_set_affinities( const char *sender = l_dbus_message_get_sender(message); const char *path; char **new_affinities; + const char *connected_path; + bool lower_threshold = false; if (!station->connected_network) return dbus_error_not_connected(message); @@ -4550,6 +4584,8 @@ static struct l_dbus_message *station_property_set_affinities( if (!l_dbus_message_iter_get_variant(new_value, "ao", &array)) return dbus_error_invalid_args(message); + connected_path = network_bss_get_path(station->connected_network, + station->connected_bss); new_affinities = l_strv_new(); while (l_dbus_message_iter_next_entry(&array, &path)) { @@ -4566,6 +4602,9 @@ static struct l_dbus_message *station_property_set_affinities( return dbus_error_invalid_args(message); } + if (!strcmp(path, connected_path)) + lower_threshold = true; + new_affinities = l_strv_append(new_affinities, path); } @@ -4575,6 +4614,17 @@ static struct l_dbus_message *station_property_set_affinities( l_dbus_property_changed(dbus, netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "Affinities"); + /* + * If affinity was set to the current BSS, lower the roam threshold. If + * the connected BSS was not in the list raise the signal threshold. + * The threshold may already be raised, in which case netdev will detect + * this and do nothing. + */ + if (lower_threshold) + netdev_lower_signal_threshold(station->netdev); + else + netdev_raise_signal_threshold(station->netdev); + complete(dbus, message, NULL); return NULL; From patchwork Tue Aug 13 15:56:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13762259 Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 0C7D81A08A6 for ; Tue, 13 Aug 2024 15:56:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564618; cv=none; b=RoCjkrNHkZWLiG3RmBS+pjwtd+CfLqNkCuMvatWBSUomtqRog6UfH9L6voZtFP+Z2UGwvmCcrzJ19M4u6siyjz8u7sXHvIDw8savAeX9Yk9BX4ncd4mReuLSD52s4z7fu+gF2+okiNZ5ecCEvPyHdYm3jA+Aem5hgGd8M3iQfMY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564618; c=relaxed/simple; bh=S7B1UY64GhhBoY5OYyxIuuHzhi17S4KHnBxHinDFk4k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Vqr+6bpr7BfrFTMoWe1fEiw7vEm9EEoFw3TTdl/gf/oqPaNlAyOSNR6FEDnVpxwcO5/uaQBPtgo6o1jzMFJa2DNdFk7wLH/HGZNS7k0YKb3DgTfpJJ4UPS7trtaJMMsRrox5qMXqpfyqg2ChFSsFMUTNN3Vy5jNSkS4MHOkOjmo= 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=dm2E60hR; arc=none smtp.client-ip=209.85.219.43 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="dm2E60hR" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-6b7a36f26f3so56282436d6.1 for ; Tue, 13 Aug 2024 08:56:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723564616; x=1724169416; 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=mEYzwptQH/JXy4XblJrkhba6Q4l40LpTRB3Fi0c6YWE=; b=dm2E60hRmjjzU8CHysrU1QqRUPy4HejFWgTsRHS/Ymtn7aUecr7R8ckig0A9wq8GW2 2iuKr1oivOELZoIcVzqvBZg6Ww7XCdUzb56Emp1riJPYYgYRTjKXFBYQaLMsPTRxbKyU Np9c3De6f2Kpj2h/qGR7j8mB21+Pb5QQWvBj/Os/mEdnGj0cWc8Bem7XnbTA0+SMoTO7 CTKiLdrwt1W6LOfdGHi5gEYLTYtb/bxlHnb7jzrAhoYygFvLKC1dhsYaMD7pep8DqteL JyQzzX6b9Nq63ETACt2lbXSukc/EfgzLrjgWY4NU+ahTPLjIphTJkdUSdFRI16gFnJYo +d1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564616; x=1724169416; 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=mEYzwptQH/JXy4XblJrkhba6Q4l40LpTRB3Fi0c6YWE=; b=STVh1FDVOk10qBJjvzuVSRS8mVTZsFfH/EvpzNcfSZ2FVQYGEvbaKYV1MWb9roBsgZ d540y1xVYnzTz7+5JKjNZLbz2ICWx8StElSXH29VvAcf52cnkwlPbLmcAHXJ9bB1j9bs 7MWeGPApsTivGERq1hQ9ZVxeBBcn1oM8H3GAmiPVrRq2SIx0aJcXok5k1n/Rl04soSzz MjinDg4a10M+CmjeALVKQApgHCK5qxmi2zYGyevz8H6Qj3RzzZ8ohz0BhL1uoWL2reZP pclvXbBjJQagBbgKhqjOBpJFE6LTt7jG+my1dMBiSAifUhurQrpoKvx/P5MfLhQZ2BHB k8XA== X-Gm-Message-State: AOJu0YzGGSp4Wj4ceE/NEoPJoHD6mS/6KPSHpO13cXCrhbbsbwqMSraj vj21fI1mc5wPT2uPfiTfdyBl0IpFz2mwmDTWtK9IlNiyab9a2n1AIUMIAw== X-Google-Smtp-Source: AGHT+IFKJkY5ypN9QC/BqOf6x04AkFpUh5Cot8E+0h+FkETpcmXAc40QnWf3xYCseZY9TFLf/4EAiw== X-Received: by 2002:a05:6214:5f01:b0:6b4:e21c:d46f with SMTP id 6a1803df08f44-6bf5cc326d9mr1871366d6.27.1723564615859; Tue, 13 Aug 2024 08:56:55 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bd82ca2024sm35825706d6.72.2024.08.13.08.56.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 08:56:55 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 8/9] auto-t: add affinities property for station, and extended_service_set Date: Tue, 13 Aug 2024 08:56:37 -0700 Message-Id: <20240813155638.74987-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813155638.74987-1-prestwoj@gmail.com> References: <20240813155638.74987-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- autotests/util/iwd.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py index 1d4a5472..83f2d9ef 100755 --- a/autotests/util/iwd.py +++ b/autotests/util/iwd.py @@ -596,6 +596,11 @@ class Device(IWDDBusAbstract): props = self._station_properties() return props.get('ConnectedNetwork') + @property + def connected_bss(self): + props = self._station_properties() + return props.get('ConnectedAccessPoint') + @property def powered(self): ''' @@ -630,6 +635,19 @@ class Device(IWDDBusAbstract): self._station_debug._prop_proxy.Set(IWD_STATION_DEBUG_INTERFACE, 'AutoConnect', value) + @property + def affinities(self): + return self._station_properties()['Affinities'] + + @affinities.setter + def affinities(self, values): + self._station_properties() + self._station_prop_if.Set( + IWD_STATION_INTERFACE, 'Affinities', + dbus.Array([dbus.ObjectPath(v) for v in values], signature="o"), + reply_handler=self._success, error_handler=self._failure) + self._wait_for_async_op() + def scan(self, wait=True): '''Schedule a network scan. @@ -975,6 +993,10 @@ class Network(IWDDBusAbstract): ''' return bool(self._properties['Connected']) + @property + def extended_service_set(self): + return self._properties['ExtendedServiceSet'] + def connect(self, wait=True): ''' Connect to the network. Request the device implied by the object From patchwork Tue Aug 13 15:56:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13762260 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.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 7F0BC1A0AF3 for ; Tue, 13 Aug 2024 15:56:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564620; cv=none; b=NIlWAKA96469E8BHNZQaRD8ULy1fPb1Cjc+GBPVDxN6h0WGr0amOCm4+sLWOYmImLtX9cEGTPk1y6qYEsmQc8SCqCuc5dNkoVA4WxaBLearmZzcL0C/ATsojt8Vm2QGaowf4hR0KY58t5FrCUtgoTcDeqhO7uPuxM/0NeFjegTQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723564620; c=relaxed/simple; bh=8hLMnJe9bIdtE+LX70MNwmIvB2g5jRKJo39S8/tGCVk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=GKCCQdCEGgsrDCSrLYT2ZLBIvCUyLob4H8Sjd/EoAc/cLdeXouL5VKzIBHCcqN1xUeQRTHyirj2BFpqs/2I7017E1J88Z6lDUbAD0zd5zkkigEktCwHDnJoisdq0jksiHnyuee625rPymwrzj4RUD4KzNLKAC1aqaMcYUrJxbzc= 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=MPKKLE56; arc=none smtp.client-ip=209.85.219.51 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="MPKKLE56" Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-6b78c980981so31857726d6.2 for ; Tue, 13 Aug 2024 08:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1723564617; x=1724169417; 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=4uKfMHqNkvdM8b0cHGDx72DZKGmRqCA0kvcVQsRlpbM=; b=MPKKLE56MNq+1RWSgOUvtikQowTGmk2w88xlpZznFDvUqdd8ET4SpoXG3/dQJA9ZOP sVxT4I2NmTERWlBOC+GooKSJqLexLu+WLKpVUGmE2lv+jBaI4Ro5rHN5CLtqjtvUdeg1 YkXagZS6VffaTA39cqJeBTukGj6m5QZ9tM9UCgM1H+Xi5jOzSb5VTYVwATa/IDnIPgVb hAfEe7riCiSgp+vhE7MRAARBRUBHgxdxSwBzl6WkDqSGOVFjwIH0lTSGNpE9lsbjgnss n4nQijTjB43us9oi7QGQs5LhJjPQyOt3FYCdm8EuCXCwSy4O9yZm+wbAIwoq7AYAcabk xANA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1723564617; x=1724169417; 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=4uKfMHqNkvdM8b0cHGDx72DZKGmRqCA0kvcVQsRlpbM=; b=CiTbdeq3wW5bc+k/Mzw+XcZfi95NgcyM7VJ7FxacL/X8pD6H32DN7y/OWBVV037x0i 3yQUqDo2HNEI5CTrRbpsMP7ezlbxSGeYNRukfEpfnPFMeZSJxLQvxsdLzJ0/50kcw0iL d2AfNSrcx0734rpocfeFE95V3z421xXT094adIwUsOhNLnelEcyEEDQJg6H8OHjavGG8 zf1Lr4gUzfMwQBhMp1G/93Iii+Stmb2sq7iFlQkRQ7YExlKPjbmzjGxFl8fI1lEmuqWi WNBgtNokcHzJe6WeoWTNMttYxoRFv/IStHGch4ZuMEHj25i1YvhXV0zPN10+G8bB32h+ Td2A== X-Gm-Message-State: AOJu0YxA5sF0DUz+RSUYH7ZKZWHUOT/FoNZH635L3aAm576TDlMrkeST KTrNfq5ZqzuJ3ljMLvrBKGnbhOSVQe1L3SFzQz/cz6a8cmSm7z4Cpz6fFg== X-Google-Smtp-Source: AGHT+IHFu+sjIvqpdjiYMoov7ibJd1T0PBS215F5B1AZZPLD9XLl/cMdc8EGelgOftSPy8KpDg46hQ== X-Received: by 2002:a05:6214:468c:b0:6bb:be58:f282 with SMTP id 6a1803df08f44-6bf4f884af2mr54070626d6.53.1723564616973; Tue, 13 Aug 2024 08:56:56 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bd82ca2024sm35825706d6.72.2024.08.13.08.56.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Aug 2024 08:56:56 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 9/9] auto-t: add tests for Affinities behavior Date: Tue, 13 Aug 2024 08:56:38 -0700 Message-Id: <20240813155638.74987-9-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240813155638.74987-1-prestwoj@gmail.com> References: <20240813155638.74987-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- autotests/testAffinity/TestFT.psk | 2 + autotests/testAffinity/ft-psk-ccmp-1.conf | 41 ++++ autotests/testAffinity/ft-psk-ccmp-2.conf | 41 ++++ autotests/testAffinity/hw.conf | 8 + autotests/testAffinity/main.conf | 5 + autotests/testAffinity/test_set_affinity.py | 231 ++++++++++++++++++++ 6 files changed, 328 insertions(+) create mode 100644 autotests/testAffinity/TestFT.psk create mode 100644 autotests/testAffinity/ft-psk-ccmp-1.conf create mode 100644 autotests/testAffinity/ft-psk-ccmp-2.conf create mode 100644 autotests/testAffinity/hw.conf create mode 100644 autotests/testAffinity/main.conf create mode 100644 autotests/testAffinity/test_set_affinity.py diff --git a/autotests/testAffinity/TestFT.psk b/autotests/testAffinity/TestFT.psk new file mode 100644 index 00000000..e82d1295 --- /dev/null +++ b/autotests/testAffinity/TestFT.psk @@ -0,0 +1,2 @@ +[Security] +Passphrase=EasilyGuessedPassword diff --git a/autotests/testAffinity/ft-psk-ccmp-1.conf b/autotests/testAffinity/ft-psk-ccmp-1.conf new file mode 100644 index 00000000..839eb496 --- /dev/null +++ b/autotests/testAffinity/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=0 +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/testAffinity/ft-psk-ccmp-2.conf b/autotests/testAffinity/ft-psk-ccmp-2.conf new file mode 100644 index 00000000..2ffd7262 --- /dev/null +++ b/autotests/testAffinity/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=0 +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/testAffinity/hw.conf b/autotests/testAffinity/hw.conf new file mode 100644 index 00000000..c2b35d6e --- /dev/null +++ b/autotests/testAffinity/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/testAffinity/main.conf b/autotests/testAffinity/main.conf new file mode 100644 index 00000000..3d93ff57 --- /dev/null +++ b/autotests/testAffinity/main.conf @@ -0,0 +1,5 @@ +[Scan] +DisableMacAddressRandomization=true + +[General] +RoamRetryInterval=1 diff --git a/autotests/testAffinity/test_set_affinity.py b/autotests/testAffinity/test_set_affinity.py new file mode 100644 index 00000000..efd914a4 --- /dev/null +++ b/autotests/testAffinity/test_set_affinity.py @@ -0,0 +1,231 @@ +#! /usr/bin/python3 + +import unittest +import sys, os +import dbus + +sys.path.append('../util') +from config import ctx +import iwd +from iwd import IWD, IWDDBusAbstract +from iwd import NetworkType +from hwsim import Hwsim +from hostapd import HostapdCLI + +# +# Separate client used to test DBus disconnects so we don't bring down the +# entire IWD python library +# +class AffinityClient(IWDDBusAbstract): + def __init__(self, device_path): + self._bus = dbus.bus.BusConnection(address_or_type=ctx.dbus_address) + self._station_prop_if = dbus.Interface( + self._bus.get_object(iwd.IWD_SERVICE, device_path), + iwd.DBUS_PROPERTIES) + + def set(self, values): + self._station_prop_if.Set(iwd.IWD_STATION_INTERFACE, 'Affinities', dbus.Array([dbus.ObjectPath(v) for v in values], signature="o")) + + def close(self): + self._bus.close() + +class Test(unittest.TestCase): + def connect(self, device, hapd): + ordered_network = device.get_ordered_network('TestFT', full_scan=True) + + self.assertEqual(ordered_network.type, NetworkType.psk) + + condition = 'not obj.connected' + self.wd.wait_for_object_condition(ordered_network.network_object, condition) + + device.connect_bssid(hapd.bssid) + + condition = 'obj.state == DeviceState.connected' + self.wd.wait_for_object_condition(device, condition) + + def test_set_affinity(self): + device = self.wd.list_devices(1)[0] + + self.connect(device, self.bss_hostapd[0]) + + print(device.connected_bss) + + device.affinities = [device.connected_bss] + + # IWD should not attempt to roam + with self.assertRaises(TimeoutError): + device.wait_for_event("roam-scan-triggered") + + device.affinities = [] + device.wait_for_event("roam-scan-triggered") + + def test_roam_below_critical(self): + device = self.wd.list_devices(1)[0] + + self.connect(device, self.bss_hostapd[0]) + + device.affinities = [device.connected_bss] + + # IWD should not attempt to roam + with self.assertRaises(TimeoutError): + device.wait_for_event("roam-scan-triggered") + + # Lower signal past critical level + self.bss0_rule.signal = -9000 + + device.wait_for_event("roam-scan-triggered") + + def test_error_conditions(self): + device = self.wd.list_devices(1)[0] + + # Calling set while disconnected should fail + with self.assertRaises(iwd.NotConnectedEx): + device.affinities = ["/some/path"] + + self.connect(device, self.bss_hostapd[0]) + + device.affinities = [device.connected_bss] + + # An invalid path should fail + with self.assertRaises(iwd.InvalidArgumentsEx): + device.affinities = [device.connected_bss, "/an/invalid/path"] + + def test_affinity_client_disconnect(self): + device = self.wd.list_devices(1)[0] + + client = AffinityClient(device.device_path) + + self.connect(device, self.bss_hostapd[0]) + + client.set([device.connected_bss]) + + with self.assertRaises(TimeoutError): + device.wait_for_event("roam-scan-triggered") + + client._bus.close() + + device.wait_for_event("roam-scan-triggered") + + def test_affinity_client_reconnect_during_roam(self): + device = self.wd.list_devices(1)[0] + + client = AffinityClient(device.device_path) + + self.connect(device, self.bss_hostapd[0]) + + client.set([device.connected_bss]) + + # Lower signal past critical level + self.bss0_rule.signal = -9000 + + device.wait_for_event("roam-scan-triggered") + + client.close() + del client + client = AffinityClient(device.device_path) + # setting here should get cleared after connecting + client.set([device.connected_bss]) + + device.wait_for_event("ft-authenticating") + device.wait_for_event("associating") + device.wait_for_event("connected") + + # Affinity should be reset, and IWD should be trying to roam + device.wait_for_event("roam-scan-triggered") + + def test_cleanup_with_connected_client(self): + device = self.wd.list_devices(1)[0] + + client = AffinityClient(device.device_path) + + self.connect(device, self.bss_hostapd[0]) + + client.set([device.connected_bss]) + self.wd.stop() + + def test_affinity_directed_roaming(self): + device = self.wd.list_devices(1)[0] + network = device.get_ordered_network("TestFT").network_object + + self.bss0_rule.signal = -7500 + self.bss1_rule.signal = -7500 + + self.connect(device, self.bss_hostapd[0]) + + # Don't set the affinity on the current BSS, but on the other + affinities = [path for path in network.extended_service_set if path != device.connected_bss] + + device.affinities = affinities + + # We should roam to the other BSS. + device.wait_for_event("ft-authenticating") + device.wait_for_event("associating") + device.wait_for_event("connected") + + # The affinity should still be set on this new BSS, causing the roam + # threshold to drop. We should not roam in this case. + with self.assertRaises(TimeoutError): + device.wait_for_event("roam-scan-triggered") + + # Now set the affinity back to the prior BSS, which should adjust the + # ranking such that we roam back + device.affinities = [device.connected_bss] + + device.wait_for_event("ft-authenticating") + device.wait_for_event("associating") + device.wait_for_event("connected") + + + 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') + + self.wd.stop() + self.wd = None + + def setUp(self): + self.bss0_rule.signal = -8000 + self.bss1_rule.signal = -8000 + + self.wd = IWD(True) + + @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') ] + + rad0 = hwsim.get_radio('rad0') + rad1 = hwsim.get_radio('rad1') + + cls.bss0_rule = hwsim.rules.create() + cls.bss0_rule.source = rad0.addresses[0] + cls.bss0_rule.bidirectional = True + cls.bss0_rule.signal = -8000 + cls.bss0_rule.enabled = True + + cls.bss1_rule = hwsim.rules.create() + cls.bss1_rule.source = rad1.addresses[0] + cls.bss1_rule.bidirectional = True + cls.bss1_rule.signal = -8000 + cls.bss1_rule.enabled = True + + 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.bss0_rule.remove() + cls.bss1_rule.remove() + +if __name__ == '__main__': + unittest.main(exit=True)