From patchwork Mon Jul 29 12:44:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13744855 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F82D1487C1 for ; Mon, 29 Jul 2024 12:44:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257061; cv=none; b=urXvzaEk/68elFU8DBCOVaJQ91xY1UgG6HBmTIshtcPHm1W9EQEHfQl9SynfUcBeTjBfLk6GCwmaUmhpxxWPN1+BSSFv8dOnDgAa72n+YUgyjDX6TUfe10Yh0pu2pqGRQxxPcSeCBJgXi9XDcWck9JK30mpJ03y6CYJE4Hx2M9c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257061; c=relaxed/simple; bh=G/Y/HSk96c9KUFcvJUJi4rWgvQ1ijUr/fOHBtIyaX9M=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=JOkUdr8GKHl3sWYYD8fyU+yhdiURNiwpUR2JRQfn/JtQbSlmVZtVQxJ8mebwosml0m5jTBo2jekOzzunrgXxyYIFa4k4OZUEKaxl5QFbjqyVRHwTXVRNvy5Eg6jnLnUHBOM1Vh2vIheysS3mGgIswnPZaLRPPQc9S8Rmawa+SvA= 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=aEqJK4TW; arc=none smtp.client-ip=209.85.219.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="aEqJK4TW" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6b5dfcfb165so18829076d6.0 for ; Mon, 29 Jul 2024 05:44:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722257059; x=1722861859; 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=cpwtonmqs8Ssr/b2jzuLXc+ajd8QJ2pra28el9tmM2g=; b=aEqJK4TWnUFuA2Bhmf/2ZtNlVwCdOLWLlfYQfPUrwTlUPlAJ5t967RiD6zsJO+8V61 Id0ppqHzKb6D7KJ2IRamJmiy2iWh0dfJ9LxKZ8J77wum9S/UsgkbGk7HcBLOoQfTG9yM yB3dm5EdB7WR27JJpUqIxGDUhRJBORBhTP8qNkTBfVpAv67iXv6W5bJY1sJk1CYfIDRy g+FcExJCZMjuE/Q1sP5GjZauDvdKGtAPEF/SOu0OkeuULDDWLDKq/DVWBvT7DQVgCBvO MEylSxwP8qNniZjhg/JuEBx2IfPcMEOYxrhedfV36qpKfJY7uyEVzd0XJS9v58bV4g8S m9Dw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722257059; x=1722861859; 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=cpwtonmqs8Ssr/b2jzuLXc+ajd8QJ2pra28el9tmM2g=; b=Zk1pu6J6BCNrH8mC7KiXg8bU2J119Cx78cnKWcTZt0s5wYwT1lYCDlcol6RGSJVvmQ KNXGxIiJrsgPPkA+wCW7roLWLMV52qw3EQ6qf01u/q+iPYepr21GJaYRpjDpRFX9/Hj5 PQr4Lm/pc83kk5498OwfyR1PdJU51dW4cACttpTgptRQfSz/DXSZY1+KsdHH//P/U3TM tCnOhb47nQGAPRw+yL0O08E/KdC+jRBMZ4O/6Es03gSGQpjIG937P/wi0wl+L42sc9Bv wQ83QJkz9ZQNp4vxQtm2rKENuCm96+LEgehqIppoYpRIAj6DbDIgE7e+fX3lQF86RPV3 VZ9g== X-Gm-Message-State: AOJu0YwH/PkdmpzBOulyxAjaPs6hzkAqdCnrWkf1imHoT9iDXa8FsTQ4 ESuB8WFEYO7mbDLuZdJqxOOIz3gz8B0wZagEqTKjMQhWkKLkeaDPkiMtCw== X-Google-Smtp-Source: AGHT+IGwi6PLyyX+M/IczzB9+eOq+gUgX1ws0JgJbJgMbbER1UayBKuUKz0SUx4ncI+Z5DcqDJk98A== X-Received: by 2002:a05:6214:29e8:b0:6b5:e51d:441d with SMTP id 6a1803df08f44-6bb55b154f5mr92553676d6.41.1722257058766; Mon, 29 Jul 2024 05:44:18 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8d84edsm51171266d6.14.2024.07.29.05.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:44:18 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/6] doc: Document new BSS affinity method calls Date: Mon, 29 Jul 2024 05:44:05 -0700 Message-Id: <20240729124410.1763549-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 methods that expose a bit more control to how IWD roams. The new methods are: SetConnectedBssAffinity() UnsetConnectedBssAffinity() 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 after SetConnectedBssAffinity() is called. If the RSSI continues to drop below this level IWD would (attempt to) roam. --- doc/station-api.txt | 22 ++++++++++++++++++++++ src/iwd.config.rst | 8 ++++++++ 2 files changed, 30 insertions(+) diff --git a/doc/station-api.txt b/doc/station-api.txt index 05dd137e..3dc2376b 100644 --- a/doc/station-api.txt +++ b/doc/station-api.txt @@ -135,6 +135,28 @@ Methods void Scan() Possible Errors: [service].Error.InvalidArguments [service].Error.NotFound + void SetConnectedBssAffinity() + + Sets a high affinity/preference to the currently + connected BSS. Specifically, calling this will reduce + the roam threshold down to a critical level set by + [General].CriticalRoamThreshold. This effectively locks + the client onto the current BSS unless the signal + quality becomes extremely poor. + + If IWD roams or disconnects the affinity will be reset. + + Possible Errors: net.connman.iwd.NotConnected + + void UnsetConnectedBssAffinity() + + Unset a prior call to SetConnectedBssAffinity(). This + moves the roaming threshold back up to the default level + (RoamThreshold/RoamThreshold5GHz). + + Possible Errors: net.connman.iwd.NotConnected + net.connman.iwd.NotConfigured + Properties string State [readonly] Reflects the general network connection state. One of: diff --git a/src/iwd.config.rst b/src/iwd.config.rst index d9c94e01..31f43bc6 100644 --- a/src/iwd.config.rst +++ b/src/iwd.config.rst @@ -130,6 +130,14 @@ 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: **-82** + + The threshold at which IWD will roam regardless of the affinity set to + the current BSS. This is only used if the SetConnectedBssAffinity() DBus + method is called, at which point this value becomes the new roam + threshold. + * - RoamRetryInterval - Value: unsigned int value in seconds (default: **60**) From patchwork Mon Jul 29 12:44:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13744856 Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 497BB1487EF for ; Mon, 29 Jul 2024 12:44:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257062; cv=none; b=nOJebibsj8Hao3MtTtXYdqIS3rd+j04w/iHrD5aBpQSiy1zYmh/p3ed2F0mw1aHi17Zw57OKGFiZg1HHKi0xNGoC3pJ33InQ+CcHE41ZGuqO9dnI6GjjgdZF6sUZtdPGNB7nFyChLFr9hyz9JKcWwSmaWUaGjeBCKvcgAunuV3k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257062; c=relaxed/simple; bh=9eJ8l+OYeZPhw+5/ItVYu1yZlS49AMV+Qiay9rtAZ0g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=iHQE5Np02cueSHt/tfPeoG2zs9E5DnbkXiPZJPnQr/Ly75nWVRxHalV4Lo1R20a0bQ3wFJMwbddEaMqpdxxB9354Nmdv1EG9nsDFYhLfSu+IxVfgr+mv8/p5NSYpe7tbbVt+5PVtTEUOIHfO4Z9GBCnqpYEX0SEatyatti/hb30= 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=TQXi0v/V; arc=none smtp.client-ip=209.85.219.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="TQXi0v/V" Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6b795574f9dso17534586d6.0 for ; Mon, 29 Jul 2024 05:44:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722257060; x=1722861860; 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=+XqzRrcsOWy6k4wsW6OBmYdNAeAZ/1tJMTg0PuJyMZk=; b=TQXi0v/V1WqRXbvR6a2M7QgerwGryeScyRHw8B6n+6K8y7hd4N1sjFOhywQouXWarp Pma6Dy4BrqMBuZ9APQe0wURfRA+t7ioJLxnnmy424ribgR18akKckBB8wrfNO9S1zsv7 ms8YrqBuVdJMzdvu9SbIftqGQ9UMDphQb+fqmRENx7tLL/yAZhHQta8tau3mrCU7bSHq EMX4jMmF7F3qtBhiFs8zUfOS1ZosZzarBjUo/SyK40d0yN5fjNxFFoJUhwRJqnucvylj HJEfXoa4SkN3zrYItmxgSQneeyUxGaZ6mAOnlOdOPKeJBYzXcLSiiYA860Y0zSgVvLNj syeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722257060; x=1722861860; 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=+XqzRrcsOWy6k4wsW6OBmYdNAeAZ/1tJMTg0PuJyMZk=; b=YGuk5jNpIF2OA4Ha6JDk8oC8VQa6lWxyr7katWoJfasKKXJgdd57zIcTm4faPTWtmd sqvJczRDR+RdlAEgi52eHWniJn7sf4nHJd/DgnlpfegomIu2DGm4v6CZRMu/cFwkC8OZ +PSsGmGxE2UByJeWC98Wxwj4BMIVkbBZJU5c53XqucyZo1tdw/DdxudQPSCUrjq7LU7s wO3gXGZaFSlVyOc5f8beRGqQaBfdCPr7BOOewTOa3qg07D4ux+QXeapDiheO8TTQT2G4 1CrtKpplKe6H410rnQVXyRXhWNaQ3UiSal0PkMetQcOFgITk0s9I4N8xJyXXNisWq0n3 JIlQ== X-Gm-Message-State: AOJu0Yymj2b8pZ5F0bq9wPFTaeHr0di76Y1XUJKzcC5VvQLJr8PBDghZ w3ELBYlhPYuw6phC4F1mPH2DkGdKzXpeDOzFJo84hGTXljso02+9uDBtxg== X-Google-Smtp-Source: AGHT+IHFD4FaqMGv0bdiqNIrOEdrEIxHb8TdAFsmbunsNPWeXrqnf9wbwI+nxoFXoxX4JPs6cW+khg== X-Received: by 2002:a05:6214:4105:b0:6b5:e5fc:b8dc with SMTP id 6a1803df08f44-6bb55a06c43mr90508336d6.15.1722257059875; Mon, 29 Jul 2024 05:44:19 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8d84edsm51171266d6.14.2024.07.29.05.44.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:44:19 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/6] netdev: store signal threshold in netdev object, not globally Date: Mon, 29 Jul 2024 05:44:06 -0700 Message-Id: <20240729124410.1763549-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240729124410.1763549-1-prestwoj@gmail.com> References: <20240729124410.1763549-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 2d70fc38..db1ad380 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; @@ -6164,6 +6168,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 Jul 29 12:44:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13744857 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.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 5F4201474CF for ; Mon, 29 Jul 2024 12:44:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257063; cv=none; b=Ca2gavoZ3eoXbWmeYOxQ90irFMZZToQvNESbkVeAwq+XIox3F3ZlDsoMnxnTU0S+nC4dW5zZCtiSKow/iE9SrK9w4+apNeS7tJLzH25LZutYqzJFUO+HXVJIhbx/YJTTRak+ZxAM95ZhTo95PVIbs9PYe6H6ibpUWMy8P7xu4/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257063; c=relaxed/simple; bh=ZMXepfIOR5PDI/Wwo7y82bfrh6nXGBya/TTZVzj68w0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b9GaE2jxYn9EtXbO/ZVFScANEgaEdo0pGioaILiQyMeonDZqy3KXTyn9RUqCJiHNX0uEA0uxO7HQociDXKOdTO51IjXVz5i2CyY2MgN1nTad9PbK5hwS9pn0SIsFOR2mKNvjTJoBwiIto0kjw7otNVyalut4oXoBIofD0bp/FRM= 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=TCtYpdq5; arc=none smtp.client-ip=209.85.219.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="TCtYpdq5" Received: by mail-qv1-f50.google.com with SMTP id 6a1803df08f44-6b6199ef089so19043906d6.3 for ; Mon, 29 Jul 2024 05:44:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722257061; x=1722861861; 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=BK/zxYy03R51FquWBPz7yeXqzJ59CvYxYqHnWf2zW1Q=; b=TCtYpdq5JMcHIDc0sMN8pmc7jrKIiiB7PcLjTwZLPUtlkiXYfAM8R5OFKXnUIIwoCD uKEwyxR5jIKdgi0Qzh8ZcOCxli/ayon7w09nCZ1xdvkJiJJB6t/va74P0kqPQKOma3px Ca2agoVUhnA+z4wCaWGVx+lCBwman4/pBcEjZJ/HNA1ErBtM72c9D4FXEbFnBMTV5PqF ORGZvdUgDOlW+MEhdEo/Bizhv0SozylxCUkNqTKJ7n+d6THQ763VV2rUJL9A3poAFIlI KwIv7c0IsJGpOx44IyCFIc3/v86zQ5kcpJ8UXSS9XxALiiYGFfZVpGPBicDQP4AvyIXE qImA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722257061; x=1722861861; 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=BK/zxYy03R51FquWBPz7yeXqzJ59CvYxYqHnWf2zW1Q=; b=QbxsfTapd+hdqY6yDl73jUaVWJg6Thz5ht3ZCZuubZBvwcIAd+dyOwD2WT8fr8ZgC+ Wfq4mZOF7xpif7y4g+ebGZWQbI6xfeAP4tacHLUlnBhm9IysH9qR538r/incbpdAU+rQ /9caC+WHGAMZ/9wIFsCLfdOErj2axxZ4GzARBmqShIz02XxuaLNYGzgWa2NOPeg+RR9Q gp/4KwSQRKvU0viddZjGtPnE+ZEYYjCN4PtaSpRLoOt/SASXgTu5PNyUPf8vva78BQg2 d79hwvHV3wiWw24rbs4FTXZ9ByuNVM+6uEmb+g5W9q04lfeLKSNKQvTHGd6QRYCY16o1 9P/Q== X-Gm-Message-State: AOJu0YyxaTqAtIKwqHRU8rudSmHu1iXzzvmmFnImPUM7f8ISauyKJDkU SvwwYy+GyDhQi/kBIqbnNFzbfzfsT6XkfwpnrXnyX/8+h+F0R1WZuX1exw== X-Google-Smtp-Source: AGHT+IFJqMwAID2zgqx04gvUAPwV3DGetR+zFE/3OXsCvP94FhWfz58jUJL1/7hEdSq1UJuCFLNT2A== X-Received: by 2002:a05:6214:2a4a:b0:6b5:7f22:d7ca with SMTP id 6a1803df08f44-6bb5599a916mr80729646d6.5.1722257060955; Mon, 29 Jul 2024 05:44:20 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8d84edsm51171266d6.14.2024.07.29.05.44.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:44:20 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/6] netdev: add critical signal threshold level Date: Mon, 29 Jul 2024 05:44:07 -0700 Message-Id: <20240729124410.1763549-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240729124410.1763549-1-prestwoj@gmail.com> References: <20240729124410.1763549-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 db1ad380..852ad569 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); @@ -3884,6 +3923,8 @@ build_cmd_connect: 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); @@ -4257,6 +4298,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 @@ -6279,6 +6322,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 Jul 29 12:44:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13744858 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4D4631487C4 for ; Mon, 29 Jul 2024 12:44:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257064; cv=none; b=EW3r9tBK5D0UlbGQp8Gp0Brnp7EmlVQXDTSTSVeuk+B6QW4GcEJ/s0+DJ0qVQx5gZTXccG0QlXnl+QTN9k3mq0J8A1SPamVjfOX352ij0IdyZbQRnPI5pGNEJrf0UPkHv7G+irltW5W+WgUWMHCbP59VspEWH7v1/1q1EReMtzw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257064; c=relaxed/simple; bh=wx1bXoyiUu/0XlF32T0pmCEjxlwxHbUUPu/AgHpeR+I=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nNmBw+6i3JCcK1ctRryR5cTM4JRktR6IRKIh+EPTdXfHOzUt+vcKNGt611vsmp1NwMgk7cQXEl87Pye7wbK9QDgixH4iLc44zZRQhaMTb25x8K6xHx87YBrB+psUGn29JAtzXwiI2TmZYwoa+1qGJzIUp1dXN54COSc64vAvgzA= 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=SsS2VXwS; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SsS2VXwS" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-661369ff30aso17439867b3.2 for ; Mon, 29 Jul 2024 05:44:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722257062; x=1722861862; 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=9rq7h3IBjpITtbFjil7bJuaDsith8FK5pmZ39rQk5Rs=; b=SsS2VXwSGER27yWbMW0MK1RgdzaUAO98ZLEvRTD8T3E92x3wbcrd5ARaXPtOkXXgVR atqd+jldZrXLkBVh7L1jSxHyH4HzY9fjt2UjrFKLYds7TrQ7gNzJw1EQnrgOFg982aH8 JZVbeVdy2Ctb3kRbUEj0pjYPt87iLziBAF5Kb4IaZ1PdzXYl+AhztjoFC+/TUND15skB sOaDnA+fFudLTlJrxaZqC4Tm8NzODRD6Fzv+bHQlFsMzq2jcUE7uWJBG2SGNdvdyDkfg mLaSWCPpjd5kXlBtBagjFiKAoQARJ6ul+Lngl3D4c6B2onxJCpXuB0Fapu4N+jyp/PWs yr4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722257062; x=1722861862; 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=9rq7h3IBjpITtbFjil7bJuaDsith8FK5pmZ39rQk5Rs=; b=cKb/oz+htXnUlci3rlfUqmgWRDIYZppF0+8M+erOIDuSsb/zAzdmNSt4YLgyT4gGgH WTl+LsKCu/FKkF/mmLI3bA8vp9IzbX15XMmKjiTLsHiv4Tm1rqdmRQ7eRPyQjHBJpqrD ctR70Rkrp2ycEQVoFoQ4S20KJfft5vkGeGjHTfjvsdn95jg9PX5HBOjn0kp3MDtAVYrl wR24CAqTH12d09zpuL62l1IEg7RGHhPxvGJjF+/LygohmiO2OLnW+ExPLl06cUWlwZ+B 17C0gcHgW7Fchr/zRA3MCcRnhVELzyoD6puAQrZZXN25FEK7sRj3gEY4biRzX1NoHWJd K9rA== X-Gm-Message-State: AOJu0YxlR20gvrD3RX5Pgbx2lh/PX1MjwW3jtGx6dC+U07xJTTLM3Por E0iuOuGdAhh+66kl2uNAxjlmA1VNvwJ5kkqfwGi6++bV4LpltSN6n4vCBg== X-Google-Smtp-Source: AGHT+IH5xDCgJiMqYhltVb/lU4NGniFvWwxyQOmGlhpVom8bM0v+1NIbUL/NdQYD+mTr+230SrjK9g== X-Received: by 2002:a0d:c806:0:b0:64b:52e8:4ae3 with SMTP id 00721157ae682-67a053e06d6mr82685067b3.3.1722257062078; Mon, 29 Jul 2024 05:44:22 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8d84edsm51171266d6.14.2024.07.29.05.44.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:44:21 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 4/6] station: add {Set,Unset}ConnectedBssAffinity DBus methods Date: Mon, 29 Jul 2024 05:44:08 -0700 Message-Id: <20240729124410.1763549-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240729124410.1763549-1-prestwoj@gmail.com> References: <20240729124410.1763549-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 These methods can be used to loosly lock IWD to its current BSS. Calling SetConnectedBssAffinity() will lower the roaming threshold to a critical level ([General].CriticalRoamThreshold) thereby preventing IWD from trying to roam unless the RSSI reaches this level. The motivation for this is a use case in which an external client/daemon has additional information about the environment and can use this to make an informed decision about roaming. For example if the device is stationary its unlikely IWD will find a better roam target. --- src/station.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/src/station.c b/src/station.c index db069981..dc07bacc 100644 --- a/src/station.c +++ b/src/station.c @@ -128,6 +128,8 @@ struct station { uint64_t last_roam_scan; + unsigned int affinity_watch; + bool preparing_roam : 1; bool roam_scan_full : 1; bool signal_low : 1; @@ -1660,6 +1662,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: @@ -1668,6 +1677,13 @@ static void station_enter_state(struct station *station, case STATION_STATE_FT_ROAMING: case STATION_STATE_FW_ROAMING: station_set_evict_nocarrier(station, false); + + if (station->affinity_watch) { + l_dbus_remove_watch(dbus_get_bus(), + station->affinity_watch); + station->affinity_watch = 0; + } + break; } @@ -4328,6 +4344,79 @@ static struct l_dbus_message *station_dbus_signal_agent_unregister( return l_dbus_message_new_method_return(message); } +static int station_change_affinity(struct station *station, bool lower) +{ + if (!station->connected_network) + return -ENOTCONN; + + if (lower) + return netdev_lower_signal_threshold(station->netdev); + else + return netdev_raise_signal_threshold(station->netdev); +} + +static void station_affinity_disconnected_cb(struct l_dbus *dbus, + void *user_data) +{ + struct station *station = user_data; + + l_debug("client that set affinity has disconnected, setting default"); + + /* The client who set the affinity disconnected, raise the threshold */ + station_change_affinity(station, false); + + station->affinity_watch = 0; +} + +static struct l_dbus_message *station_dbus_set_affinity( + struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + struct station *station = user_data; + int ret; + + if (station->affinity_watch) { + l_warn("A client already set the affinity!"); + return dbus_error_already_exists(message); + } + + ret = station_change_affinity(station, true); + if (ret < 0) + return dbus_error_from_errno(ret, message); + + station->affinity_watch = l_dbus_add_disconnect_watch(dbus, + l_dbus_message_get_sender(message), + station_affinity_disconnected_cb, + station, + NULL); + + return l_dbus_message_new_method_return(message); +} + +static struct l_dbus_message *station_dbus_unset_affinity( + struct l_dbus *dbus, + struct l_dbus_message *message, + void *user_data) +{ + struct station *station = user_data; + int ret; + + if (!station->affinity_watch) { + l_warn("A client has not set the affinity!"); + return dbus_error_not_configured(message); + } + + ret = station_change_affinity(station, false); + if (ret < 0) + return dbus_error_from_errno(ret, message); + + l_dbus_remove_watch(dbus, station->affinity_watch); + station->affinity_watch = 0; + + return l_dbus_message_new_method_return(message); +} + static bool station_property_get_connected_network(struct l_dbus *dbus, struct l_dbus_message *message, struct l_dbus_message_builder *builder, @@ -4722,6 +4811,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); } @@ -4747,6 +4839,10 @@ static void station_setup_interface(struct l_dbus_interface *interface) l_dbus_interface_method(interface, "UnregisterSignalLevelAgent", 0, station_dbus_signal_agent_unregister, "", "o", "path"); + l_dbus_interface_method(interface, "SetConnectedBssAffinity", 0, + station_dbus_set_affinity, "", ""); + l_dbus_interface_method(interface, "UnsetConnectedBssAffinity", 0, + station_dbus_unset_affinity, "", ""); l_dbus_interface_property(interface, "ConnectedNetwork", 0, "o", station_property_get_connected_network, From patchwork Mon Jul 29 12:44:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13744859 Received: from mail-yw1-f176.google.com (mail-yw1-f176.google.com [209.85.128.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D6B21487C4 for ; Mon, 29 Jul 2024 12:44:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257066; cv=none; b=UgsdBHuyraoPCbr1wNfpdmE4o8d+p53Bb7BlmN4mOFbck8EXSt1FH/LfozFkufhhoOpi7SpOdi8IyjFCzz3svSaOgBzwfstFND8U3bmqcJBk3XzXVc9bUIhA6orzp2GVh5BLKYXP58L8jGJ0CPfxgqSj/apRHeX2mucqYQ6vShM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257066; c=relaxed/simple; bh=9iGtdPtr4BaFIewmCRJ7Ffo6AV1x17P38NTxmT/5bVI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ab0lgOx4BwfGqmd42CZD+zwbE3+Sy9VMkRyIaFXixqzfFQnqJWIqUnvc5u8R0VkQBJPTT3sqnz4kjn+DFm3qnoGZ2HkVlph16JCPvnOicFBsjxwwJFynrtWXH9uFbAjoQmmxBg6fzuzjF4MO+lMxqGx3SCB/domSqvW3kEv2mGw= 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=DXmHN9Yk; arc=none smtp.client-ip=209.85.128.176 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="DXmHN9Yk" Received: by mail-yw1-f176.google.com with SMTP id 00721157ae682-651da7c1531so20143327b3.0 for ; Mon, 29 Jul 2024 05:44:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722257063; x=1722861863; 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=YClqp2SLUvQWTsmINjHIaLn29oO+N0ThIyfHcw5AvNs=; b=DXmHN9YkXDJJcYzsT1Cwj2ONOC6h2l6e8Z/Px65XO2HcR49jiHFeXt6AI6gFC1My/R 56aoWALeVqmIamoecq5aUVNk60AyAvylmD0w9srJ6XkgIrVKTdeXoQehQuWw4zpmqrsm 77FcjpZxrxe6BsNUOmfZfSjQmCWVdJY9EBsmzXISljEkrblUGlJckh7T/byUq60ii7vm 0UTwkmXk6bB9gvACW/3gHPjZty0zQsMZos7kQvVLqdAqmr+XUkKIVuASn0hP2xAmwj1R JIzU+g7uz4BpRp63M//1pt2P6ha9MRpdXxGONohJsHeA/7tDbpArHGS2SD4TFF+LAcYV z4tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722257063; x=1722861863; 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=YClqp2SLUvQWTsmINjHIaLn29oO+N0ThIyfHcw5AvNs=; b=vejgUglnH4V+Rtm60o7B20JY8xyrK/pmVWGTWj3GBdsmM7N9g5USB1cvJx2lk8Cy0t pABKbjXp6hLOrPdj5OOu5y0X5N6o2cRNfs4iSp1hcAoVBn6ywXfvRKGNwYjTuj+e2qoW ED4SrSvtGrrXd1pxebRABH3YzladDAN+m1NN9Mj5zYAXy1NWF5q+g05GSqOSVROjkasg GqbAsqEGGMaWGbf1EhfzDr4pkjCWyIF73DbQ53UJEDqR3EceR6A8ert8FR/r1L+E286r mBQFQw2dX8KsEWzETMaj6t8CzOjorWkEb23jjsOTwuDT+RmKUHs1j9TFIdAj3OWj8BFa dBeg== X-Gm-Message-State: AOJu0YyoWDY2RYpyjAT05nU9z+BuaxUrwALNmy2XuR5dVIbh/tpJXOTk p1ZOSazdvHYBAnTjs1vrL1G2xWtoV9dW5JZ08UHxNPzeJgLTvPhjpwuT8g== X-Google-Smtp-Source: AGHT+IEFRzN7QsCMaZ9Wi3cgiYVFzkLzt3JRawJ6GbLaIFzYSg6mqMJXkF3G3xt5HphUJym28oHuVw== X-Received: by 2002:a0d:d004:0:b0:62f:e5a7:5f05 with SMTP id 00721157ae682-67a06441dfbmr73789857b3.17.1722257063156; Mon, 29 Jul 2024 05:44:23 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8d84edsm51171266d6.14.2024.07.29.05.44.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:44:22 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 5/6] auto-t: add set/unset affinity python methods Date: Mon, 29 Jul 2024 05:44:09 -0700 Message-Id: <20240729124410.1763549-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240729124410.1763549-1-prestwoj@gmail.com> References: <20240729124410.1763549-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 | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py index 1d4a5472..211f3777 100755 --- a/autotests/util/iwd.py +++ b/autotests/util/iwd.py @@ -940,6 +940,16 @@ class Device(IWDDBusAbstract): return ret + def set_connected_bss_affinity(self): + self._station.SetConnectedBssAffinity(reply_handler=self._success, + error_handler=self._failure) + self._wait_for_async_op() + + def unset_connected_bss_affinity(self): + self._station.UnsetConnectedBssAffinity(reply_handler=self._success, + error_handler=self._failure) + self._wait_for_async_op() + def __str__(self, prefix = ''): s = prefix + 'Device: ' + self.device_path + '\n'\ + prefix + '\tName:\t\t' + self.name + '\n'\ From patchwork Mon Jul 29 12:44:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13744860 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 C40F41487EF for ; Mon, 29 Jul 2024 12:44:25 +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=1722257067; cv=none; b=m8G9Rp+zVlSSmqymoHPR7TVN83iieJsqqbzaFupeTyR6UGvEx6luKA+tLTKnbYvvfV7eigvoOBD+JY7wbbicaxJAqcdmiQ4ET4BSUSabJBNd9XmaybgG4c7MkSE3jaYnii764tdvtEBaRPm69VAvsBKjED2yB3QpJ96ALHG7USI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722257067; c=relaxed/simple; bh=+gQrkK+sZMZUhh0j8r95Ix509+sdIhu/RXrfAomQzCo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MizHRrc8UKPV2DjfntWTBiUbiVhjU0IqBYgAYR5xEMLb3bxmD3MTMJNZEKvEQjWMqKZJDIWR56H8wL+oCX5zWLk4RHKK5WjouVyYZlo0wfbmYSG2KlCQNfWqeRAs3DiK29d01VIE3VrEvndW3aspckWoHXMUrchiQhFTfJ3DTL4= 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=EnY8IsGJ; 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="EnY8IsGJ" Received: by mail-qv1-f54.google.com with SMTP id 6a1803df08f44-6b78c980981so18130126d6.2 for ; Mon, 29 Jul 2024 05:44:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722257064; x=1722861864; 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=JohrDw1YpOqYVOu6XykXepNIkgE3z15AcpREOSOK2NQ=; b=EnY8IsGJ5+N8JJVryTsa17DQnRvSNZoGwSD85DKwS4f0/WYuUJ8aiLVAa6S7L1b/Y5 oVFFPYvACLsEsArGALgrzEUJSWZMpHD74ruP467g41/QH+gSz2xtVlBTCDCoJZuZjnJP agednxZMy2uFydRtPX/yp2J6SkRujbuz1x/OYCdHzayycj9QmXraeqcLvUtL7F06re3R HYuLuP38DIkpyBTST41fn55/J+h9fFAOqNItyvYTIDsRRB/nl90ypPnUUUk1UeNBoVlR kCSRGcOehHL3WejpPnCBwIhBv+HWAH0x7gsf76O+rNNanCDNkPfINiPTO+TAwC7Ub3g3 1Wsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722257064; x=1722861864; 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=JohrDw1YpOqYVOu6XykXepNIkgE3z15AcpREOSOK2NQ=; b=XsaNysCIgTX80JTj0OzD+byuZRqFKu1IHhLoIeIAqYwyVCTr5NKgFXAuvDN7WO4luR vl6RQkiOxPdlX/TXxFV4sUCdcXBkv1VciCwKR9ew82EFNEVcbL/Xv3SeM1OoIaKQwUna xVg8jDZkED9lg4HfGP6oBvTgLU2gIwMhMW+dmGomtHRIUysrcna4IxSbjy3TqLFdoEdZ ePNG1BWbRWtACShGQLH3NRBvbzoJpH8etd/rdsbFfElWQm6CqWvc5AOy+itCD8uxPjUi l1G/uao5fHzqD2dLD1vWayppY/4jSPA/yZerLQFUYhdGar5asGvY0d3/INq+liva2AzB m16Q== X-Gm-Message-State: AOJu0YxmuLMyy9ENWk4m7Yp0xI5GW9umNRX3CyVOfWU/ygccfzoXf2bM +k357P7zlx1Wsfxf0cwCsZ3AZWbvwsARDP5MSME2YMdGNq7Hrk/0WzctiQ== X-Google-Smtp-Source: AGHT+IFJ2eUbrgXDhBMkib+TusVklt0rn66PQqsi3dKohRTN4gcZz7TnYniQ1UGI4zjAc/4JwgUlZQ== X-Received: by 2002:a05:6214:c2c:b0:6b7:ab54:3b97 with SMTP id 6a1803df08f44-6bb559fa829mr83788546d6.23.1722257064266; Mon, 29 Jul 2024 05:44:24 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6bb3f8d84edsm51171266d6.14.2024.07.29.05.44.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jul 2024 05:44:23 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 6/6] auto-t: add tests for set/unset affinity Date: Mon, 29 Jul 2024 05:44:10 -0700 Message-Id: <20240729124410.1763549-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240729124410.1763549-1-prestwoj@gmail.com> References: <20240729124410.1763549-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- autotests/testSetAffinity/TestFT.psk | 2 + autotests/testSetAffinity/ft-psk-ccmp-1.conf | 41 ++++ autotests/testSetAffinity/ft-psk-ccmp-2.conf | 41 ++++ autotests/testSetAffinity/hw.conf | 8 + autotests/testSetAffinity/main.conf | 5 + .../testSetAffinity/test_set_affinity.py | 224 ++++++++++++++++++ 6 files changed, 321 insertions(+) create mode 100644 autotests/testSetAffinity/TestFT.psk create mode 100644 autotests/testSetAffinity/ft-psk-ccmp-1.conf create mode 100644 autotests/testSetAffinity/ft-psk-ccmp-2.conf create mode 100644 autotests/testSetAffinity/hw.conf create mode 100644 autotests/testSetAffinity/main.conf create mode 100644 autotests/testSetAffinity/test_set_affinity.py diff --git a/autotests/testSetAffinity/TestFT.psk b/autotests/testSetAffinity/TestFT.psk new file mode 100644 index 00000000..e82d1295 --- /dev/null +++ b/autotests/testSetAffinity/TestFT.psk @@ -0,0 +1,2 @@ +[Security] +Passphrase=EasilyGuessedPassword diff --git a/autotests/testSetAffinity/ft-psk-ccmp-1.conf b/autotests/testSetAffinity/ft-psk-ccmp-1.conf new file mode 100644 index 00000000..839eb496 --- /dev/null +++ b/autotests/testSetAffinity/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/testSetAffinity/ft-psk-ccmp-2.conf b/autotests/testSetAffinity/ft-psk-ccmp-2.conf new file mode 100644 index 00000000..2ffd7262 --- /dev/null +++ b/autotests/testSetAffinity/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/testSetAffinity/hw.conf b/autotests/testSetAffinity/hw.conf new file mode 100644 index 00000000..c2b35d6e --- /dev/null +++ b/autotests/testSetAffinity/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/testSetAffinity/main.conf b/autotests/testSetAffinity/main.conf new file mode 100644 index 00000000..3d93ff57 --- /dev/null +++ b/autotests/testSetAffinity/main.conf @@ -0,0 +1,5 @@ +[Scan] +DisableMacAddressRandomization=true + +[General] +RoamRetryInterval=1 diff --git a/autotests/testSetAffinity/test_set_affinity.py b/autotests/testSetAffinity/test_set_affinity.py new file mode 100644 index 00000000..8a0fdf21 --- /dev/null +++ b/autotests/testSetAffinity/test_set_affinity.py @@ -0,0 +1,224 @@ +#! /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_if = dbus.Interface(self._bus.get_object(iwd.IWD_SERVICE, + device_path), iwd.IWD_STATION_INTERFACE) + + def set(self): + self._station_if.SetConnectedBssAffinity(reply_handler=self._success, + error_handler=self._failure) + self._wait_for_async_op() + + def unset(self): + self._station_if.UnsetConnectedBssAffinity(reply_handler=self._success, + error_handler=self._failure) + self._wait_for_async_op() + + 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]) + + device.set_connected_bss_affinity() + + # IWD should not attempt to roam + with self.assertRaises(TimeoutError): + device.wait_for_event("roam-scan-triggered") + + device.unset_connected_bss_affinity() + 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.set_connected_bss_affinity() + + # 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_affinity_reset_after_roam(self): + device = self.wd.list_devices(1)[0] + + self.connect(device, self.bss_hostapd[0]) + + device.set_connected_bss_affinity() + + # 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") + + # Affinity should be reset, and IWD should be trying to roam + 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.set_connected_bss_affinity() + + # Calling unset prior to a successful set should fail + with self.assertRaises(iwd.NotConfiguredEx): + device.unset_connected_bss_affinity() + + self.connect(device, self.bss_hostapd[0]) + + device.set_connected_bss_affinity() + + # Multiple calls to set should fail + with self.assertRaises(iwd.AlreadyExistsEx): + device.set_connected_bss_affinity() + + 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() + + 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() + + # 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.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() + self.wd.stop() + + 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)