From patchwork Wed May 8 23:30:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Albers X-Patchwork-Id: 1933191 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=hURi2K+M; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=infradead.org header.i=@infradead.org header.a=rsa-sha256 header.s=casper.20170209 header.b=Ra5l8cyF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VZWdP6RWxz20fh for ; Thu, 9 May 2024 09:32:09 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=nexeFPZgT7JLXZSuCWAgWO3lrezqEeyoRu0a2ZyyxNA=; b=hURi2K+MbqgF85 uWRynhOhfB5e3Z1s/4/b8+U8JMPA93v4SC2MDRy6bHlcpknxmZ8ZatUD95THWULYCznq7FTAFdfFW ptr1V6QUc4jCyk4Zs2wbsiyUorYQCZ4sukTN6gk+O5oTPWF/ulQM2wvRneXgo5pmx9EGX87qeHKMR tl9SAkSI2yuvxZAKLiauM619NY5wG+0dAoRq4EOSW429LJ0m/Aun0kd+v7R7g+17ImzNsh25YDPQc n7c1D4GzsTMTKhOM4vkELgXFjDJKaAnnLKud2d+oxerS0uU8WBKk1l/1EdcMCbDqDb9Bc1zAtFsHz IJ4tpTkTEZ9ygI+56nDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4qkX-0000000HGuc-2sgJ; Wed, 08 May 2024 23:31:01 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4qkV-0000000HGuA-2b6n for openwrt-devel@bombadil.infradead.org; Wed, 08 May 2024 23:30:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ki78my13AGIsvM5BVCG5uuWph63oPlv/kJqyLocibW8=; b=Ra5l8cyFL94MPtcdfMdim7QgDL pWDbOwEe1c47IkAPfy0ymndM90sChl86JOJccRUDjT7Gpk+ko3MdhOoZUYAOgniC17mQRsAIYZg3k ZxkHi7HTPBztlo0xPOQGctNQ3CFMwoJopupz+0CGhCpuXb9qeXI1Vn/StniYZ2mfViyntV0a8KlTA o37uJmmCGVGmglN/DytsvHrlzDJY/Sg94T8DhdurvO38+meA+OqkpbIJEnE/wM9pSlLRK2Ctu/OZZ SpFIGQr3dNhV5Nslqy5VAKf/n+e+wVMZQxlQ/0Yie1AuDUbfDSZpeC6nLpvF6ZuEpWjxanFOFJGZP lafboVSw==; Received: from niel.cx ([2001:41d0:8:1580::1] helo=fourrooms.bandsal.at) by casper.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4qkR-0000000Ggs1-2KoR for openwrt-devel@lists.openwrt.org; Wed, 08 May 2024 23:30:57 +0000 Received: from spiderman.vpn.bandsal.at ([10.0.0.1] helo=spiderman.bandsal.at) by fourrooms.bandsal.at with esmtp (Exim 4.96) (envelope-from ) id 1s4qk2-00BQdq-2n; Thu, 09 May 2024 01:30:31 +0200 Received: by spiderman.bandsal.at (Postfix, from userid 1001) id BA88AA01261; Thu, 9 May 2024 01:30:30 +0200 (CEST) From: Daniel Albers To: openwrt-devel@lists.openwrt.org Cc: Daniel Albers Subject: [PATCH] Fix has_better_load evaluation Date: Thu, 9 May 2024 01:30:17 +0200 Message-Id: <20240508233017.2617515-1-daniel@lbe.rs> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240508224307.80808-1-daniel@lbe.rs> References: <20240508224307.80808-1-daniel@lbe.rs> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240509_003055_638711_8658F8F4 X-CRM114-Status: UNSURE ( 7.76 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -1.6 (-) X-Spam-Report: SpamAssassin version 4.0.0 on casper.infradead.org summary: Content analysis details: (-1.6 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.2 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Fixes two bugs: 1) if condition in is_better_candidate previously always evaluated to false. 2) below_load_threshold actually implemented above_load_threshold Signed-off-by: Daniel Albers --- policy.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/policy.c b/policy.c index 8c5d244..632cd47 100644 --- a/policy.c +++ b/policy.c @@ -55,7 +55,7 @@ better_signal_strength(int signal_cur, int signal_new) } static bool -below_load_threshold(struct usteer_node *node) +above_load_threshold(struct usteer_node *node) { return node->n_assoc >= config.load_kick_min_clients && node->load > config.load_kick_threshold; @@ -64,7 +64,7 @@ below_load_threshold(struct usteer_node *node) static bool has_better_load(struct usteer_node *node_cur, struct usteer_node *node_new) { - return !below_load_threshold(node_cur) && below_load_threshold(node_new); + return above_load_threshold(node_cur) && !above_load_threshold(node_new); } bool @@ -107,8 +107,7 @@ is_better_candidate(struct sta_info *si_cur, struct sta_info *si_new) if (better_signal_strength(current_signal, new_signal)) reasons |= (1 << UEV_SELECT_REASON_SIGNAL); - if (has_better_load(current_node, new_node) && - !has_better_load(current_node, new_node)) + if (has_better_load(current_node, new_node)) reasons |= (1 << UEV_SELECT_REASON_LOAD); return reasons;