From patchwork Fri Aug 23 22:23:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13776083 Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A39419258E for ; Fri, 23 Aug 2024 22:23:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451828; cv=none; b=m/gE4yNNrfSILyQBU/DteiW4Kx1pKJoKplzGPDtDpZOeRPnifI2ZFO5C9/Vgye/9VTLc+jTOtlr7KIAFreHF8CZ7TaIjzxcNELW1mm5uOITIQZM0QTIrH/x4ThuKCecy25oWO5tkZOdpGRCvCfillE7b3p2+ufL2rdGVCPRQ9NY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451828; c=relaxed/simple; bh=dS0tyOjSd4TPPSvvYfg8CAQBd6kK7xkQ5caCa/Or0ZI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=qe7PJZfsv+QeyfW50dAH+MJB8AbtRkmTfKWVoaHUjajewfBlYMUFQs6by+q4LaswIAfWs6xXcDwqpBrq17IiI0Us8t07XYSOAR7UGtfkXV+xcroYYNyPHN6fPZMHdpHMlvBXS2XnqtDDeoT/tBXJQ5TYOfo6mOEDx3qBq4y0FM4= 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=MbbiBIG0; arc=none smtp.client-ip=209.85.222.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MbbiBIG0" Received: by mail-qk1-f177.google.com with SMTP id af79cd13be357-7a1d6f4714bso234190585a.1 for ; Fri, 23 Aug 2024 15:23:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724451826; x=1725056626; 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=6eVTC1Aym8sF7ndRgQcB/wj5IW7I/Jj97dqCANyEsNk=; b=MbbiBIG0o0CHhSooDF1g2utnlIbkQV9/yjfI74wFilbbQiIZvDAfkuORqou3J4tO2p ba3DXkRY4GBH6MI2ugMuBGfbWzfCrmp9eVtlsQ9jq66eO0dkCNKaXqcszAZ4IPYrGcg2 TXzcqEfY1wIfYc1ck32MpAoqxaidrvoIoiY+UkrZOZZLutFnubZ0F1dZuV2Pfwj8n+5l NXVUsmsHOey5om+qAivBSkIlBamlBzjvm2E8dn1Zz+ZQaOXClGRc+n4hnuyb04gWAAcE 3t90GNb3GWa+AzQ/USHklQUZYVVCj61dAWekj0/Gd9RqarQkwN72YAMG56+HKZwQrRZj y/cw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724451826; x=1725056626; 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=6eVTC1Aym8sF7ndRgQcB/wj5IW7I/Jj97dqCANyEsNk=; b=pWuUx/7LFeLjKPkGuk3u+JiiV6Dbya47OJ8rOo52RvfDL64S11lofs+kfo7ec2C7Kl Xx/kPiGXyhokz4xGdo1rVbSAja/Ijrq7cB3CIuEGc1agyNlbhAKuviNbXmJroc2Wm72p OAHLGn4X8oCVwQAXgboYWGbwKj7mLlH85CMKECza1gLpbyMw66EwcZagvCxi8HgdZLii H245m9l86XHOt0f1dTFBHzPx1WTPbXwDr0S1vLxPqJdkV3HEsZlLgXwnDqFmENJxySIU kMj2LoFazM0fweJ2YtpOC72CVnTwKziOcareLGKHhaUI9d1kWcR9Y4C5Bu7W2bpYwGFS 0ifw== X-Gm-Message-State: AOJu0YzGDJ2MWUqcc1Im4G5+mFq2bxIISsx37rrQXw0Gpn7pkt7pg/z+ WUF0lUWwpDtNxdpAI0+VA15IXWKD+7NSc1l13Qv8wE5MMTSOi17xW10KNg== X-Google-Smtp-Source: AGHT+IFlXucXrk6/krEUD7rPL54Ycn5IEKM5aN5Y1yXLrftsgdCQnJsu7DLqNkm+KtkkO2PfBMhn2A== X-Received: by 2002:a05:620a:2994:b0:79e:f878:7ffb with SMTP id af79cd13be357-7a688d2fea1mr734844885a.9.1724451825830; Fri, 23 Aug 2024 15:23:45 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f41f507sm218860385a.132.2024.08.23.15.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 15:23:45 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v4 1/8] doc: Document station Affinities property Date: Fri, 23 Aug 2024 15:23:32 -0700 Message-Id: <20240823222339.328006-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 d9c94e01..2d1f6dcd 100644 --- a/src/iwd.config.rst +++ b/src/iwd.config.rst @@ -130,6 +130,22 @@ The group ``[General]`` contains general settings. This value can be used to control how aggressively **iwd** roams when connected to a 5GHz access point. + * - CriticalRoamThreshold + - Value: rssi dBm value, from -100 to 1, default: **-80** + + The threshold (for 2.4GHz) at which IWD will roam regardless of the + affinity set to the current BSS. If the connected BSS has affinity + (set in Station's Affinities list) the roam threshold will be lowed to + this value and IWD will not attempt to roam (or roam scan) until either + the affinity is cleared, or the signal drops below this threshold. + + + * - CriticalRoamThreshold5G + - Value: rssi dBm value, from -100 to 1, default: **-82** + + This has the same effect as ``CriticalRoamThreshold``, but for the 5GHz + band. + * - RoamRetryInterval - Value: unsigned int value in seconds (default: **60**) From patchwork Fri Aug 23 22:23:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13776084 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.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 691961925AF for ; Fri, 23 Aug 2024 22:23:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451829; cv=none; b=RGg9+PGrV533RdcfJywTdZbXXIcfh/+VUrpR92tnUyxXFLzz7l41clFfbKAybQRyi0Zf36NpZ/WmBPa8BkuIpAUtHqTUNim3bXOMI1sCOrQbQ6Zwn3EM5nED5EaBgOWViFd1nUNWHWkB5r9Wqv4czTPsrOYuyjsW1mfbaPEqSc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451829; c=relaxed/simple; bh=XuOeFsddTnDIC956A+nIPyDg4sOeSaUqYh8SjqKWg7U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lRW3L4fVqmBsYdOi6OnR6rr31cxQ+WKnCOwKN+z3aaNOdC8D2T99kWBksTV+hQg779EpS2+FaS89qjnPTOon2cjWD0imDk2evyPVR8xlyrSE8WtNsYobUFnWHEGIkIgtnIuil/n0ZjFpYZsokDQLSDtSZQ9RIG1oLNlYFBUzwAY= 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=kOpbd66T; arc=none smtp.client-ip=209.85.222.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="kOpbd66T" Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-7a1d6f4714bso234191185a.1 for ; Fri, 23 Aug 2024 15:23:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724451827; x=1725056627; 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=1tQJvtRW2PSFTZ4r1iQQLiNM4sfBKdJoT8tMjFV4cTk=; b=kOpbd66Tc9YW8lVk02rxgUNW7XX7W522uBnlvF+9rzyt1TyetEdF5oPSH3dNW5OqGR fWIe4sJ4sOdhQvwi+ITHK/Esl7JuhvceOatTgTNmbtJYfaSavKoe+UimFe6sVru6HHh0 tL19kHP4C7mzKepxz0eqAhgzjpqSdj2K9kkZKgRlzCy7CaIICKHmzYqVde6x2cCOcVOb vC3G2G0PLIL+zIGARL45oiyrEqTqjoMDRSr86scPULic6H+EqNuOanv9Ax52d2mUsY8Y EwADjzvo38ffpx8e1cfMq7nw/OwsHDW27iYaibhfhdbS3C3ZNMRMXNapu0/fU7Hi/6b6 i/kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724451827; x=1725056627; 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=1tQJvtRW2PSFTZ4r1iQQLiNM4sfBKdJoT8tMjFV4cTk=; b=Ttp922YxqnU7ADaYMVeUuZXWkL1qTz5rE2dG3BgTzGBiYGLN/z3KDR4TvufYipqNjW aIinzoSnDPAYYK97QTrwsm34qgj4z5oqAfMzg4ljsC8OJ2ul6BBCprWy/JoBqx3+gPYb kRBSr/954CCBX0pYOEX72v+KY3omdr/iBvbK7rwc10ci6KEpO+6Aw1DvFe91glAbigY9 CCMlO9orxa9SjfJcAfH58Ta3/XxA/tSNwtnepBEQx1hwIWtiBj6CYM1E5jHInwt/x/Lm tlQa4V21gPieogC6Ox2J2IwbnvWF3ILQAW2PrCciZnxVHcd7vwY3xueUdkoExBpzDhE1 nBVg== X-Gm-Message-State: AOJu0YzZv5fRspcBAZQax+de//va0/kFBFoCqEej7mgx7Sp3E8277+MH f2UbxPVxjmGI0Jtw8FvQzjuMvwyfPlI9m1UQhByXTze0gutIGD/UW3MaOA== X-Google-Smtp-Source: AGHT+IH6JA9XJ5HcNuKwQL5SqPvFRxiGbCE5qMOdpy4drAjjlWahPaxkhWwS4ZoudkrXUDMuRma+BA== X-Received: by 2002:a05:620a:1a8b:b0:7a6:50a4:291c with SMTP id af79cd13be357-7a688d3b540mr645036085a.14.1724451826968; Fri, 23 Aug 2024 15:23:46 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f41f507sm218860385a.132.2024.08.23.15.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 15:23:46 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v4 2/8] netdev: define netdev settings in netdev.h Date: Fri, 23 Aug 2024 15:23:33 -0700 Message-Id: <20240823222339.328006-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823222339.328006-1-prestwoj@gmail.com> References: <20240823222339.328006-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Following knownnetworks, this moves the settings into a header file which is easier to maintain/read. --- src/netdev.c | 8 ++++---- src/netdev.h | 5 +++++ 2 files changed, 9 insertions(+), 4 deletions(-) v4: * Fix typos diff --git a/src/netdev.c b/src/netdev.c index 494e46a5..e0121095 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -6264,16 +6264,16 @@ static int netdev_init(void) goto fail_netlink; } - if (!l_settings_get_int(settings, "General", "RoamThreshold", + if (!l_settings_get_int(settings, NETDEV_ROAM_THRESHOLD, &LOW_SIGNAL_THRESHOLD)) LOW_SIGNAL_THRESHOLD = -70; - if (!l_settings_get_int(settings, "General", "RoamThreshold5G", + if (!l_settings_get_int(settings, NETDEV_ROAM_THRESHOLD_5G, &LOW_SIGNAL_THRESHOLD_5GHZ)) LOW_SIGNAL_THRESHOLD_5GHZ = -76; - rand_addr_str = l_settings_get_value(settings, "General", - "AddressRandomization"); + rand_addr_str = l_settings_get_value(settings, + NETDEV_ADDRESS_RANDOMIZATION); if (rand_addr_str && !strcmp(rand_addr_str, "network")) mac_per_ssid = true; diff --git a/src/netdev.h b/src/netdev.h index db0440d0..c48b2c38 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -29,6 +29,11 @@ struct eapol_sm; struct mmpdu_header; struct diagnostic_station_info; +#define GENERAL "General" +#define NETDEV_ADDRESS_RANDOMIZATION GENERAL, "AddressRandomization" +#define NETDEV_ROAM_THRESHOLD GENERAL, "RoamThreshold" +#define NETDEV_ROAM_THRESHOLD_5G GENERAL, "RoamThreshold5G" + enum netdev_result { NETDEV_RESULT_OK, NETDEV_RESULT_AUTHENTICATION_FAILED, From patchwork Fri Aug 23 22:23:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13776085 Received: from mail-qk1-f180.google.com (mail-qk1-f180.google.com [209.85.222.180]) (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 C2A7819258E for ; Fri, 23 Aug 2024 22:23:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451831; cv=none; b=IXGxj1RmX2bqaPbrae/IZVsoIf2Gcs/1mmzkd4Ki1m+OJefvF8VPVLpYpzBNGhebstHeFRszFHYamBh/4Fmcmdw7UzDfuCC8s0EkwlXr2KH01zbhVYmFumfontc3vYYqj2pI47tzc9C0+kwS3DP8v2CwLQNaBLV2lFjzc4fUqc0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451831; c=relaxed/simple; bh=z+bl8P9tasSSgCV215ezjlQmwF+2dwLJO7xYWwGBxw4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rJN9rggIRtBVW71doqRAoy/u+I9n6ycgUlsXTxTufmN/+MuaWGBKEQdIKwIJ0Ni0KdryxqLNJ5cbZl3jAfMZk97sOXJHpv2uA+V+2oA5+4VuC9Addl9zwLIxlb6aSgIR+5N3gM3I4xuHjfuesLxPf7K4lgtYK4CaZGTonbmGEyY= 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=IGqjgwhf; arc=none smtp.client-ip=209.85.222.180 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="IGqjgwhf" Received: by mail-qk1-f180.google.com with SMTP id af79cd13be357-7a1dac7f0b7so151879785a.0 for ; Fri, 23 Aug 2024 15:23:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724451828; x=1725056628; 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=JROQ45N1DyPYU2xjIBnwVw8kQ1vHiF8U1ksLO+jJbZg=; b=IGqjgwhfInRGQGIyzYLzsr8s04L5SGqJrbqdpkHxZg/tp1fqfrItpd17r3mtKS1EXG KTiqPMPGS/FlaT/YRr//Q41iEWI4VbhTfWsIA4oQ/Ne5fPS5OeOnPvBkrNpet7RaOmfD 68NF5jkP+1noP2MtfrU1BmtWhvsncUcpk+M1UYDXnW30lL12kSh4F1ITEpZUbQ06CbOW iIlFr2SccJHR+j5g1sPM0RnScRUJeL0YEMa88VIRzXN9ax0RlkfntVsrajQWZfrr+co3 uOsrl4M2aavKCthDZIKNW+OP+hCz/JQwlwSsZeP8AMJFRwGpUTB/kAEYgPF3wVOM4+Oh GWZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724451828; x=1725056628; 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=JROQ45N1DyPYU2xjIBnwVw8kQ1vHiF8U1ksLO+jJbZg=; b=t+oHWTaRyxCDvw0XDiLfCkKNOej3P8AHbt/s/+ickd+ky9XhIkzn4NrOqEpLdDv+wn dg4vjJbuDJXCAF30eVPBK4kLJciykkugE2eDU76FkdmwooV5bd6qAUgjGJAhf60JjqMZ la3HtUksM6OS7KxN6A1yceUpmnQ3pJgsB1i1pAxLVvxuLCOlXgNu6uGCYyjaVUq3SrNc ZCZb+XgYbgPj89y1yf8fFiA41m5oCiPRfyN+nqyWkyw/tTp0kj03p65mCPtWn1ZU65Bt AN02dU6i7LpjSvaBU1xE97+XIM1FCj8rMDP9joMeMkHaGsyJ5ljK9MgLfIT8lErj098n fDJQ== X-Gm-Message-State: AOJu0YxLVqD3Fmb2Hpj82l49V/+URd9eHezNiOCqbxifzMt72d1wOp5o N10/Rnb/ZgDliii9xMyxFqLvZp7HeqocBii4lcYB0hgc1ODQP/YkZbhGNQ== X-Google-Smtp-Source: AGHT+IGcXzaqCnrMzWy5J5uuLEzmgMzGwKzEM5kJPhqmVxTkXjomNWZKsXJf9I7UuNSIvaSjV3e1UA== X-Received: by 2002:a05:620a:1a9e:b0:79f:1873:5463 with SMTP id af79cd13be357-7a6896e3d4amr472894185a.6.1724451828321; Fri, 23 Aug 2024 15:23:48 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f41f507sm218860385a.132.2024.08.23.15.23.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 15:23:47 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v4 3/8] netdev: store signal threshold in netdev object, not globally Date: Fri, 23 Aug 2024 15:23:34 -0700 Message-Id: <20240823222339.328006-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823222339.328006-1-prestwoj@gmail.com> References: <20240823222339.328006-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 e0121095..1f1b9400 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -172,6 +172,9 @@ struct netdev { struct netdev_ext_key_info *ext_key_info; + int low_signal_threshold; + int low_signal_threshold_5ghz; + bool connected : 1; bool associated : 1; bool operational : 1; @@ -206,6 +209,9 @@ static struct l_genl_family *nl80211; static struct l_queue *netdev_list; static struct watchlist netdev_watches; static bool mac_per_ssid; +/* Threshold RSSI for roaming to trigger, configurable in main.conf */ +static int LOW_SIGNAL_THRESHOLD; +static int LOW_SIGNAL_THRESHOLD_5GHZ; static unsigned int iov_ie_append(struct iovec *iov, unsigned int n_iov, unsigned int c, @@ -1058,10 +1064,6 @@ struct netdev *netdev_find(int ifindex) return l_queue_find(netdev_list, netdev_match, L_UINT_TO_PTR(ifindex)); } -/* Threshold RSSI for roaming to trigger, configurable in main.conf */ -static int LOW_SIGNAL_THRESHOLD; -static int LOW_SIGNAL_THRESHOLD_5GHZ; - static void netdev_cqm_event_rssi_threshold(struct netdev *netdev, uint32_t rssi_event) { @@ -1089,8 +1091,9 @@ static void netdev_cqm_event_rssi_value(struct netdev *netdev, int rssi_val) { bool new_rssi_low; uint8_t prev_rssi_level_idx = netdev->cur_rssi_level_idx; - int threshold = netdev->frequency > 4000 ? LOW_SIGNAL_THRESHOLD_5GHZ : - LOW_SIGNAL_THRESHOLD; + int threshold = netdev->frequency > 4000 ? + netdev->low_signal_threshold_5ghz : + netdev->low_signal_threshold; if (!netdev->connected) return; @@ -3585,8 +3588,9 @@ static struct l_genl_msg *netdev_build_cmd_cqm_rssi_update( uint32_t hyst = 5; int thold_count; int32_t thold_list[levels_num + 2]; - int threshold = netdev->frequency > 4000 ? LOW_SIGNAL_THRESHOLD_5GHZ : - LOW_SIGNAL_THRESHOLD; + int threshold = netdev->frequency > 4000 ? + netdev->low_signal_threshold_5ghz : + netdev->low_signal_threshold; if (levels_num == 0) { thold_list[0] = threshold; @@ -6163,6 +6167,8 @@ struct netdev *netdev_create_from_genl(struct l_genl_msg *msg, l_strlcpy(netdev->name, ifname, IFNAMSIZ); netdev->wiphy = wiphy; netdev->pae_over_nl80211 = pae_io == NULL; + netdev->low_signal_threshold = LOW_SIGNAL_THRESHOLD; + netdev->low_signal_threshold_5ghz = LOW_SIGNAL_THRESHOLD_5GHZ; if (set_mac) memcpy(netdev->set_mac_once, set_mac, 6); From patchwork Fri Aug 23 22:23:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13776086 Received: from mail-vs1-f42.google.com (mail-vs1-f42.google.com [209.85.217.42]) (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 6C6F11C871D for ; Fri, 23 Aug 2024 22:23:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451833; cv=none; b=Q8Mdb6o3pJLv/RoqcuRfnHsEfgBpSdmiAwQlMn8Pn1aWrDUbqgwYaejw9CqfayTU9X0KPecwNQp/3Ghrv42r38zWiy5VsxwL8X82GDKj1YChOLhIqYrWRzxQfyOWRcSAa74AQH/a0vzGXzn0U3DlYjpwZqELpi/jPPYV/cJIcXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451833; c=relaxed/simple; bh=zfsmCn4z9Iry8iifG1YA/kr+DiQISc/q3zC2yV47waY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=PkaxOnyihJ4NXIB+ySKpkiROUOIP4ZgwUREabfarXT8+gyRIFnkLtxmCRKBjH00NdAIa3lwSKoF9hw8lId53bf+n3fMDJ4fFWTGMtpVqQFIR+riIWeSXJg5dmXDtQaXpEV2E2hGnAWPl/ydxV9alLh3Y+h3scEKnKAEYAwbjkFw= 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=KxTDrNNe; arc=none smtp.client-ip=209.85.217.42 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="KxTDrNNe" Received: by mail-vs1-f42.google.com with SMTP id ada2fe7eead31-498eb25d247so703400137.0 for ; Fri, 23 Aug 2024 15:23:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724451830; x=1725056630; 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=X+HZyfslDqDuP15B/xamTRRdgwKfXFoD+w25dHISu2A=; b=KxTDrNNe3RJJZvE2DRuHB6MulNuXwGP9erBao0Wj1XuKFDNTXFHY9mdQxEfYnS2T1I Nz8Ng013jUfc1IZ7mpGPIW1mqyfj48CI4XJ9opekc58Pyqe1TVH7cWVRpgHY4boHnCHN pXPwU87tQyNsWdClLWLp/j/YaqEBS+7urzcfwAjYZtsYXLDd8Do/zambyfHct1DF4kto 1PzsqMCscZrLeKXXuSII6a1Mr3jI5YVUHqGa40gMfB/kSggNNutJSVFKwgLylz6589fe pu3Ebc6pcA23IrDKJhAiQ5EFSubHRHWTmvhQuLBNLpMEd1pYeRgCuNkMZThJPF2PvOq+ lPXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724451830; x=1725056630; 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=X+HZyfslDqDuP15B/xamTRRdgwKfXFoD+w25dHISu2A=; b=niyzHX9hB8KiGbuFHLRcs7dW0KpEPvwO5T8R0gm36BoiDVsvhSN1DuYQpPIyaHF+hQ DfVtIsz7XUJ3tQTFWJmVPpFDFTfF0sartvUyt8NlBFGrMvwV18MGB91SIanSj7LcNOYL Zfwba0Jw6BV1OqnCbzyFHwFbS7bKeyhIpqCvVDdbaYwRbSIYBozDzKqP3DHQC5azXimD pD1hpmmBpbRGCmJGU6HdtLnDMAJ+SRWQK8pWc7t6eDCcOdgR+gowXOl0AXN5zznDgTgY Cxp6po6b4fvEZCjkYUKG8d+3Up76+K45afrMI5/jyiWA5r/Cyvt3F3gvjCRIKbT0Rqai HwoQ== X-Gm-Message-State: AOJu0YxiWr0xBOfsQBtmLq5YW7wbf1MPxVGupRUCGCOHFUVB3ZKzScfp WNUhD7LjgnXeKVmBm8yg50QoOz4APhqoUz9ywUCtbVbJxvHsvD2+mv+mhg== X-Google-Smtp-Source: AGHT+IHJU9J0a41xDFM9OFvaLjslJFWql88T2l+j2bO2KBFY9I4yTJB69rpz/PDA2zW5O1YcdBCm+A== X-Received: by 2002:a05:6102:38cd:b0:493:c028:bee0 with SMTP id ada2fe7eead31-498f465a262mr3529729137.15.1724451830028; Fri, 23 Aug 2024 15:23:50 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f41f507sm218860385a.132.2024.08.23.15.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 15:23:49 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v4 4/8] netdev: add critical signal threshold level Date: Fri, 23 Aug 2024 15:23:35 -0700 Message-Id: <20240823222339.328006-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823222339.328006-1-prestwoj@gmail.com> References: <20240823222339.328006-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 | 4 ++++ 2 files changed, 55 insertions(+) diff --git a/src/netdev.c b/src/netdev.c index 1f1b9400..73fbf0c1 100644 --- a/src/netdev.c +++ b/src/netdev.c @@ -212,6 +212,8 @@ static bool mac_per_ssid; /* Threshold RSSI for roaming to trigger, configurable in main.conf */ static int LOW_SIGNAL_THRESHOLD; static int LOW_SIGNAL_THRESHOLD_5GHZ; +static int CRITICAL_SIGNAL_THRESHOLD; +static int CRITICAL_SIGNAL_THRESHOLD_5GHZ; static unsigned int iov_ie_append(struct iovec *iov, unsigned int n_iov, unsigned int c, @@ -841,6 +843,10 @@ static void netdev_connect_free(struct netdev *netdev) l_genl_family_cancel(nl80211, netdev->get_oci_cmd_id); netdev->get_oci_cmd_id = 0; } + + /* Reset thresholds back to default */ + netdev->low_signal_threshold = LOW_SIGNAL_THRESHOLD; + netdev->low_signal_threshold_5ghz = LOW_SIGNAL_THRESHOLD_5GHZ; } static void netdev_connect_failed(struct netdev *netdev, @@ -3674,6 +3680,39 @@ static int netdev_cqm_rssi_update(struct netdev *netdev) return 0; } +static int netdev_set_signal_thresholds(struct netdev *netdev, int threshold, + int threshold_5ghz) +{ + int current = netdev->frequency > 4000 ? + netdev->low_signal_threshold_5ghz : + netdev->low_signal_threshold; + int new = netdev->frequency > 4000 ? threshold_5ghz : threshold; + + if (current == new) + return -EALREADY; + + l_debug("changing low signal threshold to %d", new); + + netdev->low_signal_threshold = threshold; + netdev->low_signal_threshold_5ghz = threshold_5ghz; + + netdev_cqm_rssi_update(netdev); + + return 0; +} + +int netdev_lower_signal_threshold(struct netdev *netdev) +{ + return netdev_set_signal_thresholds(netdev, CRITICAL_SIGNAL_THRESHOLD, + CRITICAL_SIGNAL_THRESHOLD_5GHZ); +} + +int netdev_raise_signal_threshold(struct netdev *netdev) +{ + return netdev_set_signal_thresholds(netdev, LOW_SIGNAL_THRESHOLD, + LOW_SIGNAL_THRESHOLD_5GHZ); +} + static bool netdev_connection_work_ready(struct wiphy_radio_work_item *item) { struct netdev *netdev = l_container_of(item, struct netdev, work); @@ -3887,6 +3926,8 @@ done: netdev->handshake = hs; netdev->sm = sm; netdev->cur_rssi = bss->signal_strength / 100; + netdev->low_signal_threshold = LOW_SIGNAL_THRESHOLD; + netdev->low_signal_threshold_5ghz = LOW_SIGNAL_THRESHOLD_5GHZ; if (netdev->rssi_levels_num) netdev_set_rssi_level_idx(netdev); @@ -4260,6 +4301,8 @@ int netdev_ft_reassociate(struct netdev *netdev, netdev->event_filter = event_filter; netdev->connect_cb = cb; netdev->user_data = user_data; + netdev->low_signal_threshold = LOW_SIGNAL_THRESHOLD; + netdev->low_signal_threshold_5ghz = LOW_SIGNAL_THRESHOLD_5GHZ; /* * Cancel commands that could be running because of EAPoL activity @@ -6278,6 +6321,14 @@ static int netdev_init(void) &LOW_SIGNAL_THRESHOLD_5GHZ)) LOW_SIGNAL_THRESHOLD_5GHZ = -76; + if (!l_settings_get_int(settings, NETDEV_CRITICAL_ROAM_THRESHOLD, + &CRITICAL_SIGNAL_THRESHOLD)) + CRITICAL_SIGNAL_THRESHOLD = -80; + + if (!l_settings_get_int(settings, NETDEV_CRITICAL_ROAM_THRESHOLD_5G, + &CRITICAL_SIGNAL_THRESHOLD_5GHZ)) + CRITICAL_SIGNAL_THRESHOLD_5GHZ = -82; + rand_addr_str = l_settings_get_value(settings, NETDEV_ADDRESS_RANDOMIZATION); if (rand_addr_str && !strcmp(rand_addr_str, "network")) diff --git a/src/netdev.h b/src/netdev.h index c48b2c38..6299934e 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -33,6 +33,8 @@ struct diagnostic_station_info; #define NETDEV_ADDRESS_RANDOMIZATION GENERAL, "AddressRandomization" #define NETDEV_ROAM_THRESHOLD GENERAL, "RoamThreshold" #define NETDEV_ROAM_THRESHOLD_5G GENERAL, "RoamThreshold5G" +#define NETDEV_CRITICAL_ROAM_THRESHOLD GENERAL, "CriticalRoamThreshold" +#define NETDEV_CRITICAL_ROAM_THRESHOLD_5G GENERAL, "CriticalRoamThreshold5G" enum netdev_result { NETDEV_RESULT_OK, @@ -202,6 +204,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 Fri Aug 23 22:23:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13776087 Received: from mail-qk1-f171.google.com (mail-qk1-f171.google.com [209.85.222.171]) (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 E0BD719258E for ; Fri, 23 Aug 2024 22:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451834; cv=none; b=W/nQUlpm/D36HE886FHaQGPJU6KhdBY94rqZ9SxpIxVyLMh2XYr9RIW92Me+Fdtwrrr80uqFwu2X8yrs6PwNG+B6mAlPSaWd/n5iuKArJUBwoHEltczv9dspA0n6ySFLJBc3lkdBlSef24EnACcDFNtVABEuZllFIbjcdFExPIU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451834; c=relaxed/simple; bh=8GJp6LIloV0RHrttszdpIwblnKc6uljkf1d2c0MC+/s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hUJEv7DmKlRMAJo9dbr1683+K03FSDO1t3JyKxJcMhQHFQgJFZLpZXn9emUzRiGhkqTzXhtA9k2Jo9L+YH3wfkJKCEhVrMxqb4DECR3KT4Ew+FDMgJpyuSR4gWDSzxmZ8zYvqNthWYV6JJJ3YmZ13SaYoFpbOA1ek0uhXlYHZZw= 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=d6ICe/+K; arc=none smtp.client-ip=209.85.222.171 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="d6ICe/+K" Received: by mail-qk1-f171.google.com with SMTP id af79cd13be357-7a501dd544eso151324785a.2 for ; Fri, 23 Aug 2024 15:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724451831; x=1725056631; 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=Do/QJpPtvafMOYYsDYzOgXAyP1tN33OB7hrK9QH18sw=; b=d6ICe/+KO89wBzHGPs64v8976u7nhjVY/2LYhSfzprtNt9xJf+l8YOQ6gWvwjw/d2n ydqXI0pCmXBC3zvpz1OZA8EixzO+CcBy5Q5d0Tn1EYiXgGpeSRl8UMfnL2b++X71Xycu 87cqDxH+ZejI5MMSaCIf+lsFC75Vz0mUQCb22sHhqK3dAOyHBCuxpZjuB6CDrMJ14+eN mcqSgt6w9dLjalY3fG7Miz1Yx/Z2ZoQExGMnJl2LlJQPbkBhkJTLvswmWp/8V5qT3qVk VjurgkY92TkWNJocuYayjeehG/wDaSP9A540shPfLM4jvgC1xS5yPdpvan3xiGjB9sNF BNtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724451831; x=1725056631; 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=Do/QJpPtvafMOYYsDYzOgXAyP1tN33OB7hrK9QH18sw=; b=dgmj/nXmCcYFlCMMWK+WBIXnPA6DolCwb2H5UMYAy+BTvwvqnkplGndR2UH/MJJH4O +y5s4WM4meQ7jLB+JmVDtlr9OqL5jMf4e4ihzptmtwcPjKKgria3k000RLt9hnUdvvPJ B9bonAORzRqfkKXAh1SffIHrWS0ZFCS1RSPB/kFXSESTmvYBOzjZMDxzKh1FOQ7WiQI6 pPAvXlfGbZtsER/wozG1y9XB6udvDx/KLjw6FCPnapNP8gN2KixYLbhokvwjGwcOJbt5 O5S4e3Z4mqO/tPs2xPNvwVcbzoV5KQ6DuLnPEYszEaMk301g+1VvuRfDs2/QldPssylD hO/g== X-Gm-Message-State: AOJu0YwRR+m24jc8BmzEj0Hy0zS/XD8PKszVHR5GO2n0zlpHsAXwKz3S 5FnP5Wu57P+EDeMCq1YlpjPapAI4jzF8o3fd1YJOfQDkcVodbOS2InHXSQ== X-Google-Smtp-Source: AGHT+IHgbJzaOfRPjRNnMg+LuaLgQxpmOlCvidvGCKa6VqOZ0daliTyz4D/TrOfj/NsX6fyRkj7Gqw== X-Received: by 2002:a05:620a:24c6:b0:7a1:dfe4:5708 with SMTP id af79cd13be357-7a6896fc56emr361528185a.16.1724451831174; Fri, 23 Aug 2024 15:23:51 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f41f507sm218860385a.132.2024.08.23.15.23.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 15:23:50 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v4 5/8] station: add Affinities DBus property Date: Fri, 23 Aug 2024 15:23:36 -0700 Message-Id: <20240823222339.328006-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823222339.328006-1-prestwoj@gmail.com> References: <20240823222339.328006-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This property will hold an array of object paths for BasicServiceSet (BSS) objects. For the purpose of this patch only the setter/getter and client watch is implemented. The purpose of this array is to guide or loosly lock IWD to certain BSS's provided that some external client has more information about the environment than what IWD takes into account for its roaming decisions. For the time being, the array is limited to only the connected BSS path, and any roams or disconnects will clear the array. The intended use case for this is if the device is stationary an external client could reduce the likelihood of roaming by setting the affinity to the current BSS. --- src/station.c | 145 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 145 insertions(+) diff --git a/src/station.c b/src/station.c index 30a1232a..c72d42ae 100644 --- a/src/station.c +++ b/src/station.c @@ -128,6 +128,10 @@ struct station { uint64_t last_roam_scan; + struct l_queue *affinities; + unsigned int affinity_watch; + char *affinity_client; + bool preparing_roam : 1; bool roam_scan_full : 1; bool signal_low : 1; @@ -449,6 +453,14 @@ static const char *station_get_bss_path(struct station *station, return __network_path_append_bss(network_path, bss); } +static bool match_bss_path(const void *data, const void *user_data) +{ + const char *path1 = data; + const char *path2 = user_data; + + return !strcmp(path1, path2); +} + static bool station_unregister_bss(struct station *station, struct scan_bss *bss) { @@ -457,6 +469,8 @@ static bool station_unregister_bss(struct station *station, if (L_WARN_ON(!path)) return false; + l_queue_remove_if(station->affinities, match_bss_path, path); + return l_dbus_unregister_object(dbus_get_bus(), path); } @@ -1740,6 +1754,13 @@ static void station_enter_state(struct station *station, station_set_evict_nocarrier(station, true); station_set_drop_neighbor_discovery(station, false); station_set_drop_unicast_l2_multicast(station, false); + + if (station->affinity_watch) { + l_dbus_remove_watch(dbus_get_bus(), + station->affinity_watch); + station->affinity_watch = 0; + } + break; case STATION_STATE_DISCONNECTING: case STATION_STATE_NETCONFIG: @@ -1747,6 +1768,12 @@ static void station_enter_state(struct station *station, case STATION_STATE_ROAMING: case STATION_STATE_FT_ROAMING: case STATION_STATE_FW_ROAMING: + if (station->affinity_watch) { + l_dbus_remove_watch(dbus_get_bus(), + station->affinity_watch); + station->affinity_watch = 0; + } + station_set_evict_nocarrier(station, false); break; } @@ -4520,6 +4547,118 @@ static bool station_property_get_state(struct l_dbus *dbus, return true; } +static bool station_property_get_affinities(struct l_dbus *dbus, + struct l_dbus_message *message, + struct l_dbus_message_builder *builder, + void *user_data) +{ + struct station *station = user_data; + const struct l_queue_entry *e; + + if (!station->connected_network) + return false; + + l_dbus_message_builder_enter_array(builder, "o"); + + for (e = l_queue_get_entries(station->affinities); e; e = e->next) { + const char *path = e->data; + + l_dbus_message_builder_append_basic(builder, 'o', path); + } + + l_dbus_message_builder_leave_array(builder); + + return true; +} + +static void station_affinity_disconnected_cb(struct l_dbus *dbus, + void *user_data) +{ + struct station *station = user_data; + + l_dbus_remove_watch(dbus_get_bus(), station->affinity_watch); + station->affinity_watch = 0; + + l_debug("client that set affinity has disconnected"); +} + +static void station_affinity_watch_destroy(void *user_data) +{ + struct station *station = user_data; + + l_free(station->affinity_client); + station->affinity_client = NULL; + + l_queue_destroy(station->affinities, l_free); + station->affinities = NULL; + + l_dbus_property_changed(dbus_get_bus(), + netdev_get_path(station->netdev), + IWD_STATION_INTERFACE, "Affinities"); +} + +static struct l_dbus_message *station_property_set_affinities( + struct l_dbus *dbus, + struct l_dbus_message *message, + struct l_dbus_message_iter *new_value, + l_dbus_property_complete_cb_t complete, + void *user_data) +{ + struct station *station = user_data; + struct l_dbus_message_iter array; + const char *sender = l_dbus_message_get_sender(message); + const char *path; + struct l_queue *new_affinities; + + if (!station->connected_network) + return dbus_error_not_connected(message); + + if (!station->affinity_watch) { + station->affinity_client = l_strdup(sender); + station->affinity_watch = l_dbus_add_disconnect_watch(dbus, + sender, + station_affinity_disconnected_cb, + station, + station_affinity_watch_destroy); + } else if (strcmp(station->affinity_client, sender)) { + l_warn("Only one client may manage Affinities property"); + return dbus_error_not_available(message); + } + + if (!l_dbus_message_iter_get_variant(new_value, "ao", &array)) + return dbus_error_invalid_args(message); + + new_affinities = l_queue_new(); + + while (l_dbus_message_iter_next_entry(&array, &path)) { + struct scan_bss *bss = l_dbus_object_get_data(dbus_get_bus(), + path, + IWD_BSS_INTERFACE); + + /* + * TODO: For now only allow the affinities array to contain the + * connected BSS path. Any other values will be rejected. + * This could change in the future. + */ + if (bss != station->connected_bss) { + l_queue_destroy(new_affinities, l_free); + return dbus_error_invalid_args(message); + } + + l_queue_push_head(new_affinities, l_strdup(path)); + } + + l_queue_destroy(station->affinities, l_free); + station->affinities = new_affinities; + + l_dbus_property_changed(dbus, netdev_get_path(station->netdev), + IWD_STATION_INTERFACE, "Affinities"); + + complete(dbus, message, NULL); + + return NULL; +} + void station_foreach(station_foreach_func_t func, void *user_data) { const struct l_queue_entry *entry; @@ -4842,6 +4981,9 @@ static void station_free(struct station *station) l_queue_destroy(station->roam_bss_list, l_free); + if (station->affinity_watch) + l_dbus_remove_watch(dbus_get_bus(), station->affinity_watch); + l_free(station); } @@ -4878,6 +5020,9 @@ static void station_setup_interface(struct l_dbus_interface *interface) station_property_get_scanning, NULL); l_dbus_interface_property(interface, "State", 0, "s", station_property_get_state, NULL); + l_dbus_interface_property(interface, "Affinities", 0, "ao", + station_property_get_affinities, + station_property_set_affinities); } static void station_destroy_interface(void *user_data) From patchwork Fri Aug 23 22:23:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13776088 Received: from mail-qk1-f175.google.com (mail-qk1-f175.google.com [209.85.222.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D715D1C871D for ; Fri, 23 Aug 2024 22:23:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451835; cv=none; b=Fo8008JxluLNZcDxzRinx3vS+v+iMkS8h6y3hwcQhjfJRvB3q6VkskZogPeSb8j7SxYFJA5aLCwjwFqjgbo5lTdJABuABlvkBAxRja+Nxpiz5mZjoV1rxQxq+EmqOq4oDZsvZBkfTZ/Hw+9LsRWo9EL42tlJVOG04GuKV4q9Qqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451835; c=relaxed/simple; bh=77WYaDfYJJhEeptfZjfnvcSpDbjqVudeC27c8zeK0+g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gf6TeHoX7KLrmUsoGkbuUGiVeXAWwmHakV/MgbRpe+qwUQAHT13fjYcXBT8ANO6eOZPP1Cv9IucCKGifF1zcA1qPuW/1rwnIbjIgx6qc5u/3cE08IlE6A1IfvUGm8vEfLbqo3t86/aLXAhIdpMFZ08hW5d7iRos1SHY/krgqRXA= 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=a5Cx/yba; arc=none smtp.client-ip=209.85.222.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a5Cx/yba" Received: by mail-qk1-f175.google.com with SMTP id af79cd13be357-7a4df9dc885so163682785a.0 for ; Fri, 23 Aug 2024 15:23:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724451832; x=1725056632; 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=WhCvMDPW8lt7t7wlMZm6/J0hw/xGPZvrfOiiaITr7Ak=; b=a5Cx/yba8nmMwrG/smD+/PEpYoWSCRgsauUDdUMRMzPJbF4uiGR7jbh25S8VE08b+9 DEsFvhkA5eVlCgDqsZx5WrL9dBLfdXp6M2V2/EwEdntyF/s9T3j6mPHzNhyFpwHYMhHM TQy7UrVa7FmbXqK9AswGduXlC9IRih/rERMzA0fzdKA4Hjzre5YwWTgyioX9dxCv3/WE A5/WFBTZg7TVMCy8XX/v+OBbBGM28PvqtNuwksT8JFA0BuZ0J+9QTVOAe+eHox39mvVO /d5vqObUwNg+zR/3HKfC7jk3hFAq8VFHTL0RZ51SEacJJoyWvyCNNXnqpmH9ILEbbPcV GGvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724451832; x=1725056632; 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=WhCvMDPW8lt7t7wlMZm6/J0hw/xGPZvrfOiiaITr7Ak=; b=kL3Rf/2kg7LuPgXNFhO4JAcKa0uE9rIWILEr1YRW76vY//EM06FZtJeuSvTGJjZs2B mOT85TJ2aRFgEeMg5PdUyNfZ65VjkfXU2xd36gxPM0l4MlJvpAkIfdLrxgWiIOOui0cF SSAkR+xeQnHy6nEAM0P2ZljUuoxy+U9K4Nlt78MBXh7ZGZMy5LvnEpHVapOVIj7WRL75 7VYS12LjkuQTPLovGRFztbnIJOPBDtatyDnxN5DHUBVBouHJnQT5gI6UvT6KAHHerJmv tOeF+JX75QdHrEavICWeIAlbooYbmYNOqBJfjTZg+ZEEXrIMIyxTu/P8w+yNNbiM76h8 GHFw== X-Gm-Message-State: AOJu0Ywdz2VaedkL0bq48Smd5kXmtQaOp6/59FjYSj48yTckHG5Zhgg8 89arxYuIRFfeTyUDv+oLoUwoFGdy0Ma4TYkvYsQflkNYXulemMHYL/pCRw== X-Google-Smtp-Source: AGHT+IGoMaFYtVnqv9LWIRVnA7XbAe5JzwPwIOxavIZUB5PgPyC0ejSaI9PZwaUk4mawTcZsYmeD5Q== X-Received: by 2002:a05:620a:178c:b0:7a3:505f:62ec with SMTP id af79cd13be357-7a67d3fdd0bmr1482303485a.10.1724451832641; Fri, 23 Aug 2024 15:23:52 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f41f507sm218860385a.132.2024.08.23.15.23.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 15:23:52 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v4 6/8] station: Use Affinities property to change roaming threshold Date: Fri, 23 Aug 2024 15:23:37 -0700 Message-Id: <20240823222339.328006-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823222339.328006-1-prestwoj@gmail.com> References: <20240823222339.328006-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 c72d42ae..ca0b5329 100644 --- a/src/station.c +++ b/src/station.c @@ -4580,6 +4580,9 @@ static void station_affinity_disconnected_cb(struct l_dbus *dbus, station->affinity_watch = 0; l_debug("client that set affinity has disconnected"); + + /* The client who set the affinity disconnected, raise the threshold */ + netdev_raise_signal_threshold(station->netdev); } static void station_affinity_watch_destroy(void *user_data) @@ -4609,6 +4612,7 @@ static struct l_dbus_message *station_property_set_affinities( const char *sender = l_dbus_message_get_sender(message); const char *path; struct l_queue *new_affinities; + bool lower_threshold = false; if (!station->connected_network) return dbus_error_not_connected(message); @@ -4645,6 +4649,8 @@ static struct l_dbus_message *station_property_set_affinities( return dbus_error_invalid_args(message); } + lower_threshold = true; + l_queue_push_head(new_affinities, l_strdup(path)); } @@ -4654,6 +4660,17 @@ static struct l_dbus_message *station_property_set_affinities( l_dbus_property_changed(dbus, netdev_get_path(station->netdev), IWD_STATION_INTERFACE, "Affinities"); + /* + * If affinity was set to the current BSS, lower the roam threshold. If + * the connected BSS was not in the list raise the signal threshold. + * The threshold may already be raised, in which case netdev will detect + * this and do nothing. + */ + if (lower_threshold) + netdev_lower_signal_threshold(station->netdev); + else + netdev_raise_signal_threshold(station->netdev); + complete(dbus, message, NULL); return NULL; From patchwork Fri Aug 23 22:23:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13776089 Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21BC719258E for ; Fri, 23 Aug 2024 22:23:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.217.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451836; cv=none; b=GdlknQX+SvxCOQQOGGzc+WoRx4rNVzMlnSu6T44VBnoSpavWKiG/gdX21VcV9rEvvM7jSCvLs64zHhTVeTz+rUtzVIVC1OD+ZQY3gbrEg967nX2QjIGKaRoJgRrPmCQmk2aIA6+bI9kNt22tSXMI1684vYXlVIv9IDmWnjB2WDY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451836; c=relaxed/simple; bh=1pYxZdt/cb6QaZROUOt/UXNKrd4LBk55ZWX1Jek2/YY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=mtSPJyw/TAf94SRqGIAqnBbTv5oeG6B0pifDX6cl+U9F5cb/FJNGshRRqijtKlGkTbw4afzxrSByfTgaQIRJKf2ddnR9iqonI2LhrLkTxuZCkZYjclXEE/Lu6WyHj2qpWe00yvKhyupKvLGKnMugU+2oTTzV9ZVQXhF9WQ445+w= 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=X3xWc3fA; arc=none smtp.client-ip=209.85.217.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="X3xWc3fA" Received: by mail-vs1-f43.google.com with SMTP id ada2fe7eead31-498cfbc0b05so878841137.1 for ; Fri, 23 Aug 2024 15:23:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724451834; x=1725056634; 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=X3xWc3fAVYJPvetxdCOBTMP3IdhMyi0jbYsfPMruAftIW9NPQWQEzUWIkLGxOvU5y/ zov3TJyjmVgxZTPofKWBuDimzvH5+mLRPcai9TTt9Im1bUKLX94NXrqSuLhgPA5mRTGJ ReHaaA3l90r+duohou44lGq+a8YR5dzdTmaH34zDT4m75AwE/5Q/m/VB4DcSVtjzIued W4C/s+puXrDyEa6OmDwZac9DxcZO0CjbYdC0YY455O4Gq1DHrVJpbs3bLtHR1zwdCkl4 XfB338+E075FiuSkcqLFdwwI6zil8G3xB9onWI/sDpixUwKDS7hVLy78Wd2EnTeMWt3B i+3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724451834; x=1725056634; 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=H0+Po2qML5F7z6nM6JZsRIItxB2S9XTV8HH1nwyXC6KTQffKbAitoy/ivK7U2/iI6e 47o9VPOG/W/4eDyvMV3YTYJIRp91rXAU19DYx9Iak86/hTJaJkmkeBcwMS5nTHYK30aE WUe1z0Wud7xckLds/yjuKyqjym2nGQOLdJNbBhOegT57Y3xsZhusO85Tfso7b6a7T0yt 0KD8fSMNPJiAcOQ2dlyV05U/LMNzzm/x+ghCm0W5OZwiMH+9yhw4MR8UBJ7RJ00K57Cz LKDQvhBAClAPJDagMOshmdROML61MyDxqZVjpNPE7uRxhc3Ry8JOiGnT1t1Y/piKt2pY BBAw== X-Gm-Message-State: AOJu0YwiqpXudA3HBxnHN2Q/YFWf0x1t9BFVYJCs7tgwEjCTC5Rqk9qQ nfpA5LomXydrFvt2cR4ZdDColN563ieWuXRoIrrXcURaxWX+ZZ/Rf9GW2w== X-Google-Smtp-Source: AGHT+IGtg7TG/21AqcWVwbyQCWgFfL4Xph4ffhY2qBy3rPvdY4cvIPP97htG7f2T1lbnyl7ms5mZeQ== X-Received: by 2002:a05:6102:3953:b0:498:d3b7:be39 with SMTP id ada2fe7eead31-498f4c5efcdmr3904305137.29.1724451833799; Fri, 23 Aug 2024 15:23:53 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f41f507sm218860385a.132.2024.08.23.15.23.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 15:23:53 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v4 7/8] auto-t: add affinities property for station, and extended_service_set Date: Fri, 23 Aug 2024 15:23:38 -0700 Message-Id: <20240823222339.328006-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823222339.328006-1-prestwoj@gmail.com> References: <20240823222339.328006-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 Fri Aug 23 22:23:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13776090 Received: from mail-qk1-f178.google.com (mail-qk1-f178.google.com [209.85.222.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 4148F1C871C for ; Fri, 23 Aug 2024 22:23:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451838; cv=none; b=em8NVYOYwWBHURJgOD6xhJOV62X7uPvwPkqGNCfmTTIigQgsGv04gFEa1YO6c3bymrX0jkdrBXj1uDLYld5VVJwaA/zScHGBVefhBUAiFiNHZKkG7smqJLoAKhnqErHkTvzzgbdEvLgMw+YD5q06an5ODlgbfKSwQAkzpteEHuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724451838; c=relaxed/simple; bh=VtfRUqAptUpigOzeZjNHoVL4/+kBM519529S4p/CSgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dg3EpYqbFscBUPn//dxoeLhyhS6nmAhXLmMo/W3XMB8o1C+JB1kMk0S6Dv9SlNDByXmwD+y+E9F6VNDDcYKJcdzvA/rh7ULRNOWN/6JObwr2Mm/2cc50CyjLLxq8ZDrhgXwfaqsXzsLyavdZLMfAWfO7sQJk0kb1XUA8EOmv8hE= 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=YG/JPAd/; arc=none smtp.client-ip=209.85.222.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="YG/JPAd/" Received: by mail-qk1-f178.google.com with SMTP id af79cd13be357-7a1d6f4714bso234198785a.1 for ; Fri, 23 Aug 2024 15:23:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724451835; x=1725056635; 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=YG/JPAd/974AB01dJt0U0S77FcEhdlUeFXox7OgwFRjtVk3fSUOar65wIABpHhNmip 0NHbhytXK3dzry4/b7p1hE3EO0+QUXeTdB+XEqm+XSg8MkGXkdejkZDh8yA+HLNfy/YD QX5dkrswrDtNXNWoh3yQZNwNw2kOWQxLnfEqGQHy+utT8/QhTJ7FhiIYpKiIjuSWaT9z FXH2pitojpSlhDlJFLUOeykdtRlkwuDJ22j9PPpnk4y+R/+n0krLUs2MohiIt3uBuPpS B3YWJ6kkwZfzt6EsRoIQrrI8NPgC8IJ4L7kLg2dnAmwkLHnLqiA76NgO6Zadf+6MdQBO 1Png== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724451835; x=1725056635; 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=lI6JsXvps8zZ0/12SIRyoQPApfWH2CITPBE0NWryG0OHH23uTRXxDaKRZ7VU1oAYmd pa/ASpiDTfIuBJE+mtmU7wP31xZAlHSDo7vzQBfuMly3HDGRhCTQj+AcHR3wnm5+m1lR 2dQHME8Tz1xKOFWed8i/w5rWhlsIXEn1p03rLRWhuhpKXj5JHFQuYwCqbjCQ19agxfx8 ZO3q49uVE8fQm+zHfuJ+WaTHA9Sfregtzx8NMbvDwQgRf7YPcyy0sEO2bM9YPbwf+b/p 5hfusH2sS4V1YB2hAQ62nR5J/otZJzlcey/hGsld/4AoO+2d9cWA99om+uLhra0DG95c tOLw== X-Gm-Message-State: AOJu0YwC5Zc2RYtwEZxM53Sfa3Q3twXyilziM6qlV33FR5QtEwr4DVw8 lDsi+oFYyEbMz1HX+iK5YrGUJjvbtm9Krom9Wup6YfaHmVsXXITARGDelg== X-Google-Smtp-Source: AGHT+IFXn1F1i9lyeHcJkROVr4xrVyZSGom5fqEO1T8FaJsSONfPwutfzzeaGBvm1q6+838TAi+Yhg== X-Received: by 2002:a05:620a:f07:b0:7a1:d69f:5b9c with SMTP id af79cd13be357-7a67d497da6mr1673145785a.27.1724451834956; Fri, 23 Aug 2024 15:23:54 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id af79cd13be357-7a67f41f507sm218860385a.132.2024.08.23.15.23.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 15:23:54 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v4 8/8] auto-t: add tests for Affinities behavior Date: Fri, 23 Aug 2024 15:23:39 -0700 Message-Id: <20240823222339.328006-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823222339.328006-1-prestwoj@gmail.com> References: <20240823222339.328006-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)