From patchwork Mon Aug 19 17:51:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13768756 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.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 9561916132E for ; Mon, 19 Aug 2024 17:52:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089923; cv=none; b=Q2vkIsAJ/fL6GFvXFchVcL9lpl4qAOXnCZjRYDoXguZIoRKWT4SzlIV038LAWmDQCnVPJogAI41vkKIHtWneWEucQCY1ADZs4pryyn/sIaHX8MNKrwTn2otM7XVxCRmzitSK00+tDMKO77kJmhxQUv0RbW0aAJLO7D4GTrm7TCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089923; c=relaxed/simple; bh=Z6IkhHPQnWeBp9c3xiuNWrGHPS/gLeJBla5KA88xJ5I=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=duwKKfG/Xm/+OM3ZRZRsF7NiLdmQuCxyhgN4TSqVJFop8pZ1Ye4lSBygWGDmmChTfBlVQPw3IxVe03epcGm3ULIY1nIudyxKisv9oKRfdhGl5vTb7cdWD4ZFTpiAt2KO/CTmgy9Z+W88cdVN8cTo9pfreHgld1FqGZij315JpyY= 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=g54Rd0xm; arc=none smtp.client-ip=209.85.161.45 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="g54Rd0xm" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-5daa4f8f1c4so1860936eaf.2 for ; Mon, 19 Aug 2024 10:52:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724089920; x=1724694720; 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=qXLmf3Gv32nod+sT07WCwPlTlNJqI38EpO2w78hZtGo=; b=g54Rd0xmRO+/6GL/BvmM5iRM9jKvFv9KW+3Diw7fVnVDZorTTr1zu12seVjzdVW39H 1eZ1/F9F6v3klQwmnblyGkDd3ufpgfL6ji+7GahlFWYf7vRxlTaF3vpJMWbYM1RMbM78 DAYZG7amDTPWHbwrmoH5aO5o6vBrbGls+N82B/88DIQJ2dHZjuXdyljDjjEHypqJimNV Wu/vAgU4/V+fXukgUaiunqqjgiW7IFf72YI4SqrcyEYXiAKQWbfoQ9eUyP4A5h/PjlQ1 K87QHBl0+eAZTK7TJFITcEhZc8GOA958p2nJzWn9yjFcWwX/bp4WEaCKYS8Y3i5gFfLd Wf2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724089920; x=1724694720; 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=qXLmf3Gv32nod+sT07WCwPlTlNJqI38EpO2w78hZtGo=; b=TianMEwKQ3S8LrdVEBdLH+4HbwUwZeRuGG6qyPJZDz8MReAZjjt1w0IhUHBP+mZXND 0XsalBNXZjA+VS7UEUzfeI321ueU2E2O86XUP0MUQeFfrnqfzSe5Lypzmrh2hIy79z1K xNIXNBTC6Bq5+onPdkhAKv5ez1aNn3Ae/g2e+XrTvgAXgB1+GOWyUcgtG9HVl6REoL7X +4xi8olMgXyMPgWyyzzUQZK2Wlw9RN6WlJfd9AAdx1eAF+04gUHURpi4y551SpkglQpl 5OOL6HDDXl1HBWv4fci4mbw0G5zJ9Gu0EVVkgeWqZxu8tQnOyilydvdotkmEFEIeUn3T cnaw== X-Gm-Message-State: AOJu0YyLhY4CCam8GOGMSa59xu/UDPixyvbYMQR51EDzd1HG9TlSwD4e 4taAmLSVHIR+gew6nBMFfQM+JJzTnYC/mng0Sj3ej+euxlc+KzQ1XRhQMA== X-Google-Smtp-Source: AGHT+IHyna3QlJkj7jfNzL3jgTtkVcMw1E1ygaDfGOmWGejhN5hZLhwGu3oLiQ5gIUvLrd/vOxtowQ== X-Received: by 2002:a05:6358:7594:b0:1a5:4b74:2214 with SMTP id e5c5f4694b2df-1b39312b07emr1682178155d.3.1724089920286; Mon, 19 Aug 2024 10:52:00 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4ff0e5a1csm451854685a.74.2024.08.19.10.51.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 10:51:59 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 1/8] doc: Document station Affinities property Date: Mon, 19 Aug 2024 10:51:44 -0700 Message-Id: <20240819175151.1310546-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. 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 | 17 +++++++++++++++++ src/iwd.config.rst | 16 ++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/doc/station-api.txt b/doc/station-api.txt index 84f1b7bf..0bd4a352 100644 --- a/doc/station-api.txt +++ b/doc/station-api.txt @@ -170,6 +170,23 @@ Properties string State [readonly] BSS the device is currently connected to or to which a connection is in progress. + ao Affinities [optional] [experimental] + + Array of net.connman.iwd.BasicServiceSet object paths + that will be treated with higher affinity compared to + other BSS's. Currently the only allowed value to be + set in this array is the path to the currently connected + BasicServiceSet object, i.e. + Station.ConnectedAccessPoint. + + Setting the affinity will lower the roaming threshold, + effectively locking IWD to the current BSS unless the + RSSI drops below the critical threshold set by + [General].CriticalRoamThreshold{_5GHz} at which point + IWD will proceed with normal roaming behavior. + + This property is cleared on roams/disconnections. + SignalLevelAgent hierarchy ========================== diff --git a/src/iwd.config.rst b/src/iwd.config.rst index d9c94e01..2d1f6dcd 100644 --- a/src/iwd.config.rst +++ b/src/iwd.config.rst @@ -130,6 +130,22 @@ 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. 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. + + + * - 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 Mon Aug 19 17:51:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13768757 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.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 1459B186E2A for ; Mon, 19 Aug 2024 17:52:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089924; cv=none; b=LxKjsXYN84MERRXggHJkd8Pgt7v+xpqN2PQGn+U9TZ+WcyxkoNzqcs3MsosdslREsiaYimYUqJESggOLEctNWW+ctrGZKLgWZh1qhKoWjzAUhPZlPkCrxfDt6mRqwp2j76eUkTKEgO+nQ+sP8qukqnG/BUL9fTNcB2Z9MO55bu0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089924; c=relaxed/simple; bh=3ACyH0wBcHI5aXAjWAcnc1ZlymMSvIai99xD4di9yuI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=J1YUdoqi/dg8jsYWNjSBwPTyhDjGlvLSpFYZ8jTfbvr2KByAm64JPjB2+wDIrT/PtilnqCjBjY67aavjuaNJvFQX7d1WYB6EOq/9NAmjGC8dcYqXVouMJozq+s52b2NH1eyhaK6sP7xulH7+aLY6DtvJLwH2k7uGb48ACaHm9NA= 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=SZxBP3Up; arc=none smtp.client-ip=209.85.222.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="SZxBP3Up" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-7a1d7bc07b7so319906685a.0 for ; Mon, 19 Aug 2024 10:52:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724089922; x=1724694722; 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=SZxBP3UpRhLYy45U1KZKGj8oQAzdkALf3t+wJ7U/gTerFeFTkh9N0R/5FyHl+uM6Wu EEClRWr40c4mY6R4SvCZQnetynEsCpfpG8OVADkhaF3mwIduIod0K63aU4csnu8PmdpO pYEY/zhhCFL1Ws4m0hrbksPe2lE/AEy5TpWwlusJM27ZsH5m/yMLBAfyW7ETY8LKhZJb HH+cyIoeohj5Q7NzPWBe9NyzUuprV8E1osH+PJhc1KOvmSrlND1T7a9rOdaYjEAp6FRR 6HXFfPd6QahoibHdDzP8NwkHw7yqL6npebmbIPXTNH3A8yzaJvIeQwEjpmWK2cRAwhqR M6HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724089922; x=1724694722; 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=mD2nC/9W8FHulvzOPbm6D8f/MjnPQgqFbmNFipy9LbLVKuYPp9kPXP+PzavkAk1bCe T4eFEqM1P71YXX4Dok2M2zDkLdBjVS2okL9ZgjyJWiAi+yb47F0kjR3nfSW9JDt8jiuA mr5Z6Tz8cASMySN6XVFOj7gtR3wrT+jfilHQZ3Yn9okIgSOLAdI8xA6wDkMpMLyR2z1Z iu1biWQl8kazHxxPl5s8JBicMzd16yAnA5L8LA5iQtk0jAG0WGEw10TO1QIshakk0emz mshP2GMvQg6Rt4JYoo2+ShmY8RbKcmkoS2t5nw//wr6pKF4FcNtZM0WwCCYBCm2od+J9 us2g== X-Gm-Message-State: AOJu0YxkgAmLlGAwA2l47EcN/Vb72EiorZdVREL1h9H2s0R8i3T0KKgV cgsBKrFBDBdMGrbK2cOOASgfdRD524ObpnYxf1/4LwCmvJXjpCPKeLgqcQ== X-Google-Smtp-Source: AGHT+IHb6kP5wr4lTBk/E3/j1KQalFpGLWGxF7dNAoBGCIQycyXcOUbzbr1scR9kVlNBm91Y8BffsQ== X-Received: by 2002:a05:620a:438e:b0:7a6:684f:c07e with SMTP id af79cd13be357-7a6684fd42amr24243385a.19.1724089921730; Mon, 19 Aug 2024 10:52:01 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4ff0e5a1csm451854685a.74.2024.08.19.10.52.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 10:52:01 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 2/8] netdev: store signal threshold in netdev object, not globally Date: Mon, 19 Aug 2024 10:51:45 -0700 Message-Id: <20240819175151.1310546-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819175151.1310546-1-prestwoj@gmail.com> References: <20240819175151.1310546-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 Mon Aug 19 17:51:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13768758 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.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 65AE316132E for ; Mon, 19 Aug 2024 17:52:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089925; cv=none; b=ZvEvR3kYI+DzOmZMhPD+NKTB6TalNfAVszLXD65wPvqEAQhtyt43YWBaPjHhdfkOfDKKCcTCFx53z/wPGrvZdcBrO2+sG3Viut7qRw0EEu0Ie1flJRCxm7URVWgfN90WE/bmmTesG8duD1LTa0bBD1jlBHHMPxSMJ9308jTvZCY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089925; c=relaxed/simple; bh=dth8Om/dpd2WPGLKj86XfvoQcZ106g4uJ095+68o3+k=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kJJoBb+1BMnIj5WW8d2evECnPoDgPxPLSRDimZGy+WsGap84PZ/NfBJ97J4X98V9gPHJvPid4xOT/SD8ne1vp9341kYyW1qWqY3/eWpywJgyhWJ+297KyRyUz9sP+1zNU4l2baRpyNVGPqtMRwYfVw8Pfmnh69PQC/d6/OuU7Ns= 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=IYzJPJIe; arc=none smtp.client-ip=209.85.222.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="IYzJPJIe" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7a1d7bc07b7so319907885a.0 for ; Mon, 19 Aug 2024 10:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724089923; x=1724694723; 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=IYzJPJIekEw0li5fFyU6i2swQQ5OnmqjWswjO7egs8ITyHtOSrxaCR1xyfBC51O6zp Mzw8qSNKr92VBF/zih5zkRvstuBdtHu0Ecv4x9sWLUyvqJ9b/AnXVs9MNX8X4QKnLHnY aLoF5mpuX2raJ0+Xjq7mMZS0lXgmgtWkNSozpi15eR/mrn77bPSn5gbQ//hn+60sd6eD 9kVXYVQkSziAREIckTdfcg4XC1Buhywj7NFl0Vt69KWE64YcScQ3FN56XHv0i1+tRHdR HPmreksG8aKJ0/N5VwZM0ibewDGzO0ro9IY2xYKAM90ULjP1L6t7/7PIJekFLrCk3Aq3 mifw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724089923; x=1724694723; 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=uxkN4ymEJoUIlyOofbn1FIGshrnHf4e4KuKOOpliZ3CyDNBfi6ZZihaxX2J+3P0S/u iYOLR/0We8o2/qSblkgQbgmPV0a6sEoAYM1lGIQUC63CzOQxkhnrZAelIUQVvYeQDaTq aWS+rX15Drb0D0dqK7HTW0JKOKRUi1C5RQPhdwMhaEkfbG8Nmm4ONHyUAwlBq8IPF9qp 0uxvSI9fCNnwZQbnBGuOYZ2Gk9W0EGJYU7pm3azRwetIivkTlvS4nY3CCAOK+Kut64q+ htxXTr/hKejpDUttLxQkvjppjYU1EE3CUrINl5oTcnM/oiNZOQKWDLeHthi6rTsZD2lz /M0g== X-Gm-Message-State: AOJu0YzPuEzBlJ43QmM9TrQWpj3SE4oouFGbea5vCs7x0kKwb4lc4hw8 AxGC6lXHX/en+iVNagxCZXPrTx3LCGhMNUuZx/WcgUV+MtyHqclWvG5f9Q== X-Google-Smtp-Source: AGHT+IG8MLySi9bri1pUiEQ3HJa8cmZNLhTvgexFnO++y1zKlmHa31bgSpdM0x7AjftLBH6WFzxysw== X-Received: by 2002:a05:620a:40c7:b0:79c:f55:4fd4 with SMTP id af79cd13be357-7a5069eb83amr1167561285a.59.1724089922822; Mon, 19 Aug 2024 10:52:02 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4ff0e5a1csm451854685a.74.2024.08.19.10.52.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 10:52:02 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 3/8] netdev: add critical signal threshold level Date: Mon, 19 Aug 2024 10:51:46 -0700 Message-Id: <20240819175151.1310546-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819175151.1310546-1-prestwoj@gmail.com> References: <20240819175151.1310546-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 Mon Aug 19 17:51:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13768759 Received: from mail-ua1-f53.google.com (mail-ua1-f53.google.com [209.85.222.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6188D186E2A for ; Mon, 19 Aug 2024 17:52:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089926; cv=none; b=cxyxMisz97+Lv0tcoJiJRCDUqFLAfN+d5+vJPoMlFF7mOIg40e37GcgV/LzK+eQYkL5gKatADL3tvcEQdinYumNdWMTnHxSQna5WNsMkCtaD0mOV/rndmZaQ7FMlFfHXCT+ZceRnqEnlk85x2UD4inPsEjq2leduBF9mG5EFX4A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089926; c=relaxed/simple; bh=00E/Q41Zd2TOJrvpL/uo48OfjqhxcO7Lhb51yFY6IyM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Vqh23j4NiASbIKCoir+C9eETzUBlzU0Al1+HylfThk19m3aCYwtXs85qIJoYbc/Uj4BGdgyQ2/fdUMSSBhxubmn6/OYiBRlrX0mKSWlo52Mz5zN6Lc3ej16CSapdHiltlHSF9C6y+OdEjf68k3746L3HlnWBD/b0u77UzegZtbE= 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=LfYA0Vr0; arc=none smtp.client-ip=209.85.222.53 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="LfYA0Vr0" Received: by mail-ua1-f53.google.com with SMTP id a1e0cc1a2514c-842fe6f6c04so1342777241.2 for ; Mon, 19 Aug 2024 10:52:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724089924; x=1724694724; 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=DsPBgH5j1k8yNYZmLRoPq0A2N0INvrJgLlqXadmlZh4=; b=LfYA0Vr0UiQtAofwdsbXoNMUh7IFPVDkxO1U6Rz/4ZnHJIS3lOwSjKi6OcPI0xQ/7R SVJqMLgU2VNvHHfcoWMhtD5P0tlxuhvKRRS3m42ueuhxQyE+qzC/HyjbvTimm4pQOlA2 pX86nURNS2F9ytvcAZOtxiXyUEuZRO4saX6TBEgLWXgYkMCkp2WX/9WBkreglALGhOoa BMExwck+4Qo7fk/iv6csRuGbPh55wzmrHIOKtSlzi6QIYHecW3U14bzBSUHjqXOBax81 wq33Q1/KKkqson3Md02Q3eOf74/bq5+iN1ciVcTCR4CVAQsxU4fQdXEXgZIPkfJBGFJ7 Qrew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724089924; x=1724694724; 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=DsPBgH5j1k8yNYZmLRoPq0A2N0INvrJgLlqXadmlZh4=; b=v3byTjj1CwMBqwJoioeGMFTZeuoIc1lXpmcHz9c4d+vy1wT+7v2US5zvl0KqMxStBO bihrurDsCOLMOsp2V2K+X/Qx58Mn4OLN1V1gLpu0RjnwsgZ3zYCS9dDSv49HhKpGvd9B aa/z9CmhTcrxEr3UB04HQ+BHuKcRenhRdq+QiZfKC1Svja3BtjBnXQt7v/eXG8rGboDO P7RT5ZzVtj309GTb38DaO9KUsE3j9s1bCMNejetvHpDb9A5uihGvONf1IbpZhIdgeFLC 6EZ3WF4Gx4+D5fJmRwBqi1mw4tV+lX23mBwHXL0NrYUulTbY6+r323RCDc/LgA6lWwlW wLfA== X-Gm-Message-State: AOJu0Yy3vu0coQKWl+yzOnWcJUiwyfVdwd8Nz6JpBP1jtzMDUmew+PlA E+eTZBzuJQqJm/RoPmiKWOa8jNNCzO9rU77Y6zhIPUBz7vi+jSchRWj3sQ== X-Google-Smtp-Source: AGHT+IFVwCa/iqkMXjBb8Z6jJHKZkqeZxkpB6mpvvvx/Qv0VDOc7C6p4FWVadv0OFOsgxtqAQmTj4g== X-Received: by 2002:a05:6102:3906:b0:493:b965:7d03 with SMTP id ada2fe7eead31-497798f97e3mr13758109137.13.1724089924050; Mon, 19 Aug 2024 10:52:04 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4ff0e5a1csm451854685a.74.2024.08.19.10.52.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 10:52:03 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 4/8] station: emit property changed for ConnectedAccessPoint Date: Mon, 19 Aug 2024 10:51:47 -0700 Message-Id: <20240819175151.1310546-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819175151.1310546-1-prestwoj@gmail.com> References: <20240819175151.1310546-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 6a28254b..333b0fa1 100644 --- a/src/station.c +++ b/src/station.c @@ -1694,6 +1694,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"); @@ -1865,6 +1867,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 Mon Aug 19 17:51: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: 13768760 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (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 8AF1D16132E for ; Mon, 19 Aug 2024 17:52:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089928; cv=none; b=ZEuZvwC4Ke7JHtaxavWB7gl69P31QeR72H6a+dDOl26tsBqRSOoaQkBOXvNXAlj1UEb+QH0fNgBxsSMtEl8+DK+/3IMvoWpFLBPbgwgMYG7R2hi5dlx4HjaShTj0cQz8p1Vl37VC07FEMOJBC6ZUj4m/g2Ept8ynMsp3ZRwSLC0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089928; c=relaxed/simple; bh=Cdk+zmaL9pfqsn1FKIMizkcNDvfzCZ+TW+polvP0T1U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KF7RiG+Z2JnvxSHzRo3oR9Muh8D0cNXNznStN/vvUpwwc2En5a1FyUOkGfXx3xUmw7owfOQg1h2/o8Rkr8n93zoXMh+8kP87Z7NVhIgMVZk1KRDLCk97AR6VLHVQdHyTAYVty0OqOk97B9UK+J06hhB1BcklkYKo8C5fGQVE8iU= 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=lT8DG+xt; arc=none smtp.client-ip=209.85.222.177 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="lT8DG+xt" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7a1d6f4714bso456529985a.1 for ; Mon, 19 Aug 2024 10:52:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724089925; x=1724694725; 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=PgDUZtRcZALpBOQT0zUmihB2QjLTXjpOl88zRZafqUw=; b=lT8DG+xtEPHZdKCq0MbbS0OuEBVCQUXuoC42XSvWDvVAnn40bXIh13/VdK27W1jpIp 1lPFlHjI2Y4dnBrleOZCS+fRjLKOAg7UHm060eMZEZT1tvp+SSD/8+AFUVN8rT/PG/Wb 92xsKFc47AAWp8t8p6ihYoB+O+WinxmI0129agRhKbQaZ7HmFvwu9uK8h99PDWsxhi41 /42ThBH2gDmxOGSebIG/GoRBSijLdGLHmttQmyezjx+aBzsgU7WLNINBKHbBTTVjeexB 8n0FX26Ba+F6bootp0eKtNf9B0KEcfFvpQh4eInWVrm3xD7UEIWUlrXrOzA0CEvCmOe+ of/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724089925; x=1724694725; 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=PgDUZtRcZALpBOQT0zUmihB2QjLTXjpOl88zRZafqUw=; b=N+WvTAJYOPh9WkmGYEGGUehTXyxmeo/xl4Y7PArUejIvYYh3D64gJBiTYqxE45zw0u iAvY7UPeiqpp9kbLc0fo6TZZFISPrLE7eecatEIW0/IkJS0A37kHs2vfCKIGoKb+N1Go iCCpFAmQqeg6QbSnE34MRtS6/mUTILF4sWvlIsNWOLTQYMbuPhJAba4xfSDKUW9R4vKc cf+gwFI/r//oEFd7u6GE8qNCDRnTuJuxNEJ+wFGI47lLHSaWG7H9Z5N41Wgj+zXG70sB sLCUGDZ0N9BL7iHSfBLKLVsecVr72o3G+qctgx+nl7MxDxfZFZPDbIFfJGkcJoQb0j2D DB2A== X-Gm-Message-State: AOJu0YxCuJU9rpFs/ZJJu3QOu9BlSV3v1A894f51ckkTfMPmVn/re2iI 6nnjXpz1DTEXssYEKiUqqoyJBsS7t8pjEczpXNzkLaeB/0hGN+fnkxKefA== X-Google-Smtp-Source: AGHT+IG5X1qAp+sU8HcQb/kSEbprnktrFfu0qPVkBNX2Un0IGmsr1sfuDUEc+9qCdclisuRdoLfXKA== X-Received: by 2002:a05:620a:31a9:b0:7a4:dff8:35d5 with SMTP id af79cd13be357-7a667c537cdmr65356885a.33.1724089925131; Mon, 19 Aug 2024 10:52:05 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4ff0e5a1csm451854685a.74.2024.08.19.10.52.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 10:52:04 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 5/8] station: add Affinities DBus property Date: Mon, 19 Aug 2024 10:51:48 -0700 Message-Id: <20240819175151.1310546-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819175151.1310546-1-prestwoj@gmail.com> References: <20240819175151.1310546-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 the time being, the array is limited to only the connected BSS path, and any roams or disconnects will clear the array. The intended use case for this is if the device is stationary an external client could reduce the likelihood of roaming by setting the affinity to the current BSS. --- src/station.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) v2: * Limit Affinities to only the connected BSS * Change station->affinities to queue rather than char** diff --git a/src/station.c b/src/station.c index 333b0fa1..3b64cd75 100644 --- a/src/station.c +++ b/src/station.c @@ -128,6 +128,10 @@ struct station { uint64_t last_roam_scan; + struct l_queue *affinities; + unsigned int affinity_watch; + char *affinity_client; + bool preparing_roam : 1; bool roam_scan_full : 1; bool signal_low : 1; @@ -449,6 +453,14 @@ static const char *station_get_bss_path(struct station *station, return __network_path_append_bss(network_path, bss); } +static bool match_bss_path(const void *data, const void *user_data) +{ + const char *path1 = data; + const char *path2 = user_data; + + return !strcmp(path1, path2); +} + static bool station_unregister_bss(struct station *station, struct scan_bss *bss) { @@ -457,6 +469,8 @@ static bool station_unregister_bss(struct station *station, if (L_WARN_ON(!path)) return false; + l_queue_remove_if(station->affinities, match_bss_path, path); + return l_dbus_unregister_object(dbus_get_bus(), path); } @@ -1740,6 +1754,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: @@ -1747,6 +1768,12 @@ static void station_enter_state(struct station *station, case STATION_STATE_ROAMING: case STATION_STATE_FT_ROAMING: case STATION_STATE_FW_ROAMING: + if (station->affinity_watch) { + l_dbus_remove_watch(dbus_get_bus(), + station->affinity_watch); + station->affinity_watch = 0; + } + station_set_evict_nocarrier(station, false); break; } @@ -4520,6 +4547,118 @@ 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; + const struct l_queue_entry *e; + + if (!station->connected_network) + return false; + + l_dbus_message_builder_enter_array(builder, "o"); + + for (e = l_queue_get_entries(station->affinities); e; e = e->next) { + const char *path = e->data; + + l_dbus_message_builder_append_basic(builder, 'o', 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_queue_destroy(station->affinities, l_free); + station->affinities = NULL; + + l_dbus_property_changed(dbus_get_bus(), + netdev_get_path(station->netdev), + IWD_STATION_INTERFACE, "Affinities"); +} + +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; + struct l_queue *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_queue_new(); + + while (l_dbus_message_iter_next_entry(&array, &path)) { + struct scan_bss *bss = l_dbus_object_get_data(dbus_get_bus(), + path, + IWD_BSS_INTERFACE); + + /* + * TODO: For now only allow the affinities array to contain the + * connected BSS path. Any other values will be rejected. + * This could change in the future. + */ + if (bss != station->connected_bss) { + l_queue_destroy(new_affinities, l_free); + return dbus_error_invalid_args(message); + } + + l_queue_push_head(new_affinities, l_strdup(path)); + } + + l_queue_destroy(station->affinities, l_free); + 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; @@ -4842,6 +4981,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); } @@ -4878,6 +5020,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 Mon Aug 19 17:51: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: 13768761 Received: from mail-vs1-f47.google.com (mail-vs1-f47.google.com [209.85.217.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 85E5018787E for ; Mon, 19 Aug 2024 17:52:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089929; cv=none; b=OxVOCreO2EKbH8MU9l9ppIXClkpDJiyvPEfCWjV2gn3nSThhQyn9VNGzodpgLDikTmG+ZEwHHq6CfXT3vmqd464XGzulewzeqNxgIYNGGCg8Dky5DnxIDv2xAXpk7Dyq0NkVKcCquu59Yiu1N5GWta/Kcy91Gx8+Bf2ieZWpyCk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089929; c=relaxed/simple; bh=O2Tm/DmKVyNIBo1VCiKb2tFPdHzhCB6yuWw9ik1DHns=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MX7wvSJGupJtjwEOC6gMs/dI8MpTsKvf7nB/HiAdw+GgH6dIM/wkp0DZsJLJGPWzIQg4SjxOkDfPiXR2paNOUWoUYKIrZxqfyay/y8LFb22/8CEUKQMn48CJGItxzrdSUhJk3SpnZh8TdNeFo/SwcKKxIArSVnioeyWH+ZdcFfQ= 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=MHYsBIqv; arc=none smtp.client-ip=209.85.217.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="MHYsBIqv" Received: by mail-vs1-f47.google.com with SMTP id ada2fe7eead31-4928fa870a9so1342228137.2 for ; Mon, 19 Aug 2024 10:52:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724089926; x=1724694726; 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=/p0vLPm1eouQISn2iDnK/ypztLjVsmPD/wZd6WRG3ek=; b=MHYsBIqvyYWtNH3a5PFeBTyCSTpDLfmsr+xymY6a2NSpx+QF8CTrmn35i9Kz5P6cRs bRadSD0afMpW/PHEMNoqowKmMDIDJQ5Ypy6NPoEBn7GYJ0Fg4r3sQY8Wlk2U+J9Geu97 hd0JfRTatkyX8kmeo7pkcWxLu3FKcmbX9xUtsYY5AI90QkgWK4IBFhfle0aIDmsDbMrT R1Rsbn82eYXFFduvqwilVsTKHy0kupuuerEO51lsEwKdfm2JnMq3HUgZiIK4rH7aKOyH 7Zs0qbdu+0TEVMR/l2fj8ulrMWBwR8UvF1KAq3shuY4ynP5QPpvJehXQcFbmNwNy9PMR tAhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724089926; x=1724694726; 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=/p0vLPm1eouQISn2iDnK/ypztLjVsmPD/wZd6WRG3ek=; b=p4Kv6B2bYT5m1T/tndH2e8RcbvC1Iipama0woNFv3OD+crEJwQ0eCFv+D6BatKh9Td OnvpcBMfd4pdO3UBCaqlJAj00trPjUnsVHMYLWrHTk8jWo/o2Eb8U92pns8eYrVwpQbf /VCo91FlCh0YbpOvwj+xkMDlQbn3KfTAtrRzIGcA47iGyYhi8xF76p1UIoaVTqUzT6JE x6JVIba1tbKClNUh6OS8EnRsvJmmB5XnbL4bqTXREIU93eZOdbpAdHRLxfiWu+6dBSrl iedFASdzvtTUU0H2hAI0ZSkfLExKCagx0GE+u/HaSdVdnRppJlYn9jnL+n7gjmeLwEJJ 5Ahw== X-Gm-Message-State: AOJu0YwrN3EEjJEPWgIUHtBvDpq42O3+XImdL6TEbPLggqYeK1zf1vIi tL4FWSH65UXIkppaNK/Zzkp6VcZCWbAxTg42LC0Jn4LgvOBJGwrGygyzuA== X-Google-Smtp-Source: AGHT+IEMcHF4F7tL8tmBHNdINOgSp1TO2ABU5TRAAh54bys+18walgod9Jbk2pyMFZ0l/eD8w3W7qw== X-Received: by 2002:a05:6102:1626:b0:497:70db:ffc5 with SMTP id ada2fe7eead31-49779930599mr9712945137.8.1724089926221; Mon, 19 Aug 2024 10:52:06 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4ff0e5a1csm451854685a.74.2024.08.19.10.52.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 10:52:05 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 6/8] station: Use Affinities property to change roaming threshold Date: Mon, 19 Aug 2024 10:51:49 -0700 Message-Id: <20240819175151.1310546-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819175151.1310546-1-prestwoj@gmail.com> References: <20240819175151.1310546-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When the affinity is set to the current BSS lower the roaming threshold to loosly lock IWD to the current BSS. The lower threshold is automatically removed upon roaming/disconnection since the affinity array is also cleared out. --- src/station.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/station.c b/src/station.c index 3b64cd75..31faa5e8 100644 --- a/src/station.c +++ b/src/station.c @@ -4580,6 +4580,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) @@ -4609,6 +4612,7 @@ static struct l_dbus_message *station_property_set_affinities( const char *sender = l_dbus_message_get_sender(message); const char *path; struct l_queue *new_affinities; + bool lower_threshold = false; if (!station->connected_network) return dbus_error_not_connected(message); @@ -4645,6 +4649,8 @@ static struct l_dbus_message *station_property_set_affinities( return dbus_error_invalid_args(message); } + lower_threshold = true; + l_queue_push_head(new_affinities, l_strdup(path)); } @@ -4654,6 +4660,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 Mon Aug 19 17:51: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: 13768762 Received: from mail-oo1-f50.google.com (mail-oo1-f50.google.com [209.85.161.50]) (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 C02B416132E for ; Mon, 19 Aug 2024 17:52:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089930; cv=none; b=kw34Bf0v44X9uBMaD5C9bO7ArRnyax8x0mrFEdoPF4/O38HkMFVlTxX51dymHvkbuWyMgiuwhtWs8r7284NfCvMJhex5P212ZfqzrRwES3O0y4WwcgvWqkwpnEiLGy20f6DT1PoNg1yVXhZjbxaLFvTtc2q+Tl19WBzxuo+v/5M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089930; c=relaxed/simple; bh=1pYxZdt/cb6QaZROUOt/UXNKrd4LBk55ZWX1Jek2/YY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gLs3lUvZzj3Jp08+EyLkElwx8eLliM4yd89WYbnDPwhOsAvtebyqoNpnnHUTz3CXFyW4wyP65iAoR1Oygl2X/7Fhy6xp31gEfzGz2FpwQqB/TqUK3vGsBBtw/asae8Vdoya1XURueTY6+rZIB4uOTOc2yvidk6HtRVQifgpMUBA= 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=UIs2SNQb; arc=none smtp.client-ip=209.85.161.50 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="UIs2SNQb" Received: by mail-oo1-f50.google.com with SMTP id 006d021491bc7-5d82eb2c4feso3026752eaf.2 for ; Mon, 19 Aug 2024 10:52:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724089927; x=1724694727; 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=6IFPs/YJKFaYy3RoCHH1SN5YV4xFWkPxPc6QvHkhBzc=; b=UIs2SNQbR5ngGpyrDttLNIi88Gui37Fm0IMd1HL+7+wTXtWbaZlJS5XR+yS9LWbGeJ tZXTGDltvq6azPmS2r/rQAtju5Mv8vq2HjUEBJW6UHeLzjQlLCczxwD7cyJjaxR5iuuZ 5OeBD7ROKORdKftvVvtvmoHHIOjg20giKKuxpwdi0Ov05o75CbK1e0HUc/w/fj7WO0Id j80yAyOJqb7GNmyph2Oa+FwBzZXvIYotK4coeaoEiLvna52EwoUCt1JtW70q+209a6wI ZZgCi1edMjr31MP52+JMKeSyaZ00ER2EKOWeeVNq5ucXcWjKgP8BhWDxdAdjjT1xWgAB wPLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724089927; x=1724694727; 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=6IFPs/YJKFaYy3RoCHH1SN5YV4xFWkPxPc6QvHkhBzc=; b=vc/Famnu1IQ+EULox3JOGtvWtEStNO6BTZWpwuMHao89kopocMj/TEYqQeP3Z/cK9/ 7Ot/WlWh1tn8tIfW3v55g4fr8bw48mA4GwaxcG//dHmGsiL41Iz/LwIr/GDPllr0PaNJ 9//0f0vUP0vqyCFtis0vH1O1KNPYOLfV5VpoMmJ/HaGHPFK4PZ2pI8O2FAECQKcIZBrL ISmHrDl6hcx1FwMuq/3u/i64hOYbAIS2jM26xpBJvaGvB3PqXC0qpoS3qx2ykxMT1xHj ipggBiq7sEFcZ4VCxDbPcgMMJ9Bc12bPObcGRUZ3qQ+8yEavttYbbnbgfbKhQSLCSwRs UKHQ== X-Gm-Message-State: AOJu0Yz3PxMeUYM0GDH7Si2uteebT4THJoH6IEgzv+qlALpHo2jgwXJY bbVTCxfZr+vHx1M2jBVCQzVqh0aYPYkmUaaYqAEruwq0KW7MacZck2DVgA== X-Google-Smtp-Source: AGHT+IEt+YkZ+prg8ocwHalmf21Wx/6X559ZEQfXkSaPqBlF38hDD6B/ecZgTnGNtSKytB+6O3wMcQ== X-Received: by 2002:a05:6359:4c89:b0:1af:4626:7e42 with SMTP id e5c5f4694b2df-1b39330c7ecmr1398627655d.25.1724089927493; Mon, 19 Aug 2024 10:52:07 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4ff0e5a1csm451854685a.74.2024.08.19.10.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 10:52:07 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 7/8] auto-t: add affinities property for station, and extended_service_set Date: Mon, 19 Aug 2024 10:51:50 -0700 Message-Id: <20240819175151.1310546-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819175151.1310546-1-prestwoj@gmail.com> References: <20240819175151.1310546-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 | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py index 74bb25c0..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. From patchwork Mon Aug 19 17:51:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13768763 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.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 28F5C16132E for ; Mon, 19 Aug 2024 17:52:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089933; cv=none; b=f9jlwNtFCgLtwVCyQtMSgb9uWh3LzEISWXaiH+X6K8ydMCpqWiIg7Av1HRijqHQP6EIl66strFCarnBACA5cpL7d1VpB23v2hi/6drTak+Jgbn5esjWtUjHtWrQMITy8pWczI43kQVotUKti8hFj5k8tDBlT/ljQOQrKTjATWaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724089933; c=relaxed/simple; bh=VtfRUqAptUpigOzeZjNHoVL4/+kBM519529S4p/CSgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PUavRVHvt39QQfnP8crIUFP4OAG6WDVknEm2+8XOaVIspwZG4WYt0FKgVZwZrmGHgEiQo10k1tu3/CceHM6SHY8o37c6aJi+7nvumqewfqJ3jH0kp0EWsc+4c2HWeLP0gjGmGip92bEXv2HlXVAvUZXZ9vbD59RrCjQqJIujo0I= 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=m0wNboPt; arc=none smtp.client-ip=209.85.222.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="m0wNboPt" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-7a1d066a5daso312712885a.3 for ; Mon, 19 Aug 2024 10:52:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724089929; x=1724694729; 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=xVb/OjA1ZX9/HSanVUxoiwPsw4Gq2DchDkWB3iptSm4=; b=m0wNboPtIzKPvToY7ZfL9luGkL4HlfZtEx4zESOn1rQAdN7Cut8a7sCiohFYaywbWZ GAXcE0IXeRRA57VPxtVYYXZ90iN9cnFz0rJHImndNMpslReLWxEkZOlLoBomXRflIZ2b eM7G5CrvvuUS4eOV6PcGY29wPByf1CaArPuaNInAj/5Pf9PXbd4XD13HmhWGl+2K+FNK nvvqs4xUSzUzWrEpN/SaHeWPliJMNPgiqtBTAAAuevY8TikHXw3NqtRi76TSfEizgTFF TES+wD2B9/wBTUv7Nb6P4EasgB0tltpQLFPQvuCW21l4rH0EYXi2yzklXO+vpV5iujPI sXdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724089929; x=1724694729; 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=xVb/OjA1ZX9/HSanVUxoiwPsw4Gq2DchDkWB3iptSm4=; b=ihN3O89XpMaeEV8Ucyap3hgZqPBENmADkKerYPV41XNX9YshOiVKM4X8NOGkos4g7R YKOazep2wHXlgwNDTQdiX9oQL/7k4x7wXb3CKNb7aASkwWZcAunQvomIKv9Ys2YeHzGb GiYgWP4Nj+Cw1gawwXQAPSEOskOp2391oD2++I+2DdVPOLrG12EFkPYzfKHuF9MH6JJo Tfp608rROzw1jL9xkUE5dzjHT/pLR8Vacxjr0MnjuDSV2H784oQpJjcdYE8nAfTaM+7k qD2T7sXMACeDu6a36yO4LnGGAZlX56n1aq6lbwgEj7q/Gsrv14zjieoHLuPSFgyw6XD3 RTBw== X-Gm-Message-State: AOJu0YxuLOpEGPs/ZFmpL7f3lQ6ahbTVoaJP/KTItIRglOlIM3AX04WU z+EbepUYUrd3ui0ZOIMutqOKjNH8K3aWUPDzJdwCJvva6b6F55Vlcfh0dg== X-Google-Smtp-Source: AGHT+IG3R9jeRVrwfTyDprz4wxmnnZPHiO2KwmlWZgzSP04TJp6aen2oEQIC1OoMvmotZpHUKsFmGQ== X-Received: by 2002:a05:620a:2727:b0:7a6:56f7:7b2a with SMTP id af79cd13be357-7a656f77d33mr700461885a.26.1724089928636; Mon, 19 Aug 2024 10:52:08 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a4ff0e5a1csm451854685a.74.2024.08.19.10.52.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2024 10:52:08 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v2 8/8] auto-t: add tests for Affinities behavior Date: Mon, 19 Aug 2024 10:51:51 -0700 Message-Id: <20240819175151.1310546-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240819175151.1310546-1-prestwoj@gmail.com> References: <20240819175151.1310546-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 | 216 ++++++++++++++++++++ 6 files changed, 313 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..5754aee0 --- /dev/null +++ b/autotests/testAffinity/test_set_affinity.py @@ -0,0 +1,216 @@ +#! /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_removed_after_roam(self): + device = self.wd.list_devices(1)[0] + + self.connect(device, self.bss_hostapd[0]) + + device.affinities = [device.connected_bss] + + # Lower signal past critical level + self.bss0_rule.signal = -9000 + + device.wait_for_event("roam-scan-triggered") + + device.wait_for_event("ft-authenticating") + device.wait_for_event("associating") + device.wait_for_event("connected") + + self.assertEqual(device.affinities, []) + + 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)