From patchwork Wed Dec 20 13:11:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13500054 Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.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 D363825560 for ; Wed, 20 Dec 2023 13:12:11 +0000 (UTC) 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="hMEuJujf" Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-3b9f111c114so3820025b6e.1 for ; Wed, 20 Dec 2023 05:12:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703077930; x=1703682730; 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=p0r8COS43hybrdlcLSa48QXn75TJOVSuKgZDRTr3WWM=; b=hMEuJujfKcavHFpq/mW3ZItl/vdeDkmtpV1Utd2TWUrSVBs/rrCwz2OiG+az/s8yHY bIzpKm2JXAkzfHXEvGJ0VG8lpj4LY/KLty0l5urHBca5THEK7D2+bFsWOpva5tz+/voK KZ2YfIMyCP9G8gYkmwVrXibVW4L++sQi7/08nQa6vqBMeq5LWTOA/Ra7F36RXSUrFLE6 9J1AIBePrhwB/xNinHP6miyMgSmMqwZkDiCbHykfDF4PCTwegwppH2xEGxAr/82tDLRK FHmPeV2qC5/fVtqbJ1JqIWAdBJiS1SKMqpHcwFegti5is8LlhElrkMxcSQ6NCN7aCSaV Mt1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703077930; x=1703682730; 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=p0r8COS43hybrdlcLSa48QXn75TJOVSuKgZDRTr3WWM=; b=qGYotZujzRYUIL06vCnp+JFmAgrw26YoRsXa+RZDo1WHeMnriYPYG5ZV0PW2iYk5O2 +nW7bkghQRJAVigQt4tNRTLsL5//vPTEt+aFkQCfUgIygZE2moycnaTwb0mYy8mzq3sp WeUzo7awwJ1OeVFXTX6au8/Tb0QVPVWDyDvpkI8fPNpwkkuBlzTJdNyt0jxcswCTNA1Y jvA+NiIxwz1GRrl0j/1tRILIIQhKHBTD/8E3/KkJ99WfTrsqO8U2jZuMwIqChzrCemWb O//COtw9xdXcyLGiKg9VtZsfrqAd4md2Y/SjtyuErjufeHUvtinOMVjGZ5a9w1KBZw4W Gukw== X-Gm-Message-State: AOJu0Yy4TB6WKBFNQ3AB0y8vJEKn+VX0CpIM+yBUgMEAPeYmnCflm07i 940ycL7tCYMrUW8pnNEqC4dd10qRjZ0= X-Google-Smtp-Source: AGHT+IEnHsXZlP7tGbC6JgqRQZWYzDpmcqwafcU1dTdJ+GutUYauSFatgqAtwtsVJ2FXt3qSIenuSg== X-Received: by 2002:a05:6808:3cf:b0:3b8:b063:5d8e with SMTP id o15-20020a05680803cf00b003b8b0635d8emr19467748oie.117.1703077930517; Wed, 20 Dec 2023 05:12:10 -0800 (PST) Received: from LOCLAP699.barrett-olive-branch.locus ([50.222.209.222]) by smtp.gmail.com with ESMTPSA id j15-20020aca170f000000b003ba3a9c553esm2109591oii.30.2023.12.20.05.12.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:12:09 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 1/7] known_network: rename known_network_add_frequency Date: Wed, 20 Dec 2023 05:11:54 -0800 Message-Id: <20231220131200.267489-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231220131200.267489-1-prestwoj@gmail.com> References: <20231220131200.267489-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Rename to known_network_add_seen_frequency. This prepares to differentiate between tracking frequencies based on a BSS being seen versus being connected to. When a BSS has been connected to that frequency should be preferred when roaming/quick scanning. --- src/knownnetworks.c | 3 ++- src/knownnetworks.h | 3 ++- src/network.c | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/knownnetworks.c b/src/knownnetworks.c index 04ce74ec..eac6c66b 100644 --- a/src/knownnetworks.c +++ b/src/knownnetworks.c @@ -566,7 +566,8 @@ static bool known_frequency_match(const void *a, const void *b) * Adds a frequency to the 'known' set of frequencies that this network * operates on. The list is sorted according to most-recently seen */ -int known_network_add_frequency(struct network_info *info, uint32_t frequency) +int known_network_add_seen_frequency(struct network_info *info, + uint32_t frequency) { struct known_frequency *known_freq; diff --git a/src/knownnetworks.h b/src/knownnetworks.h index e8ffac0b..d404b161 100644 --- a/src/knownnetworks.h +++ b/src/knownnetworks.h @@ -114,7 +114,8 @@ struct network_info *known_networks_find(const char *ssid, struct scan_freq_set *known_networks_get_recent_frequencies( uint8_t num_networks_tosearch); -int known_network_add_frequency(struct network_info *info, uint32_t frequency); +int known_network_add_seen_frequency(struct network_info *info, + uint32_t frequency); void known_network_frequency_sync(struct network_info *info); uint32_t known_networks_watch_add(known_networks_watch_func_t func, diff --git a/src/network.c b/src/network.c index 4723334e..3e8770bc 100644 --- a/src/network.c +++ b/src/network.c @@ -807,7 +807,7 @@ static void add_known_frequency(void *data, void *user_data) struct scan_bss *bss = data; struct network_info *info = user_data; - known_network_add_frequency(info, bss->frequency); + known_network_add_seen_frequency(info, bss->frequency); } void network_set_info(struct network *network, struct network_info *info) @@ -1094,7 +1094,7 @@ bool network_bss_add(struct network *network, struct scan_bss *bss) return false; if (network->info) - known_network_add_frequency(network->info, bss->frequency); + known_network_add_seen_frequency(network->info, bss->frequency); /* Done if BSS is not HS20 or we already have network_info set */ if (!bss->hs20_capable) @@ -1131,7 +1131,7 @@ bool network_bss_update(struct network *network, struct scan_bss *bss) /* Sync frequency for already known networks */ if (network->info) { - known_network_add_frequency(network->info, bss->frequency); + known_network_add_seen_frequency(network->info, bss->frequency); known_network_frequency_sync(network->info); } From patchwork Wed Dec 20 13:11:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13500055 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 681D225541 for ; Wed, 20 Dec 2023 13:12:12 +0000 (UTC) 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="Y1IAxffI" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3ba1be5ad0aso3828330b6e.0 for ; Wed, 20 Dec 2023 05:12:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703077931; x=1703682731; 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=okalQclEjrZbYfXcH/b2xNsErvaxrMNmJdqBPJuStic=; b=Y1IAxffIS0w/a2eNTmXXQSzHFtvvPMngOe/w7tW5fFFK6M9SdaRf/sO0SjUyieWIfq fYoZfMMzFd31ZzfK7tGyopeUZ0ffl5ozVdbrt7wt2WSQ8MKyvZR1Jnf8eJO0yhHBf5fW sIRAqmZihPBJFTCtR0TVidVDLAFNVj4SjUCL2t6qHB6m50KPfMhkTGV9oIZvH8LVbWVG VlpJ82RfwqXqkpAg4ze9hUdOhOLLgNI5QDhStziXhv8Pm512WQBwyoZYl88FfCrYuhRV ITv8Ax6YMsdLkJxgZBSt9oqI0J5YW0XVChywfkEL4Sq4ck539HfrdP86TTl1sY61+Rjo WLAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703077931; x=1703682731; 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=okalQclEjrZbYfXcH/b2xNsErvaxrMNmJdqBPJuStic=; b=h6i75RWwqHaL7BZhwXMaMUK8ENN9E3mmtYKMqiUK4+8txr3x+HSeqpKpPnnU6uc35d asoqyd/nkI9fusVlo274/lR9I4OiOF0A4u4V5aGP1zr+oTJYcn1l1m4y2ijikI1ECvwA Uf2xmcXHA6Dw989w7QI3B3Ir5QtQ8HjoHX+n3ZCAWZzhaYFjFsCAk1lIreHdnv2bfS5/ 38XVW42JJyGWxDNdESDh3kFejxHHZomaxSchWOSmsbFF1XT9XxOpSQJ94EW8R6V2WpAq DgS8QzoCTa7h7KTvVSZMeRqjRq2SEPQpV8iwPNJ4Sboe1+buamWUOlT1eEaqJH+5xzH8 GexA== X-Gm-Message-State: AOJu0YwJcNZ96yfqLIYXo4M6Ydd2uw2iFCDTCMc3r00Ty69tx+6k+jXw o6qJT6RMZQaA08Kod+h6F67NAOGGSYM= X-Google-Smtp-Source: AGHT+IH8JeXjWy5INETsynjepva6lo7F5L1O1viJ+53vMs+VrwULjJsLXNRW9vyUkmCWaCjzwIMEVg== X-Received: by 2002:a05:6808:2227:b0:3bb:6a4d:deaf with SMTP id bd39-20020a056808222700b003bb6a4ddeafmr2105445oib.83.1703077931344; Wed, 20 Dec 2023 05:12:11 -0800 (PST) Received: from LOCLAP699.barrett-olive-branch.locus ([50.222.209.222]) by smtp.gmail.com with ESMTPSA id j15-20020aca170f000000b003ba3a9c553esm2109591oii.30.2023.12.20.05.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:12:11 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 2/7] knownnetworks: add known_network_add_connected_frequency Date: Wed, 20 Dec 2023 05:11:55 -0800 Message-Id: <20231220131200.267489-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231220131200.267489-1-prestwoj@gmail.com> References: <20231220131200.267489-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This should be called when BSS is connected/roamed to which will insert the frequency ahead of entries which were only seen in scan results. Providing this and the 'seen' variant sets up the frequency list into two adjacent sections: [Most recently used]...[Most recently seen] Doing this will allow scanning to be more optimized and limit the number of frequencies while prefering BSS's that have been connected to prior. Note that this list format is not synced to the file system. Frequencies will be synced in the order of this list but not containing the 'connected' bit. When IWD restarts this information will be lost, but the list is still sorted on disk in a better state than it was prior. --- src/knownnetworks.c | 59 ++++++++++++++++++++++++++++++++++++++++++++- src/knownnetworks.h | 3 +++ 2 files changed, 61 insertions(+), 1 deletion(-) diff --git a/src/knownnetworks.c b/src/knownnetworks.c index eac6c66b..e44109fd 100644 --- a/src/knownnetworks.c +++ b/src/knownnetworks.c @@ -562,15 +562,70 @@ static bool known_frequency_match(const void *a, const void *b) return known_freq->frequency == *frequency; } +static int known_frequency_compare(const void *a, const void *b, + void *user_data) +{ + const struct known_frequency *ka = a; + + /* + * Only meant to be used to insert 'seen' frequencies. Any existing + * entry that has 'connected' set should preceed an entry that was + * only seen. + */ + if (ka->connected) + return -1; + + /* + * Otherwise, insert immediately after the last 'connected' entry, + * i.e. the most recently seen + */ + return 1; +} + /* * Adds a frequency to the 'known' set of frequencies that this network - * operates on. The list is sorted according to most-recently seen + * operates on. Frequencies added here will follow frequencies which have been + * connected to and inserted according to most-recently seen */ int known_network_add_seen_frequency(struct network_info *info, uint32_t frequency) { struct known_frequency *known_freq; + if (!info->known_frequencies) + info->known_frequencies = l_queue_new(); + + known_freq = l_queue_find(info->known_frequencies, + known_frequency_match, &frequency); + /* + * If no match, create a new one. + * If connected to frequency before leave that entry in place + */ + if (!known_freq) { + known_freq = l_new(struct known_frequency, 1); + known_freq->frequency = frequency; + } else if (known_freq->connected) + return 0; + + l_queue_remove(info->known_frequencies, known_freq); + + /* insert the entry immediately after the last 'connected' entry */ + l_queue_insert(info->known_frequencies, known_freq, + known_frequency_compare, NULL); + + return 0; +} + +/* + * Adds a frequency to the known set of frequencies that this network operates + * on. Frequencies added here are assumed to be most recently used and inserted + * at the head of the queue. + */ +int known_network_add_connected_frequency(struct network_info *info, + uint32_t frequency) +{ + struct known_frequency *known_freq; + if (!info->known_frequencies) info->known_frequencies = l_queue_new(); @@ -581,6 +636,8 @@ int known_network_add_seen_frequency(struct network_info *info, known_freq->frequency = frequency; } + known_freq->connected = true; + l_queue_push_head(info->known_frequencies, known_freq); return 0; diff --git a/src/knownnetworks.h b/src/knownnetworks.h index d404b161..644e713f 100644 --- a/src/knownnetworks.h +++ b/src/knownnetworks.h @@ -96,6 +96,7 @@ typedef void (*known_networks_destroy_func_t)(void *user_data); struct known_frequency { uint32_t frequency; + bool connected : 1; }; void __network_config_parse(const struct l_settings *settings, @@ -116,6 +117,8 @@ struct scan_freq_set *known_networks_get_recent_frequencies( uint8_t num_networks_tosearch); int known_network_add_seen_frequency(struct network_info *info, uint32_t frequency); +int known_network_add_connected_frequency(struct network_info *info, + uint32_t frequency); void known_network_frequency_sync(struct network_info *info); uint32_t known_networks_watch_add(known_networks_watch_func_t func, From patchwork Wed Dec 20 13:11:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13500056 Received: from mail-oi1-f170.google.com (mail-oi1-f170.google.com [209.85.167.170]) (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 356452554B for ; Wed, 20 Dec 2023 13:12:12 +0000 (UTC) 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="XScBBOT9" Received: by mail-oi1-f170.google.com with SMTP id 5614622812f47-3ba2dc0f6b7so4494217b6e.2 for ; Wed, 20 Dec 2023 05:12:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703077932; x=1703682732; 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=CQsffKd75SXUXTs1iJokSm7cplWNDRyOZ77HR3l3p8A=; b=XScBBOT9fbVn3f5PemgaQwwcXwFnvORbF/KBkjmP5VEo/q8CDNJqD+VGsr8v2Ahlv8 NGrVCKvWJpVFC9tIChvt2WaIBCAvqnPftNtCcq3pV5mSBNbeySkTjtK+Vki1f4lhl5Nn DyQUS7ieMgXe8JNdSNz5IBRmjC2VzKsJFltQRKZw4v9Ri8+ayk8RxC3b49qg4BNS6B4A DPo0Tkw9t1Pa303b0rWQEta8hKXNPltZopqMvCPyiFtgfE6AbMkmLpvaP0I1Dd6t3QxQ TUIVtae26uWA0zNlM35nMLbOWzZbUm98RWdGb+DHTCYNzcQBV+1tTkeXm+WjkyK6FTKi ys4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703077932; x=1703682732; 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=CQsffKd75SXUXTs1iJokSm7cplWNDRyOZ77HR3l3p8A=; b=p2FQV1nTmJdNcEDwAuYuGkFcuKn3l5P5M64kH8BMaWpLfkxabJf/5IKQ1Jutx54NM1 hdmw+AlpPh0rgJl8UzF8GFG1ji2+s2sKj0wnUvcEp0+wzIMFA0re3s4XhfStithLhp9F broEj7Gel8wCXu0hdGEJsFPrHfd4EB6us3MDcABB3/00ULQTrx4boutFqVADH4+/5lm4 uEGNW6KBjn6noTZpY7daBorJ/8UU5K2VOisWLk5SLe8OM+pgF+zlcFZNLHxjdPy2hToA 1CFUj8SDVUsufnK+Usa/UbV/n5RxxQiC78PBQsXRzKUYAgt3WeBxKLh/ktjryGMladCe Ck9w== X-Gm-Message-State: AOJu0Yzinw5v6iOlewYu3/3zeMr9Yy5CaP7vAuLEEAlfq14OGdvpkmcz SeoJiBeE9/UV0HXeJM8r6uscsqPrruY= X-Google-Smtp-Source: AGHT+IFHaT1eyV7HVi0mjBmt9z9GrgqVH+EJerhGILtTLGdLYSXRLOxknvBoY10vtiXISyaxgRYn0g== X-Received: by 2002:a05:6808:1248:b0:3b9:e828:819 with SMTP id o8-20020a056808124800b003b9e8280819mr25369822oiv.44.1703077932137; Wed, 20 Dec 2023 05:12:12 -0800 (PST) Received: from LOCLAP699.barrett-olive-branch.locus ([50.222.209.222]) by smtp.gmail.com with ESMTPSA id j15-20020aca170f000000b003ba3a9c553esm2109591oii.30.2023.12.20.05.12.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:12:11 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 3/7] network: call network_connected with BSS Date: Wed, 20 Dec 2023 05:11:56 -0800 Message-Id: <20231220131200.267489-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231220131200.267489-1-prestwoj@gmail.com> References: <20231220131200.267489-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 This will allow the BSS frequency to be inserted at the head of the known frequency list, allowing future scans to prefer that frequency. --- src/network.c | 4 +++- src/network.h | 2 +- src/station.c | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/network.c b/src/network.c index 3e8770bc..f4496c25 100644 --- a/src/network.c +++ b/src/network.c @@ -167,7 +167,7 @@ static bool network_secret_check_cacheable(void *data, void *user_data) return false; } -void network_connected(struct network *network) +void network_connected(struct network *network, struct scan_bss *bss) { enum security security = network_get_security(network); const char *ssid = network_get_ssid(network); @@ -190,6 +190,8 @@ void network_connected(struct network *network) if (err < 0) l_error("Error %i touching network config", err); + known_network_add_connected_frequency(network->info, + bss->frequency); /* Syncs frequencies of already known network*/ known_network_frequency_sync(network->info); } diff --git a/src/network.h b/src/network.h index f29649f7..e7638899 100644 --- a/src/network.h +++ b/src/network.h @@ -31,7 +31,7 @@ struct scan_bss; struct handshake_state; struct erp_cache_entry; -void network_connected(struct network *network); +void network_connected(struct network *network, struct scan_bss *bss); void network_disconnected(struct network *network); bool network_rankmod(const struct network *network, double *rankmod); diff --git a/src/station.c b/src/station.c index 73de26bb..4facc0bc 100644 --- a/src/station.c +++ b/src/station.c @@ -3213,7 +3213,7 @@ static void station_connect_ok(struct station *station) l_warn("Could not request neighbor report"); } - network_connected(station->connected_network); + network_connected(station->connected_network, station->connected_bss); if (station->netconfig) { if (hs->fils_ip_req_ie && hs->fils_ip_resp_ie) { From patchwork Wed Dec 20 13:11:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13500057 Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (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 4B3FD25541 for ; Wed, 20 Dec 2023 13:12:14 +0000 (UTC) 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="ia6xTvCT" Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3ba0dfc9001so2084461b6e.2 for ; Wed, 20 Dec 2023 05:12:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703077933; x=1703682733; 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=TGa/niltCdochZCsnG/npuCftI6ucY1Yl9oYnXxqKh0=; b=ia6xTvCTzIJH9kzLVtXRX8H3GJzwamHH7fMQ04+iHPmyFbBLTKDuHc88++nuD9h024 kOWOqeKlnPFgnQ7p9UO31d+d4fSfwuzWQYgoDQuqcmMmwiP+MKn3u3x2VMBv8Oi8vnxh 1A7mgoLvvIbZbRWkLPqF6fPLLrqZHT7QFhqPduLsljDDd8pejgtRSZnA3hPbKa9O6nnF yzuAmxcqH+79gLOSSO6puKI7FDV10FrKOFMASR2Yg5/h5rDr700qE7xONJvDvf+cb/Rx Y+AYh+ZOtod1FYf5oHeeZyr/UeEjaHSProG3tTmjyCJDsYBmJw2MUp3Y56DsXvDpzKTr bQJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703077933; x=1703682733; 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=TGa/niltCdochZCsnG/npuCftI6ucY1Yl9oYnXxqKh0=; b=BnTviRSMuCVm15IMaopIUQ85ymiGjN22w+ulFhbaGaIhuPlmaIsTK7klk7Qf3rcsK2 bh6CH2aE/26nrONQgLwYUNZkxz5sl0LmZzpmDWs/2+SONw3xzyzmLbdcseS4kAzl5/19 BVCmtcP1V0L8vlbXXzyG4l4ySdszUR/O+FCVv4pJZcUJhJu63XBEprn1EjeLRVRMY7yI D3S7yFVOXWY7hHnGrNEpmbF7UI2zNnqcTtG8lWdN8/nTLH0dOldqRcA0JQjZr3uOACnj XpejJHeNQzx7IN0pFgClCb+puPDbZJN5q/CVEyBkrcVCAO4lBTzg1We1r0UPecIN2iEY VvDA== X-Gm-Message-State: AOJu0Yw9s+IxtQ7v0HvoXxY4gdCg0anv9WOT2DJhBaynpXXQOzhqrXY3 xaNtmSheRO3dmx9g6PHPvU3eo7L81V4= X-Google-Smtp-Source: AGHT+IF4MNdBQqbxV31b8xGHzhKadKOiAFCmoiA9BWq6CzL20PmxDRtJBhWZSHvTgSyXvpqXIeLFww== X-Received: by 2002:a05:6808:10c3:b0:3b8:b063:8949 with SMTP id s3-20020a05680810c300b003b8b0638949mr13777562ois.87.1703077933060; Wed, 20 Dec 2023 05:12:13 -0800 (PST) Received: from LOCLAP699.barrett-olive-branch.locus ([50.222.209.222]) by smtp.gmail.com with ESMTPSA id j15-20020aca170f000000b003ba3a9c553esm2109591oii.30.2023.12.20.05.12.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:12:12 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 4/7] network: add network_roamed Date: Wed, 20 Dec 2023 05:11:57 -0800 Message-Id: <20231220131200.267489-5-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231220131200.267489-1-prestwoj@gmail.com> References: <20231220131200.267489-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Allows known frequencies to include the roam BSS frequency and sync. --- src/network.c | 9 +++++++++ src/network.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/network.c b/src/network.c index f4496c25..04d1bf82 100644 --- a/src/network.c +++ b/src/network.c @@ -204,6 +204,15 @@ void network_connected(struct network *network, struct scan_bss *bss) network->provisioning_hidden = false; } +void network_roamed(struct network *network, struct scan_bss *bss) +{ + if (network->info) { + known_network_add_connected_frequency(network->info, + bss->frequency); + known_network_frequency_sync(network->info); + } +} + void network_disconnected(struct network *network) { network_settings_close(network); diff --git a/src/network.h b/src/network.h index e7638899..323f64a5 100644 --- a/src/network.h +++ b/src/network.h @@ -32,6 +32,7 @@ struct handshake_state; struct erp_cache_entry; void network_connected(struct network *network, struct scan_bss *bss); +void network_roamed(struct network *network, struct scan_bss *bss); void network_disconnected(struct network *network); bool network_rankmod(const struct network *network, double *rankmod); From patchwork Wed Dec 20 13:11:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13500058 Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com [209.85.167.173]) (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 E545C2554B for ; Wed, 20 Dec 2023 13:12:14 +0000 (UTC) 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="POE3WztX" Received: by mail-oi1-f173.google.com with SMTP id 5614622812f47-3bb69bfdd96so312850b6e.1 for ; Wed, 20 Dec 2023 05:12:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703077934; x=1703682734; 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=LvmFgFondgk5j95mpyYVC3tI+V7ZP2BtN2K2TDXIRuo=; b=POE3WztXCFiiH5P1GU6r//0w+V4NKnI8QujkTAXwQ6dkeAJxd5dK6UpYLM5op6qO+K J2egifpngzBwwTQnQzxLOefCcZCaSBtSxdLoOuCywH7tNDtd4P3crAoZNIFRHmqzte84 8XOfLOezYqQwWqEqKMLSyHRZR61nb3Uzt7U2/ToWLBjp9a8moDjLNTSyH4vNcKH8yl9i 7UGzBv8zV7ftd9zGEtbaa5SlF4sqfuIsYkdwV4FlkySlOR8j8jWxR86CBg0vbhfh/f+u E1oHLhBULmfnjQCUBYolqgr2XqjnYJI1bDWFSAt+9yY92/bC8LL2O9EyygyjHP1Dboj+ GEDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703077934; x=1703682734; 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=LvmFgFondgk5j95mpyYVC3tI+V7ZP2BtN2K2TDXIRuo=; b=Y5CmOtHfaf4TBt2PKVkHezZ8rfLPt4kdh+LJeEWRsQvYq80yJKkHetHUQFsVOYi9mb dgPW1vocKNmBNNkyKihdMRC1n3GpT6ZZ7t4YHIHRz9l7Rem+9Hb09sTH0c8np8abGET+ il2vA21pQF3q53r1qjDVO8i6cvsT2TzlqDp9Gq3xMoW/oMGOb5RNLyaOMRWfL0MwVu75 7D/WI2gWYUNFoQRgvY/QuTz8lQcUivUGBQMS/NAr9RooWpT2uC+Gkzvpyt5VdyNHQWEa jUFZWWj0kDifjdflpJ7vxXlzNhsZs+VP2Atr1fAMNkpBf+l/7JU55da4J/vCesa7igc9 hPeg== X-Gm-Message-State: AOJu0YzM2+FwCu8VAPpyaV69DLGi8drSvk8Um+7CKtxpZszAj4Ro1T2K xJ02JsYbmnS8hcB0BStKjj1IYwqg/WU= X-Google-Smtp-Source: AGHT+IF9F1bSEvmw6DyJubJhzUwVP5gC6NMgMfVd6T9hFZxkxE6hUL8CPI3Ydwp83ApKplnPW0CLXA== X-Received: by 2002:a05:6808:de6:b0:3b9:d5e6:2f7c with SMTP id g38-20020a0568080de600b003b9d5e62f7cmr990801oic.49.1703077933855; Wed, 20 Dec 2023 05:12:13 -0800 (PST) Received: from LOCLAP699.barrett-olive-branch.locus ([50.222.209.222]) by smtp.gmail.com with ESMTPSA id j15-20020aca170f000000b003ba3a9c553esm2109591oii.30.2023.12.20.05.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:12:13 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 5/7] station: use network_roamed Date: Wed, 20 Dec 2023 05:11:58 -0800 Message-Id: <20231220131200.267489-6-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231220131200.267489-1-prestwoj@gmail.com> References: <20231220131200.267489-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 --- src/station.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/station.c b/src/station.c index 4facc0bc..10860808 100644 --- a/src/station.c +++ b/src/station.c @@ -2106,6 +2106,8 @@ static void station_roamed(struct station *station) L_WARN_ON(!netconfig_after_roam(station)); } else station_enter_state(station, STATION_STATE_CONNECTED); + + network_roamed(station->connected_network, station->connected_bss); } static void station_roam_retry(struct station *station) From patchwork Wed Dec 20 13:11:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13500059 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 A530B2577A for ; Wed, 20 Dec 2023 13:12:15 +0000 (UTC) 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="UH5EJjl0" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3bb7376957eso179711b6e.1 for ; Wed, 20 Dec 2023 05:12:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703077935; x=1703682735; 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=DsEtghFtj+9LnD5X9azSosd8tgs2IfaQyu9KNm9uktw=; b=UH5EJjl0/vMV93VbFrOAKtU4Rs4wd1y0+S/nw32tNF9VtWZe/F487aL0M4zQlRKyun HLGi3bnF2re1Wjzvo/BB9lVcqs8uR6GRZPjqiFd861jcPnanYHRIy6zxiV1s2BMwVnh6 Xy933uSL31WBZ1MpypouKQN0eehnackpBIydXz/iIqHaH1OGyYl9NftUdtsXTrdfuqQP Dzgg/hzxrgppc4i3TK5qFCpL4knPuI8/2VinywufdaNIWf3ULwQnD/pwuga9e9dB1RUT Pb+YdyashRP1XYWXCwN6az5ZKBBIjqKy/hkrAEJK/DOfqIqhme9z72UaLUukWb/2OSqS PZ5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703077935; x=1703682735; 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=DsEtghFtj+9LnD5X9azSosd8tgs2IfaQyu9KNm9uktw=; b=hwSWHzrb56U5nehAMSg+QdacDK4kNhGZUovp2PVQ898L4VnYW5iT0tGVPN+4VNBtRp ePHkOXs01wIGpFzlckUBo7tzElHOai5RaUEP93AIeKheRwrw7EUdEnXH3UsWQYonnxS9 3Y6S+IxKWuy6P5tpIUPqGjYP+YPnjYhcSOStAd7VjJahwuEKgF1tQuogX6NY3ThHfu9m 1nYcm+SDUrLBpOns/I7FvM8ZgLgF0x6yHo5omih4eTw2bDN7yNlGqtZqpBOnSqzyUIis pJUOEBTHUqf9V5XIJiAo3pLHVfHjEOBsT+Vo5QoU/1x7A4zjhcok064Ev+TEmpi5gnzp xVWQ== X-Gm-Message-State: AOJu0YwyLvOUNPq0TONWDE5GFdObJ/lL0PGs6Yu3dHpNCVAmDWRcWIXb 5PHNNn0BblK+mowQ8wh8BkTMZxYrwSo= X-Google-Smtp-Source: AGHT+IHviob5yEA54/ahRvOC8e8hIZlbrx+Y2SV8eimkyTkyvW/88Nf3D0LlFlv1CXSqCN5tSOrMww== X-Received: by 2002:a05:6808:2dcc:b0:3ba:f4a:4310 with SMTP id gn12-20020a0568082dcc00b003ba0f4a4310mr24391428oib.11.1703077934667; Wed, 20 Dec 2023 05:12:14 -0800 (PST) Received: from LOCLAP699.barrett-olive-branch.locus ([50.222.209.222]) by smtp.gmail.com with ESMTPSA id j15-20020aca170f000000b003ba3a9c553esm2109591oii.30.2023.12.20.05.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:12:14 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 6/7] auto-t: update known frequency test to check order Date: Wed, 20 Dec 2023 05:11:59 -0800 Message-Id: <20231220131200.267489-7-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231220131200.267489-1-prestwoj@gmail.com> References: <20231220131200.267489-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Known frequencies are stored in order of most recently used, so add some logic to the test to exercise the reordering of frequencies as connections are made. --- autotests/testKnownNetworks/frequency_test.py | 122 +++++++++++++----- autotests/testKnownNetworks/hw.conf | 10 +- .../{ssidCCMP-2G.conf => ssidCCMP-2G-1.conf} | 0 .../testKnownNetworks/ssidCCMP-2G-2.conf | 8 ++ autotests/testKnownNetworks/ssidHotspot.conf | 2 +- 5 files changed, 102 insertions(+), 40 deletions(-) rename autotests/testKnownNetworks/{ssidCCMP-2G.conf => ssidCCMP-2G-1.conf} (100%) create mode 100644 autotests/testKnownNetworks/ssidCCMP-2G-2.conf diff --git a/autotests/testKnownNetworks/frequency_test.py b/autotests/testKnownNetworks/frequency_test.py index 83e51c06..4443d2a1 100644 --- a/autotests/testKnownNetworks/frequency_test.py +++ b/autotests/testKnownNetworks/frequency_test.py @@ -8,13 +8,21 @@ import iwd from iwd import IWD from iwd import PSKAgent from iwd import NetworkType +from hostapd import HostapdCLI +from hwsim import Hwsim import testutil import os from configparser import ConfigParser +from dataclasses import dataclass + +@dataclass +class KnownFreq: + uuid: str + freqs: list class Test(unittest.TestCase): - def connect_network(self, wd, device, network): - ordered_network = device.get_ordered_network(network) + def connect_network(self, wd, device, network, scan=False): + ordered_network = device.get_ordered_network(network, full_scan=scan) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) @@ -29,7 +37,39 @@ class Test(unittest.TestCase): condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) + def read_known_freqs(self): + ret = {} + config = ConfigParser() + config.read('/tmp/iwd/.known_network.freq') + for s in config.sections(): + ret[os.path.basename(config[s]['name'])] = KnownFreq(s, config[s]['list'].split(' ')) + + return ret + def test_connection_success(self): + hostapd_psks = [ + HostapdCLI(config="ssidCCMP-2G-1.conf"), + HostapdCLI(config="ssidCCMP-2G-2.conf"), + HostapdCLI(config="ssidCCMP-5G.conf"), + ] + + hwsim = Hwsim() + + rule0 = hwsim.rules.create() + rule0.source = hostapd_psks[0].bssid + rule0.signal = -2000 + rule0.enabled = True + + rule1 = hwsim.rules.create() + rule1.source = hostapd_psks[1].bssid + rule1.signal = -5000 + rule1.enabled = True + + rule2 = hwsim.rules.create() + rule2.source = hostapd_psks[2].bssid + rule2.signal = -7000 + rule2.enabled = True + wd = IWD(True, '/tmp') psk_agent = PSKAgent("secret123") @@ -42,8 +82,7 @@ class Test(unittest.TestCase): # Connect to the PSK network, then Hotspot so IWD creates 2 entries in # the known frequency file. # - - self.connect_network(wd, device, 'ssidCCMP') + self.connect_network(wd, device, "ssidCCMP") wd.unregister_psk_agent(psk_agent) @@ -57,30 +96,27 @@ class Test(unittest.TestCase): psk_freqs = None psk_uuid = None hs20_freqs = None - hs20_uuid = None - config = ConfigParser() - config.read('/tmp/iwd/.known_network.freq') - for s in config.sections(): - if os.path.basename(config[s]['name']) == 'ssidCCMP.psk': - psk_freqs = config[s]['list'] - psk_freqs = psk_freqs.split(' ') - psk_uuid = s - elif os.path.basename(config[s]['name']) == 'example.conf': - hs20_freqs = config[s]['list'] - hs20_freqs = hs20_freqs.split(' ') - hs20_uuid = s + + freqs = self.read_known_freqs() + + psk_freqs = freqs['ssidCCMP.psk'] + hs20_freqs = freqs['example.conf'] # # Verify the frequencies are what we expect # self.assertIsNotNone(psk_freqs) - self.assertIsNotNone(psk_uuid) - self.assertIn('5180', psk_freqs) - self.assertIn('2412', psk_freqs) + self.assertIsNotNone(psk_freqs.uuid) + # Save to compare later + psk_uuid = psk_freqs.uuid + self.assertIn('5180', psk_freqs.freqs) + # First should be the connected network. The other two's order is + # unknown since its based on whenever the BSS was seen. + self.assertEqual(psk_freqs.freqs[0], '2412') self.assertIsNotNone(hs20_freqs) - self.assertIsNotNone(hs20_uuid) - self.assertIn('2412', hs20_freqs) + self.assertIsNotNone(hs20_freqs.uuid) + self.assertIn('2417', hs20_freqs.freqs) # # Forget all know networks, this should remove all entries in the @@ -92,11 +128,15 @@ class Test(unittest.TestCase): psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) + # Rank a different BSS higher + rule0.signal = -7000 + rule1.signal = -2000 + # # Reconnect, this should generate a completely new UUID since we # previously forgot the network. # - self.connect_network(wd, device, 'ssidCCMP') + self.connect_network(wd, device, 'ssidCCMP', scan=True) wd.unregister_psk_agent(psk_agent) @@ -107,21 +147,33 @@ class Test(unittest.TestCase): psk_freqs = None psk_uuid2 = None hs20_freqs = None - config = ConfigParser() - config.read('/tmp/iwd/.known_network.freq') - for s in config.sections(): - self.assertNotEqual(os.path.basename(config[s]['name']), - 'example.conf') - if os.path.basename(config[s]['name']) == 'ssidCCMP.psk': - psk_freqs = config[s]['list'] - psk_freqs = psk_freqs.split(' ') - psk_uuid2 = s + + freqs = self.read_known_freqs() + + psk_freqs = freqs['ssidCCMP.psk'] self.assertIsNotNone(psk_freqs) - self.assertIsNotNone(psk_uuid2) - self.assertNotEqual(psk_uuid, psk_uuid2) - self.assertIn('5180', psk_freqs) - self.assertIn('2412', psk_freqs) + self.assertIsNotNone(psk_freqs.uuid) + self.assertNotEqual(psk_uuid2, psk_freqs.uuid) + self.assertIn('5180', psk_freqs.freqs) + # The 2417 frequency BSS should be first + self.assertEqual(psk_freqs.freqs[0], '2417') + + # Rank the 5G BSS highest + rule0.signal = -7000 + rule1.signal = -7000 + rule2.signal = -2000 + + print("CONNECTING AGAGIn") + self.connect_network(wd, device, 'ssidCCMP', scan=True) + + freqs = self.read_known_freqs() + + psk_freqs = freqs['ssidCCMP.psk'] + + # The 5180 frequency BSS should now be first, followed by 2417 + self.assertEqual(psk_freqs.freqs[0], '5180') + self.assertEqual(psk_freqs.freqs[1], '2417') @classmethod def setUpClass(cls): diff --git a/autotests/testKnownNetworks/hw.conf b/autotests/testKnownNetworks/hw.conf index 8a7ef73a..9fb3dbd5 100644 --- a/autotests/testKnownNetworks/hw.conf +++ b/autotests/testKnownNetworks/hw.conf @@ -1,10 +1,12 @@ [SETUP] -num_radios=5 +num_radios=6 start_iwd=0 reg_domain=US +hwsim_medium=true [HOSTAPD] rad0=ssidNew.conf -rad1=ssidCCMP-2G.conf -rad2=ssidCCMP-5G.conf -rad3=ssidHotspot.conf +rad1=ssidCCMP-2G-1.conf +rad2=ssidCCMP-2G-2.conf +rad3=ssidCCMP-5G.conf +rad4=ssidHotspot.conf diff --git a/autotests/testKnownNetworks/ssidCCMP-2G.conf b/autotests/testKnownNetworks/ssidCCMP-2G-1.conf similarity index 100% rename from autotests/testKnownNetworks/ssidCCMP-2G.conf rename to autotests/testKnownNetworks/ssidCCMP-2G-1.conf diff --git a/autotests/testKnownNetworks/ssidCCMP-2G-2.conf b/autotests/testKnownNetworks/ssidCCMP-2G-2.conf new file mode 100644 index 00000000..0d806fde --- /dev/null +++ b/autotests/testKnownNetworks/ssidCCMP-2G-2.conf @@ -0,0 +1,8 @@ +hw_mode=g +channel=2 +ssid=ssidCCMP + +wpa=2 +wpa_pairwise=CCMP +wpa_passphrase=secret123 +beacon_int=10 diff --git a/autotests/testKnownNetworks/ssidHotspot.conf b/autotests/testKnownNetworks/ssidHotspot.conf index 95170c84..35b31fbe 100644 --- a/autotests/testKnownNetworks/ssidHotspot.conf +++ b/autotests/testKnownNetworks/ssidHotspot.conf @@ -1,6 +1,6 @@ #ctrl_interface=/var/run/hostapd hw_mode=g -channel=1 +channel=2 wpa=2 ssid=Hotspot rsn_pairwise=CCMP From patchwork Wed Dec 20 13:12:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13500060 Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 812092554B for ; Wed, 20 Dec 2023 13:12:16 +0000 (UTC) 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="hAzf1LSc" Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-3ba46a19689so4576167b6e.3 for ; Wed, 20 Dec 2023 05:12:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1703077935; x=1703682735; 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=XXM9fDGsJhcvLM2r6QHQn6cB2B8VNSaSk3keVtia3zo=; b=hAzf1LScxUDuzvv401xdD5u2ekxHIMGhMDg+cSJHUq1HbCgR76ZzfqCPFvG858oJc2 oN6sPMwjpa5EW9gtsHv4E/tY8uSZpc2R842sLJ7P4uk2/HKxsTzN6N+eSPk6oK81rw/q EHhOmu3AyjcZxkXTe3Xxxu4cqIsWWRRhUCOQ6PL5pcUgp0eVSSckEVyt0lEiPmv+W52z muozqKcqpN8xXlM/Jou7+DSmJyhifnaAtjC1ydPFS81ytjdxj8JaEHwKSdxnJwwjV7qL VPJNk4SqOj73wf5QiIIRHfD6n2oYDZqaR3Dl3u523xN3XfnnpVSoKcKZUvey9kCt21cI Km/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703077935; x=1703682735; 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=XXM9fDGsJhcvLM2r6QHQn6cB2B8VNSaSk3keVtia3zo=; b=D3rZRUORKwxo7qwZfq6rpi5YIltlCH96bC4IFisUXf9RjDiWDELqGU1eUToTgxWUe6 quRJ8TCgnnZUVi7GYabpiRstgohUhU2erID6svq0IepxQf5nRf8YewtQsYY9j+VMu7F/ uGJrRVWvUhpYSEAVVJGbVPESZZggPxSaCBvsQprF5s5a2OFnNlJEUma/13I8QHyy7xuO b5C8wMC7atOQjgNUzFDt5JJEHGM//avtmn05OCJ7LCkM24nbqNwrYSwKjoabyY6OzCF7 Td6Tj2EZOFqigZ3Yaw7AlYUvG5T3hzCzfM1ympt7FrI6Jqaoh1LBSU9sGtUdwO6dzE62 vZ1Q== X-Gm-Message-State: AOJu0YwPxoQHoQZoGXR9otQdZcNoiHy/2iUmtIYVIV/k9ivxfYYogLAr tfbPeXoccJ0bprhy4Cq0w7D1tx/yrVk= X-Google-Smtp-Source: AGHT+IFFmeBbA9zk+tGcOX0KHvjnZvmCHb73NLfdWNY4X/NZU7nBvRjB8WMOByruKUtirGqD583U1g== X-Received: by 2002:a05:6808:22a4:b0:3b8:44e3:dfda with SMTP id bo36-20020a05680822a400b003b844e3dfdamr23558857oib.3.1703077935464; Wed, 20 Dec 2023 05:12:15 -0800 (PST) Received: from LOCLAP699.barrett-olive-branch.locus ([50.222.209.222]) by smtp.gmail.com with ESMTPSA id j15-20020aca170f000000b003ba3a9c553esm2109591oii.30.2023.12.20.05.12.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Dec 2023 05:12:15 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH 7/7] knownnetworks: limit 5 recent frequencies per network Date: Wed, 20 Dec 2023 05:12:00 -0800 Message-Id: <20231220131200.267489-8-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231220131200.267489-1-prestwoj@gmail.com> References: <20231220131200.267489-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Since this is meant to be used for quick/roam scans we should be putting a cap on the frequencies scanned. For large networks with many BSS's this could end up scanning quite a few frequencies which isn't very 'quick' as it should be. Since the known frequency list is now sorted in most recently used order we can grab the first 5 frequencies per network and be somewhat confident that this will result in a BSS to connect to. --- src/knownnetworks.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/knownnetworks.c b/src/knownnetworks.c index e44109fd..ecdd79a1 100644 --- a/src/knownnetworks.c +++ b/src/knownnetworks.c @@ -540,10 +540,12 @@ struct scan_freq_set *known_networks_get_recent_frequencies( network_entry = network_entry->next, num_networks_tosearch--) { const struct network_info *network = network_entry->data; + uint8_t num_freqs = 5; for (freq_entry = l_queue_get_entries( network->known_frequencies); - freq_entry; freq_entry = freq_entry->next) { + freq_entry && num_freqs; + freq_entry = freq_entry->next, num_freqs--) { const struct known_frequency *known_freq = freq_entry->data;