From patchwork Fri Nov 15 19:40:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hurukawa2121 X-Patchwork-Id: 3942 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:1ee:b0:5d9:9f4c:3bc7 with SMTP id 14csp1228008map; Fri, 15 Nov 2024 11:41:09 -0800 (PST) X-Forwarded-Encrypted: i=2; AJvYcCWBPRQcqd9/qHi3Eku0AgZN+jptf/A8qzZ9M0B9746T6tQaI+XdlwHIyewULHiaNYOwEtIQRwUvYow=@openvpn.net X-Google-Smtp-Source: AGHT+IHwSsE4oYPiI06++PI2/I/BRQmvIqE0EL+PIP+0nWYHQuJKgpa4jsdN0peYfiFVOteZ/+oJ X-Received: by 2002:a05:6870:a114:b0:261:1600:b1eb with SMTP id 586e51a60fabf-2962e20eacfmr4321156fac.31.1731699669440; Fri, 15 Nov 2024 11:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1731699669; cv=none; d=google.com; s=arc-20240605; b=dn431O97fVhjvpRwuEdpYv1V3oJVYX4HpnTlpeK9MNujWHUlGJ1+TfFMExHd3RDRm3 Ict8Yu3FYrunr3gXQYjN3ZN0VnDxRJ9+0zYZB7HsWbARuLXsK3qRZq6EC5dlGRyb292A adwmiElD4STNJttaXWhSGolegXBmub90Vb+TOFAtek0dR3ZN+rHHo0tE8Dh261JfEA0K 9LUKg4eLoam9PmHlE900GEhEtQhfO90B4ImzA+lSplkF3iEPqC9k3TKvdjJEqJs0HhXC AoLzz7UV8o9U0Y3l4Rc/9zH0TnbQDylm+QEko+USbe2si38zDjvMC7fQMx0bw7dD8UB8 sUYw== 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=sEE0rNvqXMT1diJrMt/svxvnq6+hAPAcCdkEI1uhQMk=; fh=PL8Gaq/CUo2LaXltYwxkcFfwVlvPtEN/PzCeiK+ADDw=; b=WAFtbXLvwyVVpqf+Vu/EQyFY35pwVeYbM1Ih9bD2iIFVPM+xfESoQiBN386LI0E1Tc m3vN+BQBH2z0Xl59+gjiGYZ36JS16U80J2zkYLjeKyTgIK6b8HDZsVITvxFLj3tO7rNt ywWZ0G8rsiewuPtBIhRrQ69lkp16apjnu0U50pA6DqF6awA/uPXViGBU395aNpeddKK2 nmolaSZRryVcC0nMeXRAUicfvI58jDqiZGDgO1xOeZwKADcTnbq26CeMCTpschCWnaQo mOqA+leBzahQEtxRfPXJxO28dYR2U2gOfCf3MNxDzOz4MF6Wp5r634m4gig3Wu7RCyax /s2Q==; 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="jpimo0O/"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=bc3j9NxS; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="lD/NAqHk"; 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 586e51a60fabf-29651b30819si27310fac.184.2024.11.15.11.41.09 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Nov 2024 11:41:09 -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="jpimo0O/"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=bc3j9NxS; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b="lD/NAqHk"; 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-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1tC2Bg-0005Gf-F3; Fri, 15 Nov 2024 19:40:59 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1tC2Bf-0005GZ-0N for openvpn-devel@lists.sourceforge.net; Fri, 15 Nov 2024 19:40:58 +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=FDR850bruiK8133EjTunub9tFZax5jyegc6+qmvSVg0=; b=jpimo0O/E34YI3vtk0kqyDhGa1 0l1g5BoMoCclkJd8yil5oLABWjtqmD1wyBaiMaAInRq2u9nLplFTdEkfMJxrRaJMm4EV6e3GBjemD gI4cBzPNnFCgtxAULYthsgPTDXQvKga6oYt0aujTEXzSPp3ZUYo7ozv85ltWW6x5qZOg=; 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=FDR850bruiK8133EjTunub9tFZax5jyegc6+qmvSVg0=; b=b c3j9NxSgHbuwdz0QJ2GlhEz6v9I3jEnssClWmSAiyOuqr1VS/FAouK/6Jx1SuVXPydThN5bSo/QM1 t4YGeVvnj9gvaWGr7O3NPu5vr3600GInlGCDBaBeUR12lihiyAFkA6EiRpqbQiLM/EmI8uqUR1OrO CB/vLacZiAOcVzWA=; Received: from mail-pf1-f171.google.com ([209.85.210.171]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1tC2Bd-0008UA-RA for openvpn-devel@lists.sourceforge.net; Fri, 15 Nov 2024 19:40:58 +0000 Received: by mail-pf1-f171.google.com with SMTP id d2e1a72fcca58-720b2d8bb8dso1634342b3a.1 for ; Fri, 15 Nov 2024 11:40:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1731699647; x=1732304447; 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=FDR850bruiK8133EjTunub9tFZax5jyegc6+qmvSVg0=; b=lD/NAqHka3yx5gv3n0TNRsGdgO3pe5Mt8xsF8e/e6jA+FJtIvKKPi4/X9QWjaROs7O ufQQXsn88Apxi+GpFmQ0Dyk7Lo5QUeqPTVK7cK5Fry3EWxDeZF4IEix2fg4zVC6RsxHI zWu1HvqHARHq5D6OawGAJ/uObYjliilyXE6OrO09oRgKO3z3NGdfyvZoT1zIkpcE00ve r41hk503FX/V/1+1tU7AOYKO4xCwgEfek1GWvm56pts659U1+vdYlhBlty65AvJUs6qQ HpYAwLPqYlxsrmBpAVMn4vZ88H9xSip5EeHP+Xak2L2j4IF7LwCoa4F/Yim5tWMPKIVI Z5WA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731699647; x=1732304447; 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=FDR850bruiK8133EjTunub9tFZax5jyegc6+qmvSVg0=; b=n2pURwXvEBVYKZf/QaI/uFhmgLZilCtSvrWQwQy2EI6XeSuGWtr7ra/G2heiSv4MTV ZvgvB0l1eUFreJPOpT4ffP+KuJwhZfdq5pdEKZ+xDEgWUjYtPlHofGbLWPR4GobRr63h qo12UHOv3HK0+9hqjmfhLhOiJ9eQCMrzrD8v5gnqvowCgcgIODpUl9nRubCq3xs1i3Zi o1Td8veVHDjDyPsUr5S69ADCpjoMckQD5GH2hxapSLsMjqC+M+hMM21YG8b0tG7EibIT bUvXR4wYmvv0QiCBdMfr5QbumHqN+gaPNjXZkXBDhaGmc11Fe5ybswv/O8PNNabxMINX NdDg== X-Gm-Message-State: AOJu0Yy9Eoub2MDTJD7DCLSBua0gfp7ph9LExQESHx6pz1/DrK+ajkfb M8w9C3WO+wXCSWuxIMQGD1r7rT7/GDyhafOCerMMXbhNrNffO4sJ+RVDyQ== X-Received: by 2002:a05:6a00:21cf:b0:71e:77e6:ad89 with SMTP id d2e1a72fcca58-72476bc97bemr4662485b3a.13.1731699646800; Fri, 15 Nov 2024 11:40:46 -0800 (PST) Received: from localhost.localdomain ([2001:268:98c3:808:6023:9c0:455:8a35]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-72477200a99sm1789912b3a.182.2024.11.15.11.40.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 15 Nov 2024 11:40:46 -0800 (PST) From: Hurukawa2121 To: openvpn-devel@lists.sourceforge.net Date: Sat, 16 Nov 2024 04:40:06 +0900 Message-Id: <20241115194005.38280-1-shujifurukawa1213@gmail.com> X-Mailer: git-send-email 2.39.3 (Apple Git-146) MIME-Version: 1.0 X-Spam-Score: -0.6 (/) 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.6 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.171 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.171 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.171 listed in list.dnswl.org] -0.7 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.210.171 listed in wl.mailspike.net] X-Headers-End: 1tC2Bd-0008UA-RA 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?1815818712200567394?= 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;