From patchwork Fri Nov 15 19:42:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hurukawa2121 X-Patchwork-Id: 3943 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:1ee:b0:5d9:9f4c:3bc7 with SMTP id 14csp1229395map; Fri, 15 Nov 2024 11:44:12 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCXFZOenLzjI3Ga36+W5yZ193Ka3eWtoEKpYmwsVm+IANs1MSOQumEfysrgIIZzS9Eok33ugScYczqY=@openvpn.net X-Google-Smtp-Source: AGHT+IHJ0DTGh0+aTEDXb+p2xxYUw4yu8Y0a09lXiTkciqPgkEv+LpmZGkZVEB1ribgiglUnrbYl X-Received: by 2002:a05:6602:154e:b0:83b:2b89:a14e with SMTP id ca18e2360f4ac-83e6c1698f8mr426419639f.13.1731699852417; Fri, 15 Nov 2024 11:44:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731699852; cv=none; d=google.com; s=arc-20240605; b=ZkIbujYBRSVV6LjTdFGDLECdRGcTPbbwg3cDjPUfKdZTxmKj4b/WXCDOzjL0j/keOx rzawP7UyVxl7m5UrlvUn2+as1SaUNdF3EQgYyAKnidH0VR9tJvVkFAN63WdS3JoSUo0R 0ydtA8Mk1F+usn5wCcoDqJonoYa4Pd8WeUFhNKEo3KPori4RmVR3b5+TelUQzJm2xuD3 BmsxMW9ElL29PoBibaObiu/02WLhyHq8QFJAJufSwquAXT+Tk6TIUrsUBquYs5ihQahy Qqh0/4fMlgFljaVW6bXSsxhAYY1VZUCgnCytZAjxL/mQqUWYt10yRIo8/BlGVHyuOFiF JTwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=errors-to:content-transfer-encoding:cc:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:message-id:date:to:from:dkim-signature:dkim-signature :dkim-signature; bh=6BG5iY6GDOmipEJltr3t2UPLtZlxlAEfBhBTgccSqbY=; fh=PL8Gaq/CUo2LaXltYwxkcFfwVlvPtEN/PzCeiK+ADDw=; b=bxt897tJ5JeYP1jEZey9abhDOxdA719eZjlyoMKMA4HZ/ZCYV5XfGtfoZcPGhOiZjI dDeBqq7s+YgP4ep39t/3I+NMA76sFupLk2A54ChDUA4Epl3Ffxwh03Q1+wJFCzV0oNl0 ba7lNqsCqz0INxMZd4Dp2zzWv5xynUGU+pxXMkFz+SndWDAdCUFTHND+X0mXIkc/o0bX l7ilOkQh/LzsiFt9kpOKCIX3CLU1EkdfipIl/AmoHJR+0qMwlJsZEmt1rsyETTxs5rQ/ 2u2+9Pyz9bRjUFtn7Vi+Flk5wxxzmWpbyy9mFg0sYO2UuEt+SgWwOSjhYrRAeOzNx/tG UKmA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=XMJ7WOwW; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Gi9/v+fF"; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=lvqiRZ66; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@openvpn.net Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id ca18e2360f4ac-83e6df96d67si122231739f.19.2024.11.15.11.44.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Nov 2024 11:44:12 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=XMJ7WOwW; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="Gi9/v+fF"; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=lvqiRZ66; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@openvpn.net Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tC2Ee-0004lr-Uw; Fri, 15 Nov 2024 19:44:04 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tC2Ed-0004li-J1 for openvpn-devel@lists.sourceforge.net; Fri, 15 Nov 2024 19:44:03 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=yI5g9zvt7XvZ3ire08iD1vpVblTtegpw5Zpf3GFpFmU=; b=XMJ7WOwWhGrDVSgZztxz/OkseB CjZ/6tKNxaSGeFu1Z5QUjOrm9XjTS/tSgWshiTHYeSBydLCTtRNry1lXlMLUJair4f7tC9346SLB3 vUG6gaI4banMAdreqyk5e9wiT1kF948Tj+OUO0oX21SeMRPs/7NfybwUcNOUnanLN0xU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=yI5g9zvt7XvZ3ire08iD1vpVblTtegpw5Zpf3GFpFmU=; b=G i9/v+fFYj28khPfrCi5+IHEdI8J26AzvgDdy1r3WWyAr6xtdGKmrU2ceWb+8R25dtfOnkwmx53nf0 V7/gvdxdAdh/5UDzqPlfw0mVgPuyKknRYx0KwIcQc34oSI3NZ3Sfd0pjyGCsqs4OlyCIlNjhTS9eY x6xEBFUrntNSLnlQ=; Received: from mail-pf1-f173.google.com ([209.85.210.173]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1tC2Ec-0000OE-HV for openvpn-devel@lists.sourceforge.net; Fri, 15 Nov 2024 19:44:03 +0000 Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-7240fa50694so968987b3a.1 for ; Fri, 15 Nov 2024 11:44:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731699836; x=1732304636; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=yI5g9zvt7XvZ3ire08iD1vpVblTtegpw5Zpf3GFpFmU=; b=lvqiRZ66VhT8f1PJqI61/9pdD3M1/Ak7StZ5MKh1XYp5ESdCewFK6zQ+U3oCkLuhmP AXc/MCAr6sW2Su5MO9VDrUMKc/pg4f78w6KMZDBw3XOe9oS+eQuX1LIT04AbtNkXpYiE TGpkWH++53A9GE19ODh1l/OlV6ONXLpYDGJDU8Q91FTbq4JH0hAzWuK6M7dwGy8Zn88u WRs36itLBt+YUEv6/u3d0XmhrKHvWDZiHf5AnPllXwikkAbcs3n4dB+2/FV4St0QZEt9 6Iva0G9vuRO2oNsTf4eBrQEY9nrPsK1UZ3zBdAh3H3u8ZQuZZV7O/olLsqhCrdCOWCwB JXaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731699836; x=1732304636; 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=yI5g9zvt7XvZ3ire08iD1vpVblTtegpw5Zpf3GFpFmU=; b=JkqzaBhAAHKgRLR+g6eLcZ6HnUvJvm8kS82t43pkoeL44RWGFWiu8ngSAra1BbAGSR 01Oi3G45lPwY7W68N0uhLKB4Egl4cGHMcxP2E+cLs7ilouRNS2JYmMEDCyV/Snhx6fs/ 415T+a8M4jDtOR/LsBz6GnTyqcbgaRd6IZdAu02tOk6RNWrjEij3bVRcRGwMrpqJjdPz FZPpH9uANggNdbLbcAU0uTybDFC5Nh4PeIK3OPzfCzGuoyB67rGy1XHEAYO8t3fa2nY3 23k9dVyKweimb+DvllCTz3TJ4geIm44Vt1xj8nz7WOm+VQFhnJk6H0CpESyX09W0Bdhg MCzw== X-Gm-Message-State: AOJu0YyTluZVhs/UW4F6VNPWLHYKnnrRKd3jnvCiZtFE6fQ2uPZ6rol9 /JPy913AVD5JpadcxRpHLYHbA3nZcpQcwtTt5Z5yI4K3Je0notx8ucAyQg== X-Received: by 2002:a05:6a00:181b:b0:724:6704:734e with SMTP id d2e1a72fcca58-72476bb0a0cmr5791746b3a.13.1731699835621; Fri, 15 Nov 2024 11:43:55 -0800 (PST) Received: from localhost.localdomain ([2001:268:98c3:808:6023:9c0:455:8a35]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-724771c0867sm1776842b3a.105.2024.11.15.11.43.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 15 Nov 2024 11:43:55 -0800 (PST) From: Hurukawa2121 To: openvpn-devel@lists.sourceforge.net Date: Sat, 16 Nov 2024 04:42:03 +0900 Message-Id: <20241115194202.39508-1-shujifurukawa1213@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Spam-Score: 0.1 (/) X-Spam-Report: Spam detection software, running on the system "util-spamd-1.v13.lw.sourceforge.com", 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: From: Hurukawa2121 --- Improve shuffling algorithm of connection list This patch implements the Fisher-Yates shuffle algorithm to ensure that all permutations of the connection target list are generated with equal probability, eliminating biases present in the previous [...] Content analysis details: (0.1 points, 6.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit [shujifurukawa1213[at]gmail.com] 0.0 RCVD_IN_VALIDITY_RPBL_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [209.85.210.173 listed in bl.score.senderscore.com] 0.0 RCVD_IN_VALIDITY_SAFE_BLOCKED RBL: ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. [209.85.210.173 listed in sa-accredit.habeas.com] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [shujifurukawa1213[at]gmail.com] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.210.173 listed in list.dnswl.org] 0.0 RCVD_IN_MSPIKE_H3 RBL: Good reputation (+3) [209.85.210.173 listed in wl.mailspike.net] 0.0 RCVD_IN_MSPIKE_WL Mailspike good senders X-Headers-End: 1tC2Ec-0000OE-HV Subject: [Openvpn-devel] [PATCH] Improve shuffling algorithm of connection list X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hurukawa2121 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: =?utf-8?q?1815818427618448736?= X-GMAIL-MSGID: =?utf-8?q?1815818904698424636?= From: Hurukawa2121 --- Improve shuffling algorithm of connection list This patch implements the Fisher-Yates shuffle algorithm to ensure that all permutations of the connection target list are generated with equal probability, eliminating biases present in the previous shuffling method. In the Fisher-Yates algorithm, there's only one way to obtain each permutation through these swaps, so all permutations occur with equal probability in theory. Signed-off-by: Hurukawa2121 src/openvpn/init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/openvpn/init.c b/src/openvpn/init.c index 9371024e..3b00b49d 100644 --- a/src/openvpn/init.c +++ b/src/openvpn/init.c @@ -478,9 +478,9 @@ init_connection_list(struct context *c) if (c->options.remote_random) { int i; - for (i = 0; i < l->len; ++i) + for (i = l->len - 1; i > 0; --i) { - const int j = get_random() % l->len; + const int j = get_random() % (i + 1); if (i != j) { struct connection_entry *tmp;