From patchwork Wed Aug 28 19:24:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13781767 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 6C4BE1ABEA7 for ; Wed, 28 Aug 2024 19:24:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873076; cv=none; b=KroxowpuuDBQXJr6mDJuCsmZbJ+iDMnavE/UEj233ZV+5glXl3NdhjpvyGwTGWa8eDEgPYZ/eO7B7zDWnEbwBAf6HGl5phZsxvoWK3UJEEvBsuxPfERkIUSRs/Lg/19G8oD+Of+iQ2QFBwEE7rve/DhrXnc+uJLu7FECkTA24Hk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873076; c=relaxed/simple; bh=6sPDRJOD0zxcNzux6fRSpLWWbyFPNTzxv1nmN/eSBX0=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=IxTeh3OawWwKo8eqIVq7LrSOAgEl1mYp+PIE/b/+i49awYfE2w0uZ4IRvH7BFZngUcbs8i1/QpN1OHtSxTyeefEzAdF9Zd0wk29JiXTBYosbN9uz3iWfFIFOc8Xbg2yzrnyMCgDgikfuEoQJDYIIP89lLtLVbGWtoe9JI5uZiQs= 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=Id7GYZNQ; arc=none smtp.client-ip=209.85.210.174 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="Id7GYZNQ" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7141285db14so6073670b3a.1 for ; Wed, 28 Aug 2024 12:24:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724873074; x=1725477874; 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=Tio7v8U3brCXEVpg4JvgYJu9CPfPEeJf/Lf1dRgQjuU=; b=Id7GYZNQM9lJVLaTaHIqhyuAWII8fxxdWDUFkOoMikSYcETa9a1MYSvrNdGrq1jACl pFjQo2Bolz79/z1aGimP1I8m28hUSHOOLmD0DU6f+sgvO2OXVLgv/PhzXeK6oJMy7Ebl Np7E35hrY2MIBZ45TKTuJWl+vgXoHQGQmLS7MsX7to4svPnCJST9Fw6T+b2v4klspgzR OPl11S/VoTvCqW8uMKhEf6PqfdU5BASfo25BNU1AClyMvlaMzjbW5LPjQuTuYExxTqO2 YWyrpp2Sk5yz5NqdpRKNT2dy5XFjDXm/3D9VAT71xcPHFG+70gCXHr6caUYrRdkHLuMN luLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724873074; x=1725477874; 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=Tio7v8U3brCXEVpg4JvgYJu9CPfPEeJf/Lf1dRgQjuU=; b=LHHVZ/KrwxSpRsfcn7ksYL0+lI6Cm8gJM9BwccmbD4NI5Hzk3Fcr+9H5R0HIT20CHp s+oMCHDldCxql9Pyd90F3fcPBpMH8C9lM179KtCYZyhH0fLcqFn7v+8bjiiXCoLb5/Px eigk4tNPoO7kxuJMXtmyN0OVFu/+bPmi9vQStQZc8jrokRMeGgrFBxB6dC+nhhWXISaJ xTJPXEgJfFzDTdy28EL1oS0BVxSc37cdv3Z00k4VE6Da/t7Oi8Ryo3zT40BctDzlNdao Mc8uCjpxPhUX67WzacKHM1rrWlRWKhz/il3Tlkp8okeRHmeoYT69/q1TkVVw6AUxMx3S dAtQ== X-Gm-Message-State: AOJu0YwahXZ/rL+ifI2mCAxMrJJQ5uSNFn9HB1fQbUWyhqXVeb6GYIg9 p6I4IaI6uqkziqiGymfWDvA3Bypq2TaljTL0wDAQ2vdb71ZtogoXmELKtQ== X-Google-Smtp-Source: AGHT+IGN3nd3qoEf2obHGzQMHVIXaRD0OR9wxz54GXq0Pt8Re59XghN5krTLY3F0+s4yF5tWUl35cQ== X-Received: by 2002:a05:6a00:3911:b0:70d:2693:d215 with SMTP id d2e1a72fcca58-715dfb77efdmr682228b3a.16.1724873074141; Wed, 28 Aug 2024 12:24:34 -0700 (PDT) Received: from LOCLAP699.localdomain ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ac994a3sm11081635a12.16.2024.08.28.12.24.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 12:24:33 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v5 1/6] doc: Document station Affinities property Date: Wed, 28 Aug 2024 12:24:23 -0700 Message-Id: <20240828192428.902761-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..707c6834 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{5G} 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 0b2878b8..9dc0fe0c 100644 --- a/src/iwd.config.rst +++ b/src/iwd.config.rst @@ -133,6 +133,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 Wed Aug 28 19:24:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13781768 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.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 B88B41ABEA9 for ; Wed, 28 Aug 2024 19:24:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873078; cv=none; b=SsribpRaMJwSeT9Zw0Za7QuJY5X27QKmnuHWh9Mp3o5tzGeNAUsbAuR6aFJwI0VqOkLFDLrooFvJ4JTXcuneUaHVSWY3zifzzVH5tybO3gBp5HbcJm8lmYyoh73Pm9TWWIz739Ec7U7Oh7KEA7IN9SWWzrzkmei431fXhZuhzlU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873078; c=relaxed/simple; bh=NIfjGt2bpC2A6vEZMyAy4JdMJbSFpPFhCXk8SaX+deE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MOdNmSt8k1slDKJJLK/SidvuMGICJJEXziGyIpTHJwL1+W8c0Sv/KWIx1k37Q65ArReL7XfuoQeFG3o4ElhviS03hZ9SRy6BAl+/ntfKQOOYX8ScKl1t9yilrTEH58vdu6m5oNiiGOmT8wVPS1k9cXo6pqWpJ9aMk6t6e3KlWns= 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=XS7Xyc3k; arc=none smtp.client-ip=209.85.210.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="XS7Xyc3k" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-715cdc7a153so781216b3a.0 for ; Wed, 28 Aug 2024 12:24:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724873076; x=1725477876; 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=tryyBdZ446X/A40KPsC+AsZfsXC92MsVqd9qgR4Y1BI=; b=XS7Xyc3kx1lyJB2E9tO9WKy5hPrsLCHTST43owaAlBWXNBhQ/ghIXjXn/EWCkM1Llh Wmb/1g5FttUGxaRoj9RTmLgRPBwqMs3wvCzEDFbhbZwywuGxrqn4XEdew5eJznHX+j2I 09CNvcBV3E0n+TQfnv0KjjGA7h5lLjovj8wCce9uZzdl5jXQVS5bf6Ef4dawWm9tMlZP 22bSyZfPPorw+WgkB04ePdOg75xR9WVqoH8IHJadZCiqpBaHU+b69ranDoPCgQI0cdbI lE9fTZvOOzI76WTbYwEGcEFOeNd0WAmGumJKqcU7Y2qtq6uSB6Ya/ySHzp76BbJV1kEw 5Yxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724873076; x=1725477876; 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=tryyBdZ446X/A40KPsC+AsZfsXC92MsVqd9qgR4Y1BI=; b=K0Y7NnAabgxInUbhIN4oNXfJDOpufpZ3w18MxVIPDBhur5Cst4sPByJhmS0DRPX+os 9FlnIKx+dZsZ82bspM3gnh2rpuhFqMMxhIoAM6dflLMLbzJg2s0ZD9n2oTuEM76oklPW 6az8J5ShLqE/3y8YD011ItI4LzHhvhn4h5gg3LSU9MeBPfN8eAm2cKgdv2AVDkAljo3h uOVx/jVmyVit3VZAuMw+d1MiPoyPpC0cxNWPvEeE+Y/2j+uERdS1trICNAdt4CE71NI5 3tT2ib4Mw4t9U6ix10z9T97Mjl8IIPWxJ97eytTPmfD1lI4sBtm19upW5YpO9NRAW5zh eMtg== X-Gm-Message-State: AOJu0YzH40Lh3HxsNEdTKxbkhCd032tpFp3M+QDC4+tRe8KV/GaKp9BN k/UD/W5tZfMU6XA8HNLT0SA+wUsezG6eM+ut+jGdqgM/h+M33NeacPZAqg== X-Google-Smtp-Source: AGHT+IHyFKrrWT68xBFO1hW+2O9IMW2J3fJWLMPKJvizoimSW8euDc0I2HxoJureWNAYcPQ4LdoDnA== X-Received: by 2002:a05:6a00:8785:b0:706:aa39:d5c1 with SMTP id d2e1a72fcca58-715e0fbe611mr251452b3a.8.1724873075700; Wed, 28 Aug 2024 12:24:35 -0700 (PDT) Received: from LOCLAP699.localdomain ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ac994a3sm11081635a12.16.2024.08.28.12.24.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 12:24:35 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v5 2/6] dbus: add PermissionDenied DBus error Date: Wed, 28 Aug 2024 12:24:24 -0700 Message-Id: <20240828192428.902761-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828192428.902761-1-prestwoj@gmail.com> References: <20240828192428.902761-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/dbus.c | 6 ++++++ src/dbus.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/dbus.c b/src/dbus.c index 32de1e1a..b3799b55 100644 --- a/src/dbus.c +++ b/src/dbus.c @@ -134,6 +134,12 @@ struct l_dbus_message *dbus_error_not_hidden(struct l_dbus_message *msg) "Not hidden"); } +struct l_dbus_message *dbus_error_permission_denied(struct l_dbus_message *msg) +{ + return l_dbus_message_new_error(msg, IWD_SERVICE ".PermissionDenied", + "Permission Denied"); +} + struct l_dbus_message *dbus_error_from_errno(int err, struct l_dbus_message *msg) { diff --git a/src/dbus.h b/src/dbus.h index 14814b5d..6d7074bf 100644 --- a/src/dbus.h +++ b/src/dbus.h @@ -82,6 +82,7 @@ struct l_dbus_message *dbus_error_service_set_overlap( struct l_dbus_message *dbus_error_already_provisioned( struct l_dbus_message *msg); struct l_dbus_message *dbus_error_not_hidden(struct l_dbus_message *msg); +struct l_dbus_message *dbus_error_permission_denied(struct l_dbus_message *msg); struct l_dbus_message *dbus_error_from_errno(int err, struct l_dbus_message *msg); From patchwork Wed Aug 28 19:24:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13781769 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) (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 74A501ABEA9 for ; Wed, 28 Aug 2024 19:24:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873080; cv=none; b=Ww//7pa64yVqBohab2OSIaWOosypHcbNkVa5FRdZLyoCl3u3wnx2TWYhD7jsPwYOwR6Tv3aO2dH6Ep3J9mEmZFeJEcTsW9bXQC7vUzvXmXR8KoOXATl1NaOlkEzll24xmua4aPXnM4KVAEoloCJQhKX4YdShJN9moVIrqW8C6/s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873080; c=relaxed/simple; bh=/cNvou5OKwXBZSjARc8ZH2uKndES7KGCEkZ8twncnpI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j2TtGKd5I1VVc70gJmXMipZuGTGLr6WNvYtSD1BI3f83BcPqEkr81Zm6nxRQ2k+ARU+OVcC0Vc7rh20Lrzx9XGuPYL0O5Xpp7AEQ/e48DsyVkxqxUCDvXWbc1ICEnduUMRQkeFC3vjwuVEOp403j/3NlPVmt2NBBkpmUw19Oz/s= 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=kjv4qjhA; arc=none smtp.client-ip=209.85.210.178 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="kjv4qjhA" Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-714186ce2f2so5631486b3a.0 for ; Wed, 28 Aug 2024 12:24:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724873077; x=1725477877; 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=so6t1mdougBNTX+QXQBrug3QroIUHCATB/kW1/gWbtc=; b=kjv4qjhAK7Cu87pj79xeZBwuJX6Egw19Xud33glYqNGjlRorDzBGKHxRcth9u1+UJB qvde2pj+pB+w1ewSRU4LVT8UvF7q3K261lf0et39q8znTN/niNfsmGGfN6qgyw0m8YzK ynwo8wVBBIaHP3LLvClgys4IrH6u/ovirHK7JTTRWKaJoP50Uedn+A8gK8vsjYGF7Dko 2pJc/n7Q36HTNhizjgCs+mPOYIJakyZvKy9om3h8uUZXUApJgmnfZnV1Yb7A0l4S+fJJ pbOQ/T0+2gDLfXc0tzKzVFihhavJJKYj8VW09Iyuq5+tmd6geQg0v2/upYOya25PdlQt MjQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724873077; x=1725477877; 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=so6t1mdougBNTX+QXQBrug3QroIUHCATB/kW1/gWbtc=; b=YmRN8XMlPKE3QzF4XsXvmtafD1WuaG89/K69NX5M1+8wOxVJTataIv+zJnpYAbW7yG AVHDKJyxTWm5Kx6DXhgtpZPOfg7YhfWnOLL4w4Dddyoi3GwbfpLcBM/dttZ98anFgCm8 rOx3KJpjuRNO6vGxq4ewaEf5szDki/aXmCKx11j0YA+txEWN2XzBvBNnzLMkhFaMd+gm FIUSrOcyBOEuvKi4kaxZDn2n1dVGXcpLIRRDp/Vh4cozsdmj8QE7Y+120u1mvWb4MltN jswYtr4MsiUhF1gz6D3Mq4XqfpW19KoW+AZ01lLqFQ6U6Sx8RPKLp2g6kiWYUtjfHCuP pqfw== X-Gm-Message-State: AOJu0Yzu1DPCeXTY+6cEd30+FUY82cO3H218a4RXzU41FAI9ImpCz/GC MqI6q+FYaXAU0ykpQTRt69B3dD/0232pZX5W2zgQ98NjMsqR6dg0d6Q0tA== X-Google-Smtp-Source: AGHT+IH9RMqkDTGt0Zdbi+w+TM9Doeprx1VAEs6FV51mDpC2JCD/jcnJYtA2wAv307KE1uhc4WYpsw== X-Received: by 2002:a05:6a00:1387:b0:714:3a4b:f78f with SMTP id d2e1a72fcca58-715dfbf403dmr639687b3a.20.1724873077351; Wed, 28 Aug 2024 12:24:37 -0700 (PDT) Received: from LOCLAP699.localdomain ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ac994a3sm11081635a12.16.2024.08.28.12.24.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 12:24:36 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v5 3/6] station: add Affinities DBus property Date: Wed, 28 Aug 2024 12:24:25 -0700 Message-Id: <20240828192428.902761-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828192428.902761-1-prestwoj@gmail.com> References: <20240828192428.902761-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 loosely 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 | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) v5: * reworked a lot of the logic removing the loop and instead just trying to get the first path, and fail if a second exists. Also fixed some cleanup on error paths * Check for FW roaming, and don't allow the affinities to be set if that is enabled. * Return PermissionDenied error if a client is already managing the affinities. diff --git a/src/station.c b/src/station.c index 30a1232a..1eeefe75 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,144 @@ 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; + bool empty = l_queue_length(station->affinities) == 0; + + l_free(station->affinity_client); + station->affinity_client = NULL; + + l_queue_clear(station->affinities, l_free); + + if (!empty) + 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); + char *old_path = l_queue_peek_head(station->affinities); + const char *new_path = NULL; + struct scan_bss *new_bss = NULL; + struct scan_bss *old_bss = NULL; + + if (!station->connected_network) + return dbus_error_not_connected(message); + + if (wiphy_supports_firmware_roam(station->wiphy)) + return dbus_error_not_supported(message); + + if (station->affinity_watch && + strcmp(station->affinity_client, sender)) { + l_warn("Only one client may manage Affinities property"); + return dbus_error_permission_denied(message); + } + + if (!l_dbus_message_iter_get_variant(new_value, "ao", &array)) + return dbus_error_invalid_args(message); + + /* Get first entry, there should be only one */ + l_dbus_message_iter_next_entry(&array, &new_path); + + if (l_dbus_message_iter_next_entry(&array, &new_path)) + return dbus_error_invalid_args(message); + + old_path = l_queue_peek_head(station->affinities); + if (old_path) + old_bss = l_dbus_object_get_data(dbus_get_bus(), + old_path, IWD_BSS_INTERFACE); + if (new_path) + new_bss = l_dbus_object_get_data(dbus, + new_path, IWD_BSS_INTERFACE); + + /* Either the same path, or both arrays are empty */ + if (old_bss == new_bss) { + complete(dbus, message, NULL); + return NULL; + } + + /* + * TODO: For now only allow the affinities array to contain a single + * value, the connected BSS path. Any other values will be + * rejected. This could change in the future. + */ + if (new_bss && new_bss != station->connected_bss) + return dbus_error_invalid_args(message); + + l_queue_clear(station->affinities, l_free); + + /* + * Adding a new BSS, create a watch for this DBus client so if it + * disconnects we can clear the affinities list + */ + if (new_path) { + l_queue_push_head(station->affinities, l_strdup(new_path)); + + 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); + } + /* The list was cleared, remove the watch */ + } else if (station->affinity_watch) + l_dbus_remove_watch(dbus, station->affinity_watch); + + complete(dbus, message, NULL); + + l_dbus_property_changed(dbus, netdev_get_path(station->netdev), + IWD_STATION_INTERFACE, "Affinities"); + + return NULL; +} + void station_foreach(station_foreach_func_t func, void *user_data) { const struct l_queue_entry *entry; @@ -4750,6 +4915,7 @@ static struct station *station_create(struct netdev *netdev) station_set_autoconnect(station, autoconnect); station->roam_bss_list = l_queue_new(); + station->affinities = l_queue_new(); return station; } @@ -4842,6 +5008,11 @@ 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_queue_destroy(station->affinities, l_free); + l_free(station); } @@ -4878,6 +5049,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 Wed Aug 28 19:24:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13781770 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.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 EAA6A1AB503 for ; Wed, 28 Aug 2024 19:24:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873081; cv=none; b=dGIzwU0iTRjT1w2Now8GeKcgndeDYzSnFhY2nj+zqKChn+fKg88oxERB42mu2si2q9JDpMG3+rgQfe48mXvNq9GwFJjE1UXeesPxcPtCiUxGehLfjMkiJaVxqElhJS8I1PRcImiDU45YifVgmd9HoeuCLVIXJiIHFLUdojRjM7k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873081; c=relaxed/simple; bh=QEhQJHRbOrtm97/kyHCtpnjRP4hsLDz84/vKfst8oR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=j0jlL/r/0JO7rf3IkXDEIQNOlWYlt99HtfIk/ixEkn0jiTbn20rqUh02hdbwOu6bZdd5coOhKGsw79dDNLa+fIGJjCbDL54PAL/AFOPwuWCPkPdj1ZKPF/+JqtbHDWPOoP03jekJS9y3lp0oJpptaMaV1kpSauA0Y7dyfZBGjq8= 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=UUnTvUkb; arc=none smtp.client-ip=209.85.210.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="UUnTvUkb" Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-7141285db14so6073719b3a.1 for ; Wed, 28 Aug 2024 12:24:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724873079; x=1725477879; 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=Nb9s9ZgiN2zlEoTES0mbLk7/Twa3l4AT7LI5Y3bD6LE=; b=UUnTvUkbyDeuv0k84hFcj4wab8DS8N2QpWnHjx5wAGS851iBW1nSmoQBY9i0R3vq3P 3ZqzvJJiIboqo9TcnVwcetdHtL1xkV5AhUWAnp3AJuc/Bw3JPcWl9QQbNSaAHlV5Q/1R DUez4rJPVL0fSKKWCbd/mrt0yKjOQ9fE/l1jb+dsL37Oh3S1qIfLZmpqWTBqyyoD6I/h nko8fStQ/kzJ8t5CU+V3Rtzde74PgNExYeWnpMZVbCUC4NWnAhaItUAyI/7c7tfxv9ZK 6y0t0Y5RfGfiJEbCpEiIMCp7oIk7vaNjzy16dm98dCDH3HbdLoimoaBMDIwWPwjIVCtO f28A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724873079; x=1725477879; 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=Nb9s9ZgiN2zlEoTES0mbLk7/Twa3l4AT7LI5Y3bD6LE=; b=EAkOp6JUOJuHneYQPu2xns0knE3ISBdWWRuUqOG8nwtuWEAR3DddAPmp6nKrP/Co8w G/r/RkP5eCQdeLiFoa+BYN8UEC4aB/0CtnN6HfPaUd2G00nykTX2LNM0k57E+vDP51RW WtVNB8HeaQaA/d8zVicVVeDoBX0b1aAmiSkrql0UfGTz2D4oBe1MrRL1+PxZiDybfxE/ iSg3VFA4A3O/HqjFFDwYMcxNLIeyWR+RCxChi5bBCt76D0WnCRgJlnhNVrSnXAyx7JYq GOZMlQsvRxYj5xNF8WU3dEZzOBiXYdGygmgaw5u37WOaX3doFFSNNthXcAJy8Sicj7FG dxOw== X-Gm-Message-State: AOJu0Yz7OZ9nWpsYH6T9XNwbbjx02OtCLNCr+NRT4wKaSnXHuYPBv7fT H1+Blw3QlHfYITBPRzCd6WP7WsbQt1V2ALU3/U8U5lGCFFkiesgm6ftPTQ== X-Google-Smtp-Source: AGHT+IHIlii7Fs4EzKbUnolhUS7u9ZzaOEOaNInyy/FEI5MENQyk0qUjo6B9sJrRWy+ciCCcJ3jang== X-Received: by 2002:a05:6a00:c92:b0:704:2f65:4996 with SMTP id d2e1a72fcca58-715dfb2e239mr575903b3a.11.1724873078902; Wed, 28 Aug 2024 12:24:38 -0700 (PDT) Received: from LOCLAP699.localdomain ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ac994a3sm11081635a12.16.2024.08.28.12.24.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 12:24:38 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v5 4/6] station: Use Affinities property to change roaming threshold Date: Wed, 28 Aug 2024 12:24:26 -0700 Message-Id: <20240828192428.902761-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828192428.902761-1-prestwoj@gmail.com> References: <20240828192428.902761-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 1eeefe75..c45d13df 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) @@ -4612,6 +4615,7 @@ static struct l_dbus_message *station_property_set_affinities( const char *new_path = NULL; struct scan_bss *new_bss = NULL; struct scan_bss *old_bss = NULL; + bool lower_threshold = false; if (!station->connected_network) return dbus_error_not_connected(message); @@ -4665,6 +4669,8 @@ static struct l_dbus_message *station_property_set_affinities( if (new_path) { l_queue_push_head(station->affinities, l_strdup(new_path)); + lower_threshold = true; + if (!station->affinity_watch) { station->affinity_client = l_strdup(sender); station->affinity_watch = l_dbus_add_disconnect_watch( @@ -4677,6 +4683,17 @@ static struct l_dbus_message *station_property_set_affinities( } else if (station->affinity_watch) l_dbus_remove_watch(dbus, station->affinity_watch); + /* + * 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); l_dbus_property_changed(dbus, netdev_get_path(station->netdev), From patchwork Wed Aug 28 19:24:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13781771 Received: from mail-pj1-f51.google.com (mail-pj1-f51.google.com [209.85.216.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AD7181AB503 for ; Wed, 28 Aug 2024 19:24:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873083; cv=none; b=gu3cnDFn+kMPkjr5U82T9VsLctNyHLgcVVWCjc/P7UX8mCrzYiKYI89QUjwidv6aoW0pLB7E/BX2qP08LsnR6HaGLjPumFhnJbMhcbtfUMHR9u8vLUAb5rJtN/9QX9jiVsjXwSjhUyKDbQ+j4ttpeDHoLC+U/+KfgpSS8p09BdQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873083; c=relaxed/simple; bh=1pYxZdt/cb6QaZROUOt/UXNKrd4LBk55ZWX1Jek2/YY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PksMZuOQxm9jAoJnD/COVIMNEmOkQVDROxWcw9YM0DefJOB0+zVLU1HYnrKIrtEKClgwJ6MsPERth3oihlt93+EyzbySKQA+43OfbhLkvvWvRqNNUdTvMGOOk0zhgCyDoca+5DVeW63TgxnGBNnSW5xSHkfFjZfrR9CjNxCL4EA= 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=O1t4uJr1; arc=none smtp.client-ip=209.85.216.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="O1t4uJr1" Received: by mail-pj1-f51.google.com with SMTP id 98e67ed59e1d1-2d60f48a2ccso5816295a91.3 for ; Wed, 28 Aug 2024 12:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724873081; x=1725477881; 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=O1t4uJr13M9E5LWt3DntsuwesPpNt7CECTLJHN4Az+pXRoExlIAieaj+BYQehBLMEx v8wGSqU2rDpolnochH59GCowQI80AY2Hulja3m4bjvqxFrb7LNTyGa3n13e3h7/knfae 5kP1zKZntq58KuU/R+FSzxGb8E2dLmePH8py/nA5ykK9BYO9dDiXEpqlln5gOWPL4Rtx ij+00FHZEk4pLrTK6ZwmHpQaWSR9co2ZMiAQWf/20PSpX58hCw2oqUfWAY2KC9QkdVmL bK7Ad4bqarbm6qzccl0uLJnSrqJKRi29iKvTjQvj5eN4dwC005ojG06iAcm+6hoBUMp/ 4+rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724873081; x=1725477881; 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=v+fM/N/q7AMJZ+BUb84o+5YBBSQylWMsy4KcA5XpWzpcfLEilw4NPqwBFk4aNotqLB V9q4r85cveZFEoFwwVkgU+OFPhbkJawMKC0H/UICRslOdR35BX9DDKo7DMjOLhJf+keV frnJeKP3P3dTJ8ujhb/5GnoJ21bl9TRcdThzdeqY/0mD9TccUCu42Pg1JE98lg7bgS9F jm+ch3wjx0X5bQjzbKu/Lmlcyegb69SZt24a6SvxRI10WL5wI6ph5eN0TVuxzX8vXQEQ BspTHT3jJsbcPvFrRiJxoXsLxac7+jGdYQp+2f81S7flzQzY+1yaxmvYNeZ+S+45JksG 1tFg== X-Gm-Message-State: AOJu0YxQKQZsN7FNzk3g1yeaZ1StNtZ9Rg1S4JIrOs51FYxRVZ7j8n/F IwFAGwJHXk7r16dh/WDgf6ZoWhiCrc6Awvwby2T9pqa9HTBtJ/0TUiCrAA== X-Google-Smtp-Source: AGHT+IE9Y2E/xyiAMdE/RAkt8jy0CkKu1SPtN7bTaO5An6iGkvCunLf+H2U8Uxs++z4xE+iW2kuB0g== X-Received: by 2002:a05:6a20:9f07:b0:1c4:bde5:174b with SMTP id adf61e73a8af0-1cce10fe079mr302873637.41.1724873080657; Wed, 28 Aug 2024 12:24:40 -0700 (PDT) Received: from LOCLAP699.localdomain ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ac994a3sm11081635a12.16.2024.08.28.12.24.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 12:24:40 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v5 5/6] auto-t: add affinities property for station, and extended_service_set Date: Wed, 28 Aug 2024 12:24:27 -0700 Message-Id: <20240828192428.902761-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828192428.902761-1-prestwoj@gmail.com> References: <20240828192428.902761-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 Wed Aug 28 19:24:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13781772 Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.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 4BAA41AB53F for ; Wed, 28 Aug 2024 19:24:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873085; cv=none; b=uYsuv3AK7MT946/qiivwGRt57EEIjoVIWNix4xaXRzo/DtCIS0I+jwG5ukCabxNnW9A7OGVwNyUtSvhk8np3FwOepKRK6+wh+mE3EL/SHhLltLMjAQpaOt+DdhyeoM7owZojQ8FruaRVZKmoJPpyZFro8eUgvKV5SyaJBdeHe/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724873085; c=relaxed/simple; bh=VtfRUqAptUpigOzeZjNHoVL4/+kBM519529S4p/CSgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kxLbuQp/tMKxLcmAf8xmbiDVaXpyjvlem9tu1/9PdLIsTK6CdPqvd4YbeZvbg/OURe0vFrCiBk+zT3ASsFTNRp0j847+FNnc9//Tf8LprPvXnd7L6rIoRxOMVgBA1N7Guma6ZO3j84tm88zY/GeRHXtLf3zZjBLceTZOaGtV6V0= 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=RGKbGlN/; arc=none smtp.client-ip=209.85.210.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="RGKbGlN/" Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-714262f1bb4so5324196b3a.3 for ; Wed, 28 Aug 2024 12:24:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724873082; x=1725477882; 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=RGKbGlN/JOP++ewnrBxT+Z1pUpQeFu2PHtq5DyQ7rrYSDjfANN83Pk1anY/DDbANGU c4PFun+fQgnU7fMcrR6IGcURMzEHT1R+Y+Gu23EOkFAp05jZLqfmx/yt0oAsCxOr/Ckl SoyDVMAeG7G+YLRgyngD/d2hXvKcUQhaMmzIbZqqxoe3romWFn+z0tq0XPP8GMEQtHxC kaicgjnllrskdxvGxa/PaeoxwQH0K7ms5AgS+PF6hKuNNNgo8AA6N+gPf6Vc/5xEOwpz YWHfsnj6WZVXqel+sILiWYY43rfNsm4EVA3zKzwKCD5C5GYvcwuMK/PIkZz1ycLFPFi8 5F5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724873082; x=1725477882; 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=QqEIFdG0w6L0HoeGkkE5XGmONhvk3q90ZPBtXuEgD71HZrlld2a68diw8b+7jkrU+/ YVYNRkz1AsB2aCCrVWa5PV4B9zRjwp0wnQH4GIxc6DJsbgyWwPNUdZEFNo02RHoPKCou oCI8m1ZVXbQ0RFTrbivV6Ye1ARPi3kU5ZRdxlUP1/ac32vDY7JQ6kRsNfCBgXQXAv/GB a8GGvertTKBBT6cfn+LbsJrlCgJ7g3+mNqMKf6hGDkiW4txpemF91pERw30Hhavk4Y0o YUKer/P2S9QSXzLrlDws3cl0vhKhgtKXc8ppHtFai4eNcLxgpydqOO7o2XP27MtOjoSi OpXQ== X-Gm-Message-State: AOJu0Yy+FAKNI+HDtSMGeChBtRyj8fY7kF1qOm6nUCnO7r9efFECAmYC ntFOcv2mQsGNLr7b23jve2R29UiERxKh6nNbG9ORJ1GY60n04nM+wAvh+g== X-Google-Smtp-Source: AGHT+IFExqXHcD3qeCAQ5JLDqRuyNVK12JP7Hks0h0KRCEZz/Qe/eeptXt2WZba67VTT8hPg8VNtBQ== X-Received: by 2002:a05:6a00:1489:b0:70d:2ba1:2402 with SMTP id d2e1a72fcca58-715dfcbb2a3mr582256b3a.29.1724873082240; Wed, 28 Aug 2024 12:24:42 -0700 (PDT) Received: from LOCLAP699.localdomain ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7cd9ac994a3sm11081635a12.16.2024.08.28.12.24.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 12:24:41 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v5 6/6] auto-t: add tests for Affinities behavior Date: Wed, 28 Aug 2024 12:24:28 -0700 Message-Id: <20240828192428.902761-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240828192428.902761-1-prestwoj@gmail.com> References: <20240828192428.902761-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)