From patchwork Fri Jan 26 20:22:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13533302 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.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 0A8F22230C for ; Fri, 26 Jan 2024 20:22:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706300570; cv=none; b=V8T4NqNRJLKkN9J5fmyiYsJ6f1b/X8LKk9OdwKbDwJHTtOEuMOGXOtqICj9c+2HJ1YDtwkFIjA65NJDTD0Ciyam3lhD1NecSQS8vhfyX8RdhJjbxiSUvgYKecU14yP4CwJmWKvKEf70Bz2HHe4IVDn6RyBC9QzD/7VLDYU3q0Xw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706300570; c=relaxed/simple; bh=AD1z9g6vaGTmslQEoP3TO6zF+quFZu1Lrkz2VMibbGE=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=mGCdUkM/Et0ju8x1lnfVLEvPtC2m1gOXLmrfjpc5IQu9zygF3ViOv8jWDOISf0ShwDmrGrHPlWJDr/rfxLMYXQY9WXPyIwRyn+UXln4PQKVfuIc33O5lJ3BNNANvH5HBjGrrEuIPwKmZPnEM8mT7bULssQfUrvcK7eCoRPKHNxA= 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=krAdW7X9; arc=none smtp.client-ip=209.85.160.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="krAdW7X9" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-42a75ec56dcso7789051cf.0 for ; Fri, 26 Jan 2024 12:22:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706300567; x=1706905367; 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=YPBb4mCw/R1ghl4eJw9QnLwDTvV7rYUlLLOC/s2r03U=; b=krAdW7X9mrhGijJYXk4xRW3RiMWNXpr//RcLo4VTjzoNvu/viezZe6I2NxWYj7mNpb PkSPGvIM6sqhhdS1K+YEc36lnMOn2ujaf/FJAWrmPhrXKjAQwveApcUMcR0hYPpnbZDf cFZK2PZE+BoAlXlU4IbBC/s/mbqG3mwa/owtgu0Z0WnF1v7pRfZ4wdP7UEvsXug4R45k WUmoPBflX8HJq9a2RzewsNnNnOnHqO9QkUyzTTYQQonq8Xi/5T6Y709SqRYTQca03yPw L1ZgzPkSLPyHurgx3rd7+ywevMmEyy0OKhI6rQNSygV01Nkvk+xCWvkf/o19cTmKfW2h 4iWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706300567; x=1706905367; 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=YPBb4mCw/R1ghl4eJw9QnLwDTvV7rYUlLLOC/s2r03U=; b=lhvGxrlehEnte8EVwovL+7BDhy8h6/98fYGrHO91WSd5t3Cboj0EAmCvkTk/yi4LA4 zDGzuslvcjVQU0mKhCIMnTKLnUqXSRQiOe8mKwK+hUGmwHwDrSMci54UDukjPnixxOOD wfmNUiu6GiwNl0k12lKirZW1ZTXeq+jdQgs7g+pfoO9EHFGZU58CgMdyiKwF5U10Jzq7 +275xpnue2p3CzY63aByWyP3lJouVhltsnTaGXIzuEhYfmb7f38Z/MVFzA/Z1ks4K7+r Pu3UKRLa0+sfDX5LFCJeXw/7XDkQhrdf9Bb+HkOuNPe6yA47yVIsnbVB/73iSHlNygBy qFUw== X-Gm-Message-State: AOJu0YxK0HuKkcOQ36RlZKk32OnJ3qa0fElfYMTuHveFt0mciDaJk6B7 ghj5lfWAsjpw0z8Ee0U/bNvxNbXjRWEOTjNxDghTr6YP9N48qdRjjpU8YIxcsRo= X-Google-Smtp-Source: AGHT+IFFOekxIQo5NLmKjcp6Qfd6UJ1cj0hkSu5Oi0GY555t6McTKV3GGs5vDgO5Juj+si8z0ZxPLQ== X-Received: by 2002:a05:622a:196:b0:42a:39ac:84e2 with SMTP id s22-20020a05622a019600b0042a39ac84e2mr454738qtw.10.1706300567611; Fri, 26 Jan 2024 12:22:47 -0800 (PST) Received: from LOCLAP699.rst-01.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id fe3-20020a05622a4d4300b0042a25f3950esm826463qtb.75.2024.01.26.12.22.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 12:22:47 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 1/4] network: add network_update_known_frequencies Date: Fri, 26 Jan 2024 12:22:40 -0800 Message-Id: <20240126202243.91947-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 In order to support an ordered list of known frequencies the list should be in order of last seen BSS frequencies with the highest ranked ones first. To accomplish this without adding a lot of complexity the frequencies can be pushed into the list as long as they are pushed in reverse rank order (lowest rank first, highest last). This ensures that very high ranked BSS's will always get superseded by subsequent scans if not seen. This adds a new network API to update the known frequency list based on the current newtork->bss_list. This assumes that station always wipes the BSS list on scans and populates with only fresh BSS entries. After the scan this API can be called and it will reverse the list, then add each frequency. --- src/network.c | 40 ++++++++++++++++++++++++++++------------ src/network.h | 2 ++ 2 files changed, 30 insertions(+), 12 deletions(-) v4: * Added an API to do the insertion once all the BSS's have been added to the network object. * I'm also ok adding something to ELL like: l_queue_new_reverse(list); The current reverse is in-place, so I cant really use it unless I wanted to reverse twice to get it back to decending order. diff --git a/src/network.c b/src/network.c index 4723334e..287e2be0 100644 --- a/src/network.c +++ b/src/network.c @@ -802,21 +802,13 @@ const struct network_info *network_get_info(const struct network *network) return network->info; } -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); -} - void network_set_info(struct network *network, struct network_info *info) { if (info) { network->info = info; network->info->seen_count++; - l_queue_foreach(network->bss_list, add_known_frequency, info); + network_update_known_frequencies(network); } else { network->info->seen_count--; network->info = NULL; @@ -1087,15 +1079,39 @@ static bool match_hotspot_network(const struct network_info *info, return true; } +bool network_update_known_frequencies(struct network *network) +{ + const struct l_queue_entry *e; + struct l_queue *reversed; + + if (!network->info) + return false; + + reversed = l_queue_new(); + + for (e = l_queue_get_entries(network->bss_list); e; e = e->next) { + struct scan_bss *bss = e->data; + + l_queue_push_head(reversed, bss); + } + + for (e = l_queue_get_entries(reversed); e; e = e->next) { + struct scan_bss *bss = e->data; + + known_network_add_frequency(network->info, bss->frequency); + } + + l_queue_destroy(reversed, NULL); + + return true; +} + bool network_bss_add(struct network *network, struct scan_bss *bss) { if (!l_queue_insert(network->bss_list, bss, scan_bss_rank_compare, NULL)) return false; - if (network->info) - known_network_add_frequency(network->info, bss->frequency); - /* Done if BSS is not HS20 or we already have network_info set */ if (!bss->hs20_capable) return true; diff --git a/src/network.h b/src/network.h index f29649f7..ea619f3f 100644 --- a/src/network.h +++ b/src/network.h @@ -61,6 +61,8 @@ void network_set_info(struct network *network, struct network_info *info); void network_set_force_default_owe_group(struct network *network); bool network_get_force_default_owe_group(struct network *network); +bool network_update_known_frequencies(struct network *network); + int network_can_connect_bss(struct network *network, const struct scan_bss *bss); int network_autoconnect(struct network *network, struct scan_bss *bss); From patchwork Fri Jan 26 20:22:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13533303 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.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 1C3C22260B for ; Fri, 26 Jan 2024 20:22:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706300571; cv=none; b=EK+iz2J1ZXqcBRdDErgn1Kne21hyxGseRHU6u6/DHwM/K9VG0fZCjPs6rl/1EZr6mCFs9+CUOGnRmJ7dx6dOKN0YoS+8DmS8tjrUwtYRC9J1ubHCDaqdwQbp007+PDZG1JO8asB9Oxebjl5jcp3+L5u/K8BWFNSbz94FHGxcO/k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706300571; c=relaxed/simple; bh=W4iMwkE9iQ02GeuGwH8BAo68hrjmStDaoPV5BDUIwu8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=d/BFsQXSc71LbUQDXW6PnARJDXqCPTNbXGO8fsqW77hVyTBxNq6QtxT1VyOiJp/DM0z31FwA/8c1KY6sc4PDp/N2zBksQqG14okRcNQZ+pnqFIQzU5LIbakWJcB+r8h7vQVmELjyQGtWsXM7URu/oLViekz53/YkKhDseAVKNRc= 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=RVxysvV8; arc=none smtp.client-ip=209.85.160.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RVxysvV8" Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-4298b23abffso6753501cf.0 for ; Fri, 26 Jan 2024 12:22:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706300569; x=1706905369; 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=Xs3+rSdiYsZ+AL1JTeDJXl9LKEZVoBz4NKzp2eGlKfc=; b=RVxysvV8rkI1kF4fz/QKo9ApkC9VTcTV0wNu/Fq7yaRokFXOLttQgOmfu4g7i1i7vb p1nOhU19z/ZZQ72r6W0qiuRWsMIpFdKaK/ND5tFaneboxt9xzBT58oe/fmhM1EfvQKAK RB3iz198yPWn2vtVxEvQQyPu5u9qNm39Q5o6a0AjfYIzDEupH+dffe9r0Md4B6CscP9O zIuWrcdxFRdqUhZ+us73rWJb3OXVzlXoE/N81lbuMWE2+K4LJGKL83DaWtH7iah5TTeF SnuFLRsgH+NWqButy79Yuyep4hlmLK3ZdtqsFOY3srnbeAdW/ACc491fn12AOi0ISR3d JR/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706300569; x=1706905369; 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=Xs3+rSdiYsZ+AL1JTeDJXl9LKEZVoBz4NKzp2eGlKfc=; b=Y6zS2HkzfMbfp34D1Cbnnha09w9Y9J8ptCNuMHTtYTaBWOywddSOdzppIHZRhfNzgj vzN+OQCsFMkoDBWmy7vm4oafHfl1uGBbneP0iYI/8vhZW3oUSKU54cqZwt/8Ra5CEzWa uycdH4VYZTYTYb4lVEwEAUvOKvQ/255agL4iJ90O3bY8BrehQBLD1YM8qVbn84Iwj2Bb LdV3Rb8kqXZHF81Y7M1mJ8tAtPmfzjXelcmDmiGt2RrefWU5UIrjmPTXZGKNEgbA197a COdWQprPgmxfCnnMSPPaq5viigcAU0E0DC3M9VDQVnlGOPUFsa3QySkAeHysqA9pQyjY ftuw== X-Gm-Message-State: AOJu0YyPv9aaDMtf50AM5Y7DTM3EnFZxozoUQm7IncnPzWO5OZ83+MzE Y8YyB89qyhfPn8WuKbW0/Htv84viSL5Yg5qFBbSUEeDTGgbmuDXruBT0mVznDpU= X-Google-Smtp-Source: AGHT+IGpzN+WPE/FQSzk29et12yV9hj3OkK2c/6nySvjhLm9sOLUVhgyQYMbCPYaVc0C7ZGWjukr8w== X-Received: by 2002:a05:622a:100e:b0:42a:75ab:ff09 with SMTP id d14-20020a05622a100e00b0042a75abff09mr413667qte.74.1706300568669; Fri, 26 Jan 2024 12:22:48 -0800 (PST) Received: from LOCLAP699.rst-01.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id fe3-20020a05622a4d4300b0042a25f3950esm826463qtb.75.2024.01.26.12.22.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 12:22:48 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 2/4] station: use network_update_known_frequencies Date: Fri, 26 Jan 2024 12:22:41 -0800 Message-Id: <20240126202243.91947-2-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240126202243.91947-1-prestwoj@gmail.com> References: <20240126202243.91947-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Updates each network with its new, most current, set of BSS's for the different types of scans: dbus/autoconnect, hidden, and OWE. --- src/station.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/station.c b/src/station.c index a6442d3e..b186c505 100644 --- a/src/station.c +++ b/src/station.c @@ -350,6 +350,8 @@ static bool process_network(const void *key, void *data, void *user_data) l_queue_insert(station->networks_sorted, network, network_rank_compare, NULL); + network_update_known_frequencies(network); + return false; } @@ -799,6 +801,8 @@ free: scan_bss_free(bss); } + network_update_known_frequencies(network); + l_queue_destroy(bss_list, NULL); done: @@ -3684,6 +3688,8 @@ next: return true; } + network_update_known_frequencies(network_psk ?: network_open); + error = network_connect_new_hidden_network(network_psk ?: network_open, msg); From patchwork Fri Jan 26 20:22:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13533304 Received: from mail-qt1-f182.google.com (mail-qt1-f182.google.com [209.85.160.182]) (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 12DD02230C for ; Fri, 26 Jan 2024 20:22:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706300572; cv=none; b=M4xMK9kYr7ud5opC/vuuY8JWgNR+9wmw3Cx+WzwvouA9ieoYWhaSCjJ1GmXPx5f84jGQKcUK1dmKXMvbZKp46fRMLfuyCjeUQ0DF1zMP5Z98KrKdyL3LMtL55F8nnBXcaJWozbL85jXwsOjj5EEPaASxkL5yhaOZ6J42QQ7OjYs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706300572; c=relaxed/simple; bh=p/qBiaP2+r7lYpiw3QH9+MkPCM1LfllQwTKB4AKRoMc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=fTWWcYgbHxYJ3n+3zT2M2FZU5jDF165pHCKf/UE/rDQUjIARG8c0BXQV39U5DCO5BGRJPErct4LjuN4wXTow/M1kS3iF7/6w5oITI+NbFJsSF27hfKtwUZu5VWWZEQky5CWS0x2Xd7IZE4WBm+RdUEkL2lwMzCHLh5kWhqCH2kQ= 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=Qd5941J6; arc=none smtp.client-ip=209.85.160.182 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="Qd5941J6" Received: by mail-qt1-f182.google.com with SMTP id d75a77b69052e-4298e866cd6so4887191cf.0 for ; Fri, 26 Jan 2024 12:22:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706300570; x=1706905370; 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=bFC3wtQTOlWSOFKpdLhiIlAPgdq6Lb2+B3xA3bc0LG8=; b=Qd5941J60qrHXveGpBdbbf+p40DMw5Y1E4T7fAbi2WKZeGFhyHO8ib67+9SmA+8M3A jLWk8giwLdmj3fQieTKKq50y+D3ZD5STn2KErtZ6u+T+E6qKs/G1f3NqUGvHVyG7+z9j 5M1ad6HV2RjGvRmswraZYRqcHywD2QaaINIxQrdSa76SW8lzhqKBjpgXYjzB4clowG6g Is6RRGptbauweFa8dESy2mSQYUbYycdtZQC/eYx56idaqCMQb5waZ21PwCRGAsszwdfc 8jPyBccSwXfcdPpV3VpqV4AmmYPuf9ziO2PbQNNBkJoaXy0vNi3po6SVvN0Xe7Se5dnk y0wQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706300570; x=1706905370; 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=bFC3wtQTOlWSOFKpdLhiIlAPgdq6Lb2+B3xA3bc0LG8=; b=MygCIR6oI4wWLBM2cfzaQrlUatV1LEAN459e0vJy3KR5fw3TCEGe8FKOC8pNQ11C6J s/3MeHKNLavA6WtXRe4TrL9f5+3gnMsQgR25Lk7y2RSxV13WIBsRitxHHl8cFQZDdzgc sdcnqtdTRoyWHwoKQUL14c8MQxa1LFYjZa02+Q2hTekHD6IdrjKeZCFdWsurytL6Lokh Uy5C7vXMgD/7fBIa5KR7O/hFSzFuTpgds3lrTzaiqTH56qCeQ28OmzzYgEDCpC1nbdpX POYoksaZqMFsnxaxJzjfzu7pizq+YqZlEPOx5LU6Ggq4SZ8sMR2yFeyx5s7Fixyr3mdK ATqA== X-Gm-Message-State: AOJu0Yxx/1qV4EKL7eYDcQao8HOKH6o61UreiOflUJBl4kz3icjLUowY JuI5N0m3DyIRXpwrR4GE6TWxhWusGfUPC+bpNZ5oVTgd0oqMoeo9/MvR4+oJOCc= X-Google-Smtp-Source: AGHT+IGoKK3K5mKJV9+sLIZNZRwgqmNHvwwb1UPLvO2s8nOECa01Vh+ZEEMYn2yAPmcYBC+oGSKLxg== X-Received: by 2002:a05:622a:648:b0:42a:5a41:abd2 with SMTP id a8-20020a05622a064800b0042a5a41abd2mr626486qtb.55.1706300569708; Fri, 26 Jan 2024 12:22:49 -0800 (PST) Received: from LOCLAP699.rst-01.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id fe3-20020a05622a4d4300b0042a25f3950esm826463qtb.75.2024.01.26.12.22.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 12:22:49 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 3/4] station: knownnetworks: limit quick scans to 5 freqs per network Date: Fri, 26 Jan 2024 12:22:42 -0800 Message-Id: <20240126202243.91947-3-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240126202243.91947-1-prestwoj@gmail.com> References: <20240126202243.91947-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In very large network deployments there could be a vast amount of APs which could create a large known frequency list after some time once all the APs are seen in scan results. This then increases the quick scan time significantly, in the very worst case (but unlikely) just as long as a full scan. To help with this support in knownnetworks was added to limit the number of frequencies per network. Station will now only get 5 recent frequencies per network making the maximum frequencies 25 in the worst case (~2.5s scan). The magic values are now defines, and the recent roam frequencies was also changed to use this define as well. --- src/knownnetworks.c | 30 +++++++++++++++++++----------- src/knownnetworks.h | 6 ++++-- src/station.c | 10 ++++++++-- 3 files changed, 31 insertions(+), 15 deletions(-) diff --git a/src/knownnetworks.c b/src/knownnetworks.c index 04ce74ec..fc810057 100644 --- a/src/knownnetworks.c +++ b/src/knownnetworks.c @@ -517,8 +517,23 @@ struct network_info *known_networks_find(const char *ssid, return l_queue_find(known_networks, network_info_match, &query); } +static void known_network_append_frequencies(const struct network_info *info, + struct scan_freq_set *set, + uint8_t max) +{ + const struct l_queue_entry *entry; + + for (entry = l_queue_get_entries(info->known_frequencies); entry && max; + entry = entry->next, max--) { + const struct known_frequency *known_freq = entry->data; + + scan_freq_set_add(set, known_freq->frequency); + } +} + struct scan_freq_set *known_networks_get_recent_frequencies( - uint8_t num_networks_tosearch) + uint8_t num_networks_tosearch, + uint8_t freqs_per_network) { /* * This search function assumes that the known networks are always @@ -527,10 +542,9 @@ struct scan_freq_set *known_networks_get_recent_frequencies( * list. */ const struct l_queue_entry *network_entry; - const struct l_queue_entry *freq_entry; struct scan_freq_set *set; - if (!num_networks_tosearch) + if (!num_networks_tosearch || !freqs_per_network) return NULL; set = scan_freq_set_new(); @@ -541,14 +555,8 @@ struct scan_freq_set *known_networks_get_recent_frequencies( num_networks_tosearch--) { const struct network_info *network = network_entry->data; - for (freq_entry = l_queue_get_entries( - network->known_frequencies); - freq_entry; freq_entry = freq_entry->next) { - const struct known_frequency *known_freq = - freq_entry->data; - - scan_freq_set_add(set, known_freq->frequency); - } + known_network_append_frequencies(network, set, + freqs_per_network); } return set; diff --git a/src/knownnetworks.h b/src/knownnetworks.h index e8ffac0b..741d42ed 100644 --- a/src/knownnetworks.h +++ b/src/knownnetworks.h @@ -113,8 +113,10 @@ struct network_info *known_networks_find(const char *ssid, enum security security); 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); + uint8_t num_networks_tosearch, + uint8_t freqs_per_network); +int known_network_add_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/station.c b/src/station.c index b186c505..8a5f4e18 100644 --- a/src/station.c +++ b/src/station.c @@ -64,6 +64,9 @@ #include "src/eap-tls-common.h" #include "src/storage.h" +#define STATION_RECENT_NETWORK_LIMIT 5 +#define STATION_RECENT_FREQS_LIMIT 5 + static struct l_queue *station_list; static uint32_t netdev_watch; static uint32_t mfp_setting; @@ -1438,7 +1441,9 @@ static int station_quick_scan_trigger(struct station *station) return -EAGAIN; } - known_freq_set = known_networks_get_recent_frequencies(5); + known_freq_set = known_networks_get_recent_frequencies( + STATION_RECENT_NETWORK_LIMIT, + STATION_RECENT_FREQS_LIMIT); if (!known_freq_set) return -ENODATA; @@ -2761,7 +2766,8 @@ static int station_roam_scan_known_freqs(struct station *station) const struct network_info *info = network_get_info( station->connected_network); struct scan_freq_set *freqs = network_info_get_roam_frequencies(info, - station->connected_bss->frequency, 5); + station->connected_bss->frequency, + STATION_RECENT_FREQS_LIMIT); int r = -ENODATA; if (!freqs) From patchwork Fri Jan 26 20:22:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Prestwood X-Patchwork-Id: 13533305 Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0C2002260B for ; Fri, 26 Jan 2024 20:22:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706300573; cv=none; b=rPjvoh2PRyoQRby/7gEQDnGRiPRVR+VbCYrCjAdtO0ABK/nOklBStbrT8bovQvC3bBNSr5OeaEC3RlDE2kN4/pTrCY5Mmya9DRm8obdZOE+v3Td+YfyaHSJIFaXC8XQ685EZXW/EasO/WEXAwGyOkTwIauWNhmBWqgM6wN16qrk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706300573; c=relaxed/simple; bh=qVUe8BPZnq+dT6elRok0k5v/vnyX0lzsZGhFvdSGGcA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=pFmFw/+YaGwLP8mpKOIYB//yZ7rFly0Etn8dolqoTtw0unHr7oLWf1fOqlhG825gALzZrfAvFFCM/pfZAot2GYOcJpDx5OzYjcd8eyTD3HYEmIK4a/aPO00AHqb1MbR36xZz3+VkfMjOuZ/HA9rYZr07iOl27hJS3C7Ia8T4GkU= 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=nmnTQ909; arc=none smtp.client-ip=209.85.160.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nmnTQ909" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-4299f424e55so3930911cf.1 for ; Fri, 26 Jan 2024 12:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706300571; x=1706905371; 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=yjhxB13PubYFTi/ivDF1ihuXnkM9cVlu0OUeGQW96W8=; b=nmnTQ909yEJvfuMnLBorgAt52wmGYbpdRmKJNyHeNOvyLE2Kye9bt9rKY4kHUhwfeD wAxFSgjJybEYuCFOqbVyvvZ9gafXn08WbEqTJTU04xHuV4P1kDW9Y/P9mdeHYpD2U5SV ktdpZ1bYWQ/5ZPgRqgJhP0+Q5A/sTNGtUFbT1dVzEuW4A7PxKF86Lul5M/NQftsOVeHL n0bf9jPC1JhwzoAaLlTfK6Q0p4pC75y4iKrSgqru2dX1SoHvWmWibktxSw396y5F5MuY ynaLER5BPeBXhhTkzKR2gEgZJimxa9w73WGvQQo7tbt5jI20+JXPRyffOpZP3fvjveTx 8m9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706300571; x=1706905371; 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=yjhxB13PubYFTi/ivDF1ihuXnkM9cVlu0OUeGQW96W8=; b=OLzOiF+8L8EG+kX37MBFmeU+m+Dvyw1vHQJ9qj5nwzKVtT4naj2cQ2SEeN0GWw2cOQ 5GfhMdVZn3vWlXGImKBzlfifkov0IoDARiUREdtjNStvIx4f6jMf2Plw+3s0KfNATGvq 2P2+Fpsq/w9MkqqkRz6cr4sft7fRcCuGENRsYDwtbHXxlYhVs/cgdnQeuh10rweaTTtk Y4jm925Aod9smDK9DsjN1eksy0oxyiGg5Dq5r5bV2z9hhRRcqHZiCmgi9hwfl7Vpm7Rk rLwhhN0Fr6HYpq8iydR20LhzFT83Or+8iu5JHMwbLXhUb4bYRlXDVRylMKU0M0mwiSeG /ZAQ== X-Gm-Message-State: AOJu0YyYWCQym48cmOGx5oeGPjfLNYbjmFq3XJEF+C4n49PIVrBKIbRS 83kCs4AG4iTxLvPPAqQRVKQf9b2lneyVPc1nOCWk1T8G51nonusH25enwXdjgEE= X-Google-Smtp-Source: AGHT+IEfd04Y9WKoV49chnmX0kyTJPTHfgg7zuNnz8ACPdasIF7xwXaITaU6+ccLLudcF0DY7dkwjQ== X-Received: by 2002:a05:622a:1b26:b0:42a:205a:fdeb with SMTP id bb38-20020a05622a1b2600b0042a205afdebmr378591qtb.85.1706300570743; Fri, 26 Jan 2024 12:22:50 -0800 (PST) Received: from LOCLAP699.rst-01.locus ([208.195.13.130]) by smtp.gmail.com with ESMTPSA id fe3-20020a05622a4d4300b0042a25f3950esm826463qtb.75.2024.01.26.12.22.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 12:22:50 -0800 (PST) From: James Prestwood To: iwd@lists.linux.dev Cc: James Prestwood Subject: [PATCH v3 4/4] auto-t: add test for known frequency sorting/maximum Date: Fri, 26 Jan 2024 12:22:43 -0800 Message-Id: <20240126202243.91947-4-prestwoj@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240126202243.91947-1-prestwoj@gmail.com> References: <20240126202243.91947-1-prestwoj@gmail.com> Precedence: bulk X-Mailing-List: iwd@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Modify the existing frequency test to check that the ordering lines up with the ranking of the BSS. Add a test to check that quick scans limit the number of known frequencies. --- autotests/testKnownNetworks/frequency_test.py | 110 ++++++++++++++++-- autotests/testKnownNetworks/hw.conf | 1 + 2 files changed, 102 insertions(+), 9 deletions(-) diff --git a/autotests/testKnownNetworks/frequency_test.py b/autotests/testKnownNetworks/frequency_test.py index 83e51c06..c2fd1290 100644 --- a/autotests/testKnownNetworks/frequency_test.py +++ b/autotests/testKnownNetworks/frequency_test.py @@ -4,17 +4,15 @@ import unittest import sys sys.path.append('../util') -import iwd from iwd import IWD from iwd import PSKAgent -from iwd import NetworkType -import testutil +from hwsim import Hwsim import os from configparser import ConfigParser class Test(unittest.TestCase): def connect_network(self, wd, device, network): - ordered_network = device.get_ordered_network(network) + ordered_network = device.get_ordered_network(network, full_scan=True) condition = 'not obj.connected' wd.wait_for_object_condition(ordered_network.network_object, condition) @@ -30,7 +28,7 @@ class Test(unittest.TestCase): wd.wait_for_object_condition(ordered_network.network_object, condition) def test_connection_success(self): - wd = IWD(True, '/tmp') + wd = self.wd psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) @@ -38,6 +36,11 @@ class Test(unittest.TestCase): devices = wd.list_devices(1) device = devices[0] + + # Set the signals so that the 2.4GHz ranking will be higher + self.ssidccmp_2g_rule.signal = -2000 + self.ssidccmp_5g_rule.signal = -8000 + # # Connect to the PSK network, then Hotspot so IWD creates 2 entries in # the known frequency file. @@ -75,8 +78,10 @@ class Test(unittest.TestCase): # self.assertIsNotNone(psk_freqs) self.assertIsNotNone(psk_uuid) - self.assertIn('5180', psk_freqs) - self.assertIn('2412', psk_freqs) + + # The 2.4GHz frequency should come first, as it was ranked higher + self.assertEqual('2412', psk_freqs[0]) + self.assertEqual('5180', psk_freqs[1]) self.assertIsNotNone(hs20_freqs) self.assertIsNotNone(hs20_uuid) @@ -92,6 +97,10 @@ class Test(unittest.TestCase): psk_agent = PSKAgent("secret123") wd.register_psk_agent(psk_agent) + # Now set the signals so that the 5GHz ranking will be higher + self.ssidccmp_2g_rule.signal = -8000 + self.ssidccmp_5g_rule.signal = -2000 + # # Reconnect, this should generate a completely new UUID since we # previously forgot the network. @@ -120,8 +129,78 @@ class Test(unittest.TestCase): self.assertIsNotNone(psk_freqs) self.assertIsNotNone(psk_uuid2) self.assertNotEqual(psk_uuid, psk_uuid2) - self.assertIn('5180', psk_freqs) - self.assertIn('2412', psk_freqs) + # Now the 5GHz frequency should be first + self.assertEqual('5180', psk_freqs[0]) + self.assertEqual('2412', psk_freqs[1]) + + def test_maximum_frequencies(self): + psk_agent = PSKAgent("secret123") + self.wd.register_psk_agent(psk_agent) + + devices = self.wd.list_devices(1) + device = devices[0] + + # Connect and generate a known frequencies file + self.connect_network(self.wd, device, 'ssidCCMP') + + self.wd.unregister_psk_agent(psk_agent) + + # + # Rewrite the known frequencies file to move the valid network + # frequencies to the end, past the maximum for a quick scan + # + config = ConfigParser() + config.read('/tmp/iwd/.known_network.freq') + for s in config.sections(): + if os.path.basename(config[s]['name']) == 'ssidCCMP.psk': + config.set(s, 'list', "2417 2422 2427 2432 2437 2442 2447 2452 2457 2462 2467 2472 2484 2412 5180") + break + + self.wd.stop() + + with open('/tmp/iwd/.known_network.freq', 'w') as f: + config.write(f) + + self.wd = IWD(True) + + devices = self.wd.list_devices(1) + device = devices[0] + + device.autoconnect = True + + device.wait_for_event("autoconnect_quick") + + condition = "obj.scanning == True" + self.wd.wait_for_object_condition(device, condition) + + condition = "obj.scanning == False" + self.wd.wait_for_object_condition(device, condition) + + # + # Check that the quick scan didn't return any results + # + with self.assertRaises(Exception): + device.get_ordered_network("ssidCCMP", scan_if_needed=False) + + device.wait_for_event("autoconnect_full") + + condition = "obj.scanning == True" + self.wd.wait_for_object_condition(device, condition) + + condition = "obj.scanning == False" + self.wd.wait_for_object_condition(device, condition) + + # + # The full scan should now see the network + # + device.get_ordered_network("ssidCCMP", scan_if_needed=False) + + def setUp(self): + self.wd = IWD(True) + + def tearDown(self): + self.wd.stop() + self.wd = None @classmethod def setUpClass(cls): @@ -129,10 +208,23 @@ class Test(unittest.TestCase): conf = '[General]\nDisableANQP=0\n' os.system('echo "%s" > /tmp/main.conf' % conf) + hwsim = Hwsim() + + cls.ssidccmp_2g_rule = hwsim.rules.create() + cls.ssidccmp_2g_rule.source = hwsim.get_radio('rad1').addresses[0] + cls.ssidccmp_2g_rule.enabled = True + + cls.ssidccmp_5g_rule = hwsim.rules.create() + cls.ssidccmp_5g_rule.source = hwsim.get_radio('rad2').addresses[0] + cls.ssidccmp_5g_rule.enabled = True + @classmethod def tearDownClass(cls): IWD.clear_storage() os.remove('/tmp/main.conf') + cls.ssidccmp_2g_rule.remove() + cls.ssidccmp_5g_rule.remove() + if __name__ == '__main__': unittest.main(exit=True) diff --git a/autotests/testKnownNetworks/hw.conf b/autotests/testKnownNetworks/hw.conf index 8a7ef73a..f68b63a5 100644 --- a/autotests/testKnownNetworks/hw.conf +++ b/autotests/testKnownNetworks/hw.conf @@ -2,6 +2,7 @@ num_radios=5 start_iwd=0 reg_domain=US +hwsim_medium=yes [HOSTAPD] rad0=ssidNew.conf