From patchwork Wed May 8 22:43:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Albers X-Patchwork-Id: 1933190 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=WkcKgy5o; 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 4VZVbr3l6bz20fh for ; Thu, 9 May 2024 08:45:42 +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: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:In-Reply-To:References: List-Owner; bh=BNefoD6PN3iP7Bya+xnXEpNaOcqKaCl85Uw/wvk+1rQ=; b=WkcKgy5omvnlqE x1mebZBDOQlL/dFQMWnb8zrsKo/ov7WZlXGE5XFC3S85/SpLcMXfp7rcFi+1HtZ0W8mvPqhGmMrcK s3hsgRxKiP5yBrciRt4ACWYJrFCo6KsYMov1pSuzlTEV3v1bHJq7osgCNukX1ie9pg19cj9QokS2N lft+iiTQV/0Xy+NYnG+98beOXwbuLbF/MkqXjp5tAQ59oOqcFawbQ528sNa+x6KIh71sCcDD4cSF+ d+jtHbqrqhMiPUUGmIgZ2pTlCnHa5XkiZ+UZ1hzKODJmo6KKO2K1KN5FsJnwz4Q26ggoRE0rvulon 7+Zti2+pXgo4HM9GXeKw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4q0L-0000000HBhQ-0jPu; Wed, 08 May 2024 22:43:17 +0000 Received: from niel.cx ([2001:41d0:8:1580::1] helo=fourrooms.bandsal.at) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1s4q0H-0000000HBfr-0Hkj for openwrt-devel@lists.openwrt.org; Wed, 08 May 2024 22:43:14 +0000 Received: from spiderman.vpn.bandsal.at ([10.0.0.1] helo=gore.bandsal.at) by fourrooms.bandsal.at with smtp (Exim 4.96) (envelope-from ) id 1s4q0E-00BOvb-0n; Thu, 09 May 2024 00:43:11 +0200 Received: by gore.bandsal.at (sSMTP sendmail emulation); Thu, 09 May 2024 00:43:09 +0200 From: Daniel Albers To: openwrt-devel@lists.openwrt.org Cc: Daniel Albers Subject: [usteer] Fix has_better_load evaluation Date: Thu, 9 May 2024 00:43:07 +0200 Message-ID: <20240508224307.80808-1-daniel@lbe.rs> X-Mailer: git-send-email 2.45.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240508_154313_184828_928C69C6 X-CRM114-Status: UNSURE ( 7.95 ) X-CRM114-Notice: Please train this message. X-Spam-Score: 0.0 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Fixes two bugs: 1) if condition in is_better_candidate previously always evaluated to false. 2) below_load_threshold actually implemented above_load_threshold Fixes #5 --- policy.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) Content analysis details: (0.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 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 Fixes #5 --- 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;