From patchwork Fri Aug 23 17:59:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13775649 Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 735C518BB83 for ; Fri, 23 Aug 2024 18:00:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436018; cv=none; b=o05dSSoodz6Sz8VY511v/CpVgeBn/wkaAbWUoEKkLLwHcZFknN50+mUaZ9bouQDuV62SvL100Ivq0o3oUpkGQ8eOVIryIb9QYrNnIs/2zDJP+8JpA+Q+tXUdX/sdTNspkqNN0AyV77u3kGN38E+UTn7VBr9xnsL5YVYalXY+lmE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436018; c=relaxed/simple; bh=n+J0VgqPpR4EeYOrZu01+32SQDmrML3IpcCjqcqRtJI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=iAOqMxtW70BGCz0Jt2EBhYXlIEa5EDSKDrYHsYTSl5JiGY3tvHBa4nmhuA2OGSsq0+N1MYBJtI6IiKE3w1m5ETBFfJ52k+6DoDc0RxnPDIbhtMdpj7pGDv6s2WTeufstmx34jfWK2bZ7LtDC9iX9UiGNZIeNfrQxh30mG8Ento8= 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=h+mXmm6O; arc=none smtp.client-ip=209.85.160.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="h+mXmm6O" Received: by mail-qt1-f169.google.com with SMTP id d75a77b69052e-44ff99fcd42so12889431cf.0 for ; Fri, 23 Aug 2024 11:00:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724436016; x=1725040816; 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=9aFfc/G92BSYc+ccc7FukmxlIFRNIq41Om4fmsWhHOE=; b=h+mXmm6Oq60mFg2F/jh886U7CocRD5zSpUIZ0uDtHwP1R49ozmvX/7XEA8e9oBJg1H LW4ZSs4pWeV09KTdAbrF2ovp6Pc/WXmoP16QxVU0exT9ngfG8lkty9WKrpJXiXVBn4kE KJtfCwU5palrHs3TVAYHQzJDJ0hAOAED/3koHVh4aw2Qzj8M+g29JmFVS6dI6hO0gtI4 fIiKC0eDIKX7iRN67l1h+8TXYqtgnalrYrP121TqOJPRsMdZX+IIsRERwG0enP4l07eB B3SulAazwFuaaMsTsUblTnaz8Yf8J0SkUBQmFUy2CL+t6SYUzTgDjzCPZm62iVNTy/vY Nsng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724436016; x=1725040816; 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=9aFfc/G92BSYc+ccc7FukmxlIFRNIq41Om4fmsWhHOE=; b=VusdKMY+fQZLYrPCEr/kFS/uKm39v5w7H0Atfy3pm0X50hX1hTMHxUZcNip2W59GI1 paCzxyKS6tbqf4bDKvI2fXKlaJHeZfKL2Jl7h6+Eme3Y0T8LJ4NPIMJQZi0afYVnr/AC hAfAQyqIVm5IdKDwLbrn2YPfEn14JSdglfv3Ie6seDL8vIhN0epl7I18wS5brkUHBfpW 6e3+k4EbiE/mMNFRWv6JHMfWpvsWh+K5d3S/E+Php4zFkAuh3hU+HnhVaNE/tmWb0lEb jFst2nYMXCjcbXyneTamcKejzys1FyTSASo7KhJ5NzUnCcOOKk+8WeGTvOa4vQ36t+tl 0IKg== X-Gm-Message-State: AOJu0YyL6qohZpaNQpdONVq5p3Ompl25MfN7Btt+tGMUEKC9DDHxtq71 /ac+I/m21yOVGR85IuMNTN98KKwOTA7BL0VRYd/75d746pSPkMz7iNZgmg== X-Google-Smtp-Source: AGHT+IFLNh2JTAgQTK7VuTjRfWW4212YnCCnIyzMXPKSvfxrSPk8TqvD+aCMV1SN56Yl06Rw+UYVBQ== X-Received: by 2002:a05:622a:6091:b0:453:767a:183b with SMTP id d75a77b69052e-4550967870bmr26144801cf.30.1724436015815; Fri, 23 Aug 2024 11:00:15 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-454fe0f0507sm19683131cf.47.2024.08.23.11.00.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 11:00:15 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 1/8] doc: Document station Affinities property Date: Fri, 23 Aug 2024 10:59:59 -0700 Message-Id: <20240823180006.317353-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(+) v3: * Fixed typo 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 18:00:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13775650 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.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 9016418DF62 for ; Fri, 23 Aug 2024 18:00:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436020; cv=none; b=uB51T1TQtLLtMkWFLjhe1RwvihOA67E1nk25sX1SKDWi/9AmGYwyg7bLMNIdWkbx45bRZXVAQSjWU4oqik+834I5ujujc4vY/lVqRtsw2STwNBiF2A0zoEgPGImZxU6dCiLyOy9V2RHpw0Si4mcwW/aV8mrQqvzXI2src+jRhsU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436020; c=relaxed/simple; bh=Wo/sCkXWEiaHPUveO577h9cB7OfoF/pXS46s7c2XYgc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bWCSBjNmobaV6eSu/J2ZSPQd1ad+sQ3WjQrn0UG+HzRXYgyHLUpmOVZwWVHIaTiC6W2SbbrmbkZZ6ivxJ57tWKSGFOY3vfutyD7oD4DJSU7+iKRPQ322ebDfYXeaQ2M01Ndsu4X53VEwNPfQRdOmQ4Z0jypGiz83+l3uiYBAD9s= 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=hYL7tP+y; arc=none smtp.client-ip=209.85.160.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="hYL7tP+y" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-44fee8813c3so13435881cf.2 for ; Fri, 23 Aug 2024 11:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724436017; x=1725040817; 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=IEYhFMAhZu34BWjS3NlsYX+UeyYUy5DmaFBWfpuztkU=; b=hYL7tP+yBoRC4ez9fHKgznd20CpF8D7IuLltbQYjxjm3WuIhdA8RnECWJ1u8hHsy2n RGsSCF5dKkJnHnwbMwGYdyhWethtIBNnwL0EhKU9ygk/7FNh2tYsgR6rRbBMyLiUXbUe NFSECO/IfG+Wv0D/xiDN4334hBaYjmiU1gf5gMRCzpCOrPsq2ItZw3MjyxaD/6b2wjLX mrKXEKodF9bCnpcxkMqFefiXExGtDsxxYjZ1ESBWAiFZcChvhN9GcnJDE2+8tzm36vo8 K7TEWu0x3fEXheoewQYgg2PaDKrDWZsDMgHqMSbg3pMvaVD88KmFzHjxGPxG0o71lKMc cwTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724436017; x=1725040817; 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=IEYhFMAhZu34BWjS3NlsYX+UeyYUy5DmaFBWfpuztkU=; b=O10Pokm5A55RWZ34JzmoXNZ59KFDMDgREnmA+3bymeXsRyw8v6e05/36OCqNW3kE9Z 8vqHBMikKyi/8xF0Twu1TpZ2Nv6tzhOYQGNkHrOkIp0QTg9VDklomD+3BRVr6V5SPeCM 6vIulaYcQJ+EskUUWYtut8VO+516dW30RyQeGYrjPxLA9b8A13UbopGBfA0zG+O2jmPN IWnBT6gTgHYCo5uiFwwfvRWnROjAEEbsy/Xn1MuDk2cOZoJ2bZCuYYadnUtQ4FqLftZe N2/nNqvz7dvbTsN/H4FyAb+fYpOS2bOPKf/s/RNVVx+sQrGpm3ad3NHeo7LtcuNKBqxk rCSQ== X-Gm-Message-State: AOJu0YzLo6MrlO3TMhyLPHwwrBlczTqmQJC19tkRfKJQu5HfQiS5iFa3 HKDOMzXBLPL1JLq6YkSx0hhq948TA2T2FoD1sAfIyhrC1VqwfOOFxpr1Lg== X-Google-Smtp-Source: AGHT+IHftQa2FV2mm8N27PKDgrzMnLF7qapsny2D0ZnYV6zHjQS6W2gvxDh/Foaq5pagS2QlnCCQvQ== X-Received: by 2002:a05:622a:248d:b0:453:75bf:20db with SMTP id d75a77b69052e-4550976e7cbmr38718391cf.51.1724436016964; Fri, 23 Aug 2024 11:00:16 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-454fe0f0507sm19683131cf.47.2024.08.23.11.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 11:00:16 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 2/8] netdev: define netdev settings in netdev.h Date: Fri, 23 Aug 2024 11:00:00 -0700 Message-Id: <20240823180006.317353-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823180006.317353-1-prestwoj@gmail.com> References: <20240823180006.317353-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(-) diff --git a/src/netdev.c b/src/netdev.c index 494e46a5..4d6aae6b 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_TRHESHOLD_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..d718fa6a 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, "RoamTreshold" +#define NETDEV_ROAM_TRHESHOLD_5G GENERAL, "RoamThreshold5G" + enum netdev_result { NETDEV_RESULT_OK, NETDEV_RESULT_AUTHENTICATION_FAILED, From patchwork Fri Aug 23 18:00:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13775651 Received: from mail-oo1-f44.google.com (mail-oo1-f44.google.com [209.85.161.44]) (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 90B6A18BB83 for ; Fri, 23 Aug 2024 18:00:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436021; cv=none; b=iFC/0TFpuwjrgxRQTkxkoe5BeUodJwa41KBFjpCJkf8DcMjDVa6ZzdRRYtvd36bjtllZ+e/0QcCzwd8qmT9mqhp5/Mtavvy94WCpTuDFE1oM+YSe1dfheByUg5+L6fBGvq4Ywp9NZNftNyoWRXnxSqsUYAIc2xsiyNpxpIldMB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436021; c=relaxed/simple; bh=btwTRtLqSGcWqZ6Ne9I+fe1S4wcBvGWmUpVBKLImO7c=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dHfpEaBdcVwwNEa4AvpJaXMmG2Yf4xJ4oeQLJuFpCLXvM0V9R03nLlDC1xvu1Wpxsaf0vJvGYNmhFzFK7kPdz+ChhwN0JX3lDAIKM7mz/vvOZhTuSf7BTI1lpq1478lS6tBFB4viviGr2KkM7z1w18BaPGqE0UxG+kcvSNVMjsE= 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=WnwUDVdC; arc=none smtp.client-ip=209.85.161.44 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="WnwUDVdC" Received: by mail-oo1-f44.google.com with SMTP id 006d021491bc7-5da686531d3so1675168eaf.3 for ; Fri, 23 Aug 2024 11:00:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724436018; x=1725040818; 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=N/gRqrTjMi6ShOPOHtkjCdl7RgioLdEkQjLXtXh16+U=; b=WnwUDVdC7r5xGyZE6nGQvjOCjSw6pc0j718eVQu0x7p5C7gyqX7bcS/Ud2+j+W3s3k wwLKB4aGml/oK+mxl0xmJT8gLksVI+NMUg2Z4V5yZm/t1yXoKl7rRzjZjudmMNkNX3qj zeAy/L6r/az/kRUECFLUvsPex4kGjIfGjxMkFDH5oqYfo9YP2GIBPiLZhjOBXlgnYkTI C51JRlw7lCMAU1D5axFBNGm3Ce8Oirghc762E8wwNMjX075tObhSNyFyn3hi6mdYfMFa ELkbReh+PnGoDK+aPLmdqni+IMnkAy673SGRMUzGlNLOGJWLaaSS4wQyDeHuer0Yi5M+ 2f9g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724436018; x=1725040818; 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=N/gRqrTjMi6ShOPOHtkjCdl7RgioLdEkQjLXtXh16+U=; b=fpWN3/+WqNDfdWTXwxJ6ubystybfm0l2lPe8VH+ugHsG4ONcIPUZ+ResHdwok8HCmq bwlRl8j3M0KHvPZk7jftUF5dHJjHFNIf+TJ+eQHVb6xqVJ9A8sPhYAsL7+Gt8eHfnwYn woIE17Lq/O4dXIMsot8IouVXtpAQtGqblbdxji0zgHiHLyRfq8LRiVcZiK6mtBl43HVS /yn1NS5m2pP/DQYmAzS1zLsGaedtJgesAQ8AnR5Ef6hBhby4ydSwbrVdPyP0JC17d99v p16PAru6q0KEofv/+0WuYOy3aX/JYsYoCj+0tWf8toW/2s1e2MQ8BXSQqhK2gF0XS2ej bEMg== X-Gm-Message-State: AOJu0YwGRzrNa/vM9uh55kbBnBQmSF+Mpx8KRXj/YQ/7kIdFOjzsJt0X CDOryoT7haN2HF0DQcBx7mkcKv86OXcm7dj9AIZg52TJGrHg4bUPmFn6Mw== X-Google-Smtp-Source: AGHT+IEI/bfkUIU+TUk5wbyhDsTOAfJE2AHITDR5iNf83MEB+46DJm/FiqrHunwVIA5rkl18+ETFhg== X-Received: by 2002:a05:6808:bc7:b0:3de:ed0:680 with SMTP id 5614622812f47-3de2a86ef6emr3007531b6e.3.1724436018252; Fri, 23 Aug 2024 11:00:18 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-454fe0f0507sm19683131cf.47.2024.08.23.11.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 11:00:17 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 3/8] netdev: store signal threshold in netdev object, not globally Date: Fri, 23 Aug 2024 11:00:01 -0700 Message-Id: <20240823180006.317353-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823180006.317353-1-prestwoj@gmail.com> References: <20240823180006.317353-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 4d6aae6b..e392c654 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 18:00:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13775652 Received: from mail-ot1-f52.google.com (mail-ot1-f52.google.com [209.85.210.52]) (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 CCEB218DF62 for ; Fri, 23 Aug 2024 18:00:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436022; cv=none; b=ag78ldjcPou3w5yJAddpaK3HC9QgjBnP/Y3w4QDvsn+Z8HL8k+9NUWBqfoBDPbj8/3/R14jkhyvGiz5/vDiW5nbvzopnvbcddnc2PrU2cFe+fmZavR/KUuyk4OPpqvMREpklzuGhJnm38EIbveC1l0gDmDWwOZe2VA6hY34X+YY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436022; c=relaxed/simple; bh=ZljTQtXq98cRA+kwtS2Z0zd4CWtfUqva1KNY1MkV0Go=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jKwxDEg5C9N7kb6oXh8l5Y0fOq+ODHBB3qqan0eY55YSeueYApyaUc2eZ6tiHzecHaf1XJ7+KRdUHeF3BvOCIWo+PaWbY2TuclPX4WjlwMA7WCdPK+B34AMipqfDKdBssQdxWCywWC92HhND9fiwNjSzlVjZqaVgdWyK3+mlOfA= 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=IAjFyvv4; arc=none smtp.client-ip=209.85.210.52 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="IAjFyvv4" Received: by mail-ot1-f52.google.com with SMTP id 46e09a7af769-7094468d392so1764896a34.0 for ; Fri, 23 Aug 2024 11:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724436019; x=1725040819; 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=9jkjOZ/MabxyN8XvAZyvEOd32VeO/sg6Mr+9d65TU/o=; b=IAjFyvv4B35YDdzC7kUubX6aoxByG53yXjSaESTHF84fqpNRAUMps9cPInnreOQBtq JdjDIHJuReMfzbdZJ8Rpc+LWZnq0UNvH8QmEZl62gAGqZ+Xd459mQgHPk2rx5/Hiw7z/ R4dNBQ/UrpFwDtPCx4V2YWYPKimsj1lofNiP4MQyLgUQ47d/BmLTk2D5pHD7tBHGOCLP EtNrW1XnhFSakOkO03lTLyoRKzz/S9L49VUtFu+Opsv2Y6wTm59JgGbgQPOnsW9sbnC3 ohFWk8321Znpdw1UVyX0Q6JDf42B0DU23JOhATrP2pwnX10dQ3/lqeypuAICS9z2qimq Y/rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724436019; x=1725040819; 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=9jkjOZ/MabxyN8XvAZyvEOd32VeO/sg6Mr+9d65TU/o=; b=u3vVcCUyYdyqnSBX2u/cSM/ZXp+oj46q49PN4AD0mxeL41ltn9A5BSc/pWdgUeQVKD eA4eLdmg26nx0ZOHkBOWFgY53F7M2wb7wGOh+34OlwQebaIAivAqRXIC+ZZ9ZjCcc4cj qJ5nGxvlPifMwBpj0whB9i2U13dHyRTrOlbTMouJEOw2YtZ+ONBvRWlVL53iQS5LTBiw qRmXRX8MZZoSSAWQxRwnQjVrIYW7wpIoonzhs3XRJdo1nYvzppxSCZx6jftS76qBjHcL JR+WGvdBVKzSbYKbIOsJxNKaKsJ/HCOjTNPf40XzJDYjSD6Gjnc0U+G2Mh5cWYDeXlBq mwsQ== X-Gm-Message-State: AOJu0Yy084pibcECeSsjKF1YbYSZg/oPHWg7TWDDH3fp5Ci100JKaMZr 1qm4yC1reGyueELUsWa4uHEbv4u+44b73BF/mn6G6Uh3//ACcw4+SVpTkg== X-Google-Smtp-Source: AGHT+IHsoZXs8m7peX7Jcxy0rhlHAJM0IYWfGBkGHPtPwHSKZNo3r0ZagHnt7k3cTER1HlBq+BtZzw== X-Received: by 2002:a05:6830:2645:b0:703:79f5:fabb with SMTP id 46e09a7af769-70e0eb0d34emr3127681a34.11.1724436019557; Fri, 23 Aug 2024 11:00:19 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-454fe0f0507sm19683131cf.47.2024.08.23.11.00.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 11:00:19 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 4/8] netdev: add critical signal threshold level Date: Fri, 23 Aug 2024 11:00:02 -0700 Message-Id: <20240823180006.317353-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823180006.317353-1-prestwoj@gmail.com> References: <20240823180006.317353-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 | 5 +++++ 2 files changed, 56 insertions(+) v3: * Moved the new settings into a #define in netdev.h diff --git a/src/netdev.c b/src/netdev.c index e392c654..cd3cfc78 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 d718fa6a..46845c36 100644 --- a/src/netdev.h +++ b/src/netdev.h @@ -33,6 +33,9 @@ struct diagnostic_station_info; #define NETDEV_ADDRESS_RANDOMIZATION GENERAL, "AddressRandomization" #define NETDEV_ROAM_THRESHOLD GENERAL, "RoamTreshold" #define NETDEV_ROAM_TRHESHOLD_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 +205,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 18:00:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13775653 Received: from mail-qt1-f178.google.com (mail-qt1-f178.google.com [209.85.160.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 6FE5219069B for ; Fri, 23 Aug 2024 18:00:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436024; cv=none; b=W8G1Oqnt8gbUdULKdc984dXCnVESQ+j99GgOzMZlCAPMZNVsUc3vVsQJbtvjlw0gW3w+LrrmMwJxU621SUFvE0VlOGLSzFyuUv6WgkcdBfsSmb2oVDvDzMfcDSpYTbIVHZH3RGrNk6YPva0KOna3IGlqHlLc3lrLqO5WGNAF460= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436024; c=relaxed/simple; bh=8GJp6LIloV0RHrttszdpIwblnKc6uljkf1d2c0MC+/s=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nHs07MWgWOZE2Wc31xpRBlb3ApV/mU4+96AMHAd93UM/0PegrwK5iyVmIgOhQMrUacA/5dh5akL50Jg86ov8VCwuZQ7h79E0h5CJxQdgv6KMHLbqqtvCqYS6qLoQN7OCe7/R1mov9ofMIp8rEHvwObPBevoRn56t7VHvbBmSzrs= 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=WBGaB4tE; arc=none smtp.client-ip=209.85.160.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="WBGaB4tE" Received: by mail-qt1-f178.google.com with SMTP id d75a77b69052e-44fff73f223so12436131cf.2 for ; Fri, 23 Aug 2024 11:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724436021; x=1725040821; 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=WBGaB4tEmxIE9ZMJeP6IElXffPMXkUCxu8vkIQwgC3FDeIbl+ygj54WCo2oGpy0e4L 0I/sLJi2Eh5tJfqhHV09Q6rhbSL9YR2Y25/eomwjKYuT2fexmnJJHKV4jT85ejzHT+o7 WCHCnDdcY5Z10Kaoedm4TC4XHGuSZyx0dTPAIN4Ym4A9GifsznTHMVNcLWvqy9NewVRZ 0OokNmBGA8Ped5SyW4ETtDQEpdm7AXYKT7ZsbcQiBHzetVztmIjkzgJ9tHO1F7OnQT/6 Pv8YHp/FFiT/m6+VyjLahlXsQM/z5KPD451QpMCtFNogtFtf1JzzyqB1IjK7OfrXjORD t68A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724436021; x=1725040821; 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=uPneaAv9bg/V7QydFTy1j+Fii4PM1VNJym5DEbTmYZuHot2HzH+rb8Hn93dPraVKSG ZuZ4MeoeAMTa1rkK84lX5Ymv7lEfqAUa4Ad7Pd81HAwE4SIlf7XJzw8v2pgpS4JADytp T67G6iGRqqvCmp1vI+sjDWkWvQ1htE2aC/gy/cx/2KJWEAojp6klxoSsec8mmesRVSIE sz6wlXTH33YOxv3QWnovIx3tXNUoxrUNoAr/l5K6wY5NK19BPLkEz37l3/LyqpRuOYy9 kZfM18vZF6MqQ53a/ekbTI4rZOfug4ESIPeVjhfR/RWGGo35i9Q0UXONcTlftUomONgi EDkg== X-Gm-Message-State: AOJu0YwPDdeW45fbk1+wWdnaodo8yYCj0nuv/4WMH75ecYeIeiFvIF1N ypJ/VJ7vuZ28zrR33hIzNL52i1lCZCZ/q3Qk2seU1AoIKljYPLHP8H08PA== X-Google-Smtp-Source: AGHT+IE4nVN3bZVgKb3eL3aRRSQhmTEZtgnwOfsywf1e9DZ3BgUldSLzKkKwOtuTsVloz5zpVjLXlA== X-Received: by 2002:a05:622a:4203:b0:447:e542:ab00 with SMTP id d75a77b69052e-455097c22d1mr29818041cf.50.1724436020824; Fri, 23 Aug 2024 11:00:20 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-454fe0f0507sm19683131cf.47.2024.08.23.11.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 11:00:20 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 5/8] station: add Affinities DBus property Date: Fri, 23 Aug 2024 11:00:03 -0700 Message-Id: <20240823180006.317353-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823180006.317353-1-prestwoj@gmail.com> References: <20240823180006.317353-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 18:00:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13775654 Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (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 62DC518DF62 for ; Fri, 23 Aug 2024 18:00:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436024; cv=none; b=l/61hrFzHOfGhPqzv9QqFKGdJjxaiqERBoW2dPlAGi94IpUhOVcwci41tiUdP0fVSV7M/sVh0lRAeSIYx2K9ZtQUAW721RZoLbs5qRfwTp6HQFLmy6e/VovDyNAupB/VsJtr00sVuPiY201/7O3Qy+tWhr1KKb5Z6zps1/Gqexw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436024; c=relaxed/simple; bh=77WYaDfYJJhEeptfZjfnvcSpDbjqVudeC27c8zeK0+g=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oYN/vrEpB4KSwOMLwGXyxkaY4X8tKuD9+Hpo15TlIv0D+TPsWI7SKYBEBvtzYYlsp740Dn8zq9anQlnD8Sqt9WvYMYjcvf7JstKTnF0885Nx201SrORVEg7tHCiM0xJB0mosjJtIyErV0HHE7fQSm+L67fS+eBTkfYPwo4bmLOY= 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=Urqp05r4; arc=none smtp.client-ip=209.85.210.44 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="Urqp05r4" Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-70cb1b959a6so1347956a34.3 for ; Fri, 23 Aug 2024 11:00:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724436022; x=1725040822; 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=Urqp05r4WLk954B8TT6+mlYOUNSvSbfqMdRzCmVYv0szZuR/jW5NGzvcEJJreqEmpr 94/WwtVBICNqyp7hBRlGzWM5G794ySUxQRYNQbQNA6CNnStKUJrI35PFeqs+ID4pdJgC 3mOnTlBC5Dxs2TXhbM8b4tTQ7v18JUocHvm14Gdb50g7pW17+WBPQwPP2auPWci0HSSK 7/OKMfWiV6UiygO4FHr8Cb0ThkUB13OX+fPfik7dBbrQPjA3ZrlxQXjT3kjV6+h0OSb3 QH0iKPNKsbaIJJHJirQs2Lu9l+NelG7D+28VnsaTc7xaRIVMYtnlsqoEgz1iOWn+IXzr KyPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724436022; x=1725040822; 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=SIOFxDNF8jqXTCpt+BBfTjuh610He7cdCCcRU9crQ+zI+9QFjyw7SK+RaQSywgehx+ Q9FMop1sAJkzznKkNC+NzqsYk9nj/AUskqwyiKY4nqTNT+rmYchtR5AXCY3w2UJCFxhz eO4YdTYgyczjcT1dRSYgq8LJsOCD74D1Kc7V47FYh0fMJaqEvZD/74f4cLGA4kVGVqDo VmmooMPniO2CU6VbDtC5HmYIt8ZVAcAnjeUSgeJW1+L5lY0g6F73XWaA0p6oyifNBHgg Ad6Np9xhru17QFss9808SPcwTv+eAMvjCdY+YMWU+QZlZvL2NlbxYhW01bO6QXHeHRIo VyUA== X-Gm-Message-State: AOJu0YxObuVLZ+CwpDfYOd6zZgUAFTS4+Pqfblh+bZgRRi/9er7engGc Xy5OA4gGTQWLpHDLWlqmfY7rco9/l8drMmyLvTKz8NqhhW14OfEDIgXQeA== X-Google-Smtp-Source: AGHT+IGkHmFmRtoGal8pZAJuRYnPX+KQYxcdR1RUB3XwxIfZ4trmrQb9dT0CTItIjeUUNsDWyOSi3Q== X-Received: by 2002:a05:6830:268c:b0:709:2fa3:1329 with SMTP id 46e09a7af769-70e0eb909d7mr2822299a34.18.1724436022151; Fri, 23 Aug 2024 11:00:22 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-454fe0f0507sm19683131cf.47.2024.08.23.11.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 11:00:21 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 6/8] station: Use Affinities property to change roaming threshold Date: Fri, 23 Aug 2024 11:00:04 -0700 Message-Id: <20240823180006.317353-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823180006.317353-1-prestwoj@gmail.com> References: <20240823180006.317353-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 18:00:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13775655 Received: from mail-qt1-f177.google.com (mail-qt1-f177.google.com [209.85.160.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 D9A7E190482 for ; Fri, 23 Aug 2024 18:00:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.177 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436026; cv=none; b=B7vbLWI1ttKkJTJBJYZVdZNUdqd3lTrXFddoJltjzlJfpn0KvkduRLd2PLKlldhdS9S19cN7S8qlHh0nxprU0wPOvPCPr+yJ1XOByZPO1fbpR+am7eMXBMVd/imSm3c56m7twfuo4KX/9iYHtc143541zaDlItNtVPwFE2YVRuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436026; c=relaxed/simple; bh=1pYxZdt/cb6QaZROUOt/UXNKrd4LBk55ZWX1Jek2/YY=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P8/3L5AouJIaou/Ij9GVfRx+VEd6ZKc+yBznHVShz/CkkuvFOCLteiWXjTuFYuj1K3RyppCqmddreY8pbuU1QGHVWkI4QN+vVxJ0CBJWXNu4xHAqY8KNDAFz7tBW8hDk+1zd8tyqbXDSVJSZPlwGzHkd4IKV7OuSE+zJ8E/Wk1o= 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=DpMyeRBs; arc=none smtp.client-ip=209.85.160.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="DpMyeRBs" Received: by mail-qt1-f177.google.com with SMTP id d75a77b69052e-44ff99fcd42so12890141cf.0 for ; Fri, 23 Aug 2024 11:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724436023; x=1725040823; 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=DpMyeRBsb5uvdbjGw6vuCalGJ6uGg9u8/oQASvjDjR6b2FYvopdsHJ73x0b9xjZyNu fMh+TPKFJJ7vfFvyxWWiUApjjXKd+1pEuvPHIolzEhg7SN3xoyxkY32MbzLMlHX6cOP+ 32z5AZ+80Z5sm66LA9YVOnmRtT0KMo1+XFQM62ogJY3SQ7w/HEjYe7PGZR0qgcgFJ3Uq 9UbXN4uFmt+FzWC++qQLAsS+FNYjaHBr9rMoe8+SQ4fRhOnpnScgFZpOfxmSdIN2h07o RMMxCNqMtp/UQkfftG9M3V/8if2IqxUQyyzN2sdtPYM51qrX/Td7zr1Y178LpFeSa/4k 6LIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724436023; x=1725040823; 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=pkKJpY9xhK+DGleJ2FJCTOX2keLOM0U4fQMaQC0NCozDH8lAT+RSpL0pu7YmZezthS WmnXnU1AzM33/QhRAZmwL73GGCFdLxaHg9juN/KzGQ6bRfoA2yWSln3dhxxMFmEZ5e3F jDuvYhVO7Gk9u8Uepnik/ZaoGPNWqqkHihuzS1O4LPslo70Tc1lNPrDMGIeUV+S7BB41 8mrHDSwWIU/9jnjhxSSyqFGrW8aKWrkPFcqyg5lM9GijOYsvaCt2ExKFuuLJ7W7NjYIw WpW045yYFfbiLxUxkFC+OBy/QuOoYYiSgdfnC5wzyHPao09VQ+5lyMJee1jgqSB5Y02p e6Xg== X-Gm-Message-State: AOJu0YySzBk+C62oQ79awASkjuV2a8UvtDQeYWRPH11G2ntdRPk1pEFf BtOBBgefiyZEJhaQwk+8hOTSqsj/E2/NQ4vEyCZBTKQd7t8Ltaq2xnjU3Q== X-Google-Smtp-Source: AGHT+IHUCRRfjwd4/fw6ckPLcS+CdaXTBVhM+TqfYQRtXv27L8ffL+OFfyS1H1mXMQyuVkPXEP5GHA== X-Received: by 2002:a05:622a:1f96:b0:44f:5e2c:1631 with SMTP id d75a77b69052e-45509616d0emr39094211cf.17.1724436023318; Fri, 23 Aug 2024 11:00:23 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-454fe0f0507sm19683131cf.47.2024.08.23.11.00.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 11:00:22 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 7/8] auto-t: add affinities property for station, and extended_service_set Date: Fri, 23 Aug 2024 11:00:05 -0700 Message-Id: <20240823180006.317353-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823180006.317353-1-prestwoj@gmail.com> References: <20240823180006.317353-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 18:00:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13775656 Received: from mail-ot1-f43.google.com (mail-ot1-f43.google.com [209.85.210.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 CE14718BC3A for ; Fri, 23 Aug 2024 18:00:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436027; cv=none; b=p1YRt6M0cRmXPEHWiOyt1MjSk860vGqurfAAuEpUJ0tTVtRTpM7cZlUuPu68qEyOL0NVpaWBZzTahpmR0i5SPSrpbHi1FcuHFlhj5y42k3tiLGPPU1FRZjstIxYE0omRFhcosI+WKd1NvEHpSVHy+7p2E2B+d3duAdzR4LyIGcg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724436027; c=relaxed/simple; bh=VtfRUqAptUpigOzeZjNHoVL4/+kBM519529S4p/CSgM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yb3+RD1vGXQMIlR9rdrosbMtx8hOB7H81pan5JJiLQsnh1oPzWEnrpY+tMAqNGzRdAp6h0Rll7RzonRbZ62kY4dkWPHyRqqJBt3v13EJlyRKmywpt/u2FwpfvbzLSe/ljqtcCtAGYrlT4HShI6djMCJ5e5nN6D2KqxbHtbny6co= 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=VS0Nf3ur; arc=none smtp.client-ip=209.85.210.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="VS0Nf3ur" Received: by mail-ot1-f43.google.com with SMTP id 46e09a7af769-7093abb12edso2074231a34.3 for ; Fri, 23 Aug 2024 11:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724436025; x=1725040825; 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=VS0Nf3ureH6nOkixQ2mk6r/MDDZ8DJPfaHDFTmu3g/2wju3zWwgWMBNOK0tCDo53M5 yMYfxrDJAt2UriS2ml8uaMfwS0BhW+9mtjJRhhdMyill3yOUyy8T8eqnYmZ3oSGVOGND lRp6D9rOmh6/vnUtgAsU0QCjhtybGqw889VMR70yiH243hCeIWm6hFCimlXEtaZsDhoi tqBa57Ym3WsX5Ynd8uCX4qW16PSgd5CtqhwoWDv704uS7HADk0jAMN22kWQ8beSXk3Dq fcSLLGt6qgMpz9b0hsGZsMCpXM+dxG3LfRKdlTcn07ilyZgScRrw5cZJu3N6FZuBKC7W xEfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724436025; x=1725040825; 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=QsXouTt5TLy8mEVcL24C9HMua7tMFrobhPgY4rcO7b9Xw9mXLGWWWBo++JyL6RUfTL ggaQX/Ol0JGlugg+hgdEYNVA1wQv34euy0AeFuobEFVxuBxAUsVFZTxgZMGDynx9iRFB 0p/fD5YGxTnbWSKb7i8EO0L+Nlvn0NWrWPO/QSZO7RoHHbDujnuVikJHXwenhzoRyKMz o4gYVrnTbSy6P7V41rPpyBHSjBaZI+O96lBGigWodynYJEQb0m6GavD7qz/nQY3zyVzF MY42JI/oqfCLyf8Fk60gXR22JfOUPtnFaQIc8jisbA+QmENS3v/sYk3TDXD7ZIIKRQPw ardw== X-Gm-Message-State: AOJu0YwxJnUMcWuiLq0lOGVWKpUg+PPTnpvbNziPdiT8yDNTMhhQrpJU 6A5lJjNg8Yedm3SZ2TKD70w1kBzTlB0FaTeE2DC749mCrEzhnRpvfvXpKA== X-Google-Smtp-Source: AGHT+IFrd+0ldp6GaPdSd0RWBgv34ueGC6BMUnDhr+LfuPYZuTaEg+1q6oZf/NzJC9Y8ru7jC6K+kw== X-Received: by 2002:a05:6808:138b:b0:3d9:e109:a6d3 with SMTP id 5614622812f47-3de2a8a8f3bmr3480735b6e.26.1724436024554; Fri, 23 Aug 2024 11:00:24 -0700 (PDT) Received: from LOCLAP699.locus-rst-dev-locuspark.locus ([152.193.78.90]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-454fe0f0507sm19683131cf.47.2024.08.23.11.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Aug 2024 11:00:24 -0700 (PDT) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 8/8] auto-t: add tests for Affinities behavior Date: Fri, 23 Aug 2024 11:00:06 -0700 Message-Id: <20240823180006.317353-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240823180006.317353-1-prestwoj@gmail.com> References: <20240823180006.317353-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)