From patchwork Fri Jul 17 14:15:03 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5113 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:b0c1:b0:878:4d70:ff7f with SMTP id p1csp1240791maw; Fri, 17 Jul 2026 07:15:37 -0700 (PDT) X-Forwarded-Encrypted: i=2; AHgh+Rrjc1/do26B6+cNygdybTJocgFqMoXVQIbW/EaGS0aJL3f7lh4scLNlq0IeZdB7eBBxm0wLi4Fko/w=@openvpn.net X-Received: by 2002:a05:6870:c192:b0:43c:5b9d:4bfd with SMTP id 586e51a60fabf-45690412623mr1115940fac.31.1784297737365; Fri, 17 Jul 2026 07:15:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1784297737; cv=none; d=google.com; s=arc-20260327; b=mLO3bERVHR7+SNjpgm5m3M95d5264GaBUeJcUAmegx5no/5yc8kJEMwyNd3L9ZBW/A EiUW8TB0yqgCz7lmoW7K0CBYwedvjJWrOfAkcktI2Jwe/jnaiZyjRIAbXp+bQhD6pjQL Gg+2qdz5A+LSQvb1/6p0cS3Sw8cjHqWx/uxCe9lIhgX0oTIfGEpWTRqfEX71OOeItNsb nqBnFSjz2D8SuJd/tdo50wwOww73mTfLhAE5gaxJ5kewYnK0R5jO66EpRRJ7pfiSwh/U bzw1yVmdlH+QwnBB7hT+cCOla8V2IFD21pibzwpYJomhWeiGppTR42/u66SRNfpcfSlH ERrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=nTVqF2ecjc3TFp7Y9E3dFAUH24e8pO0T5XhneHR6f2I=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=PRQsPOBRcjejSKaIsfFa2XFpdiryiIuk738EIGxV88KBiIrejdEEK2OTN5AOXKh4Kq /4CqWyEMt3YIVIVJskz3h4EmWw+SI8fYdkkPp5GNbZQ9lboBJu/69fMqYsKlSt8gRFxk ZCRvXPgPD73aoxq/gaee6O3KE2Uv1b37cgJksfZashXNh5MEKy2MgG/BbJY4p+d+uuNs grcrpKuaHFtn4g5OL4lkP41xPTFTJuDTDrzW3bEiARzDbDFIqqkM4bv3Pi9avoLabxYq PhUvkDURYwzHDLR+MJLXL8UqhfKVsOwNJ5J4CFU7zi2hmlAVI1L0fZHFPmEHn/0YOHRC tEfw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=GbPnG8Vb; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=C1sFS96q; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=BbibVqqZ; 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=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id 586e51a60fabf-4568e64eb99si1296062fac.180.2026.07.17.07.15.36 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Jul 2026 07:15:37 -0700 (PDT) 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=pass header.i=@lists.sourceforge.net header.s=beta header.b=GbPnG8Vb; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=C1sFS96q; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=BbibVqqZ; 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=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=nTVqF2ecjc3TFp7Y9E3dFAUH24e8pO0T5XhneHR6f2I=; b=GbPnG8Vb8ioWjb7HXwtsa80x2y rnAHMoL8k1GPKh+Rl6oGIAA3bUSSTPIhg8ane26E7bvdvxIfs9RJxUMPMPZhpc8AdOpjDtkEPaeky 5QkuYG82wSuOzoPJcBJa3E1KWvb4txTTaAvV1YZ7HBwBzJKkUx2xwSH+e0oLDOt4a6sQ=; 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 1wkjLi-0002UU-1r; Fri, 17 Jul 2026 14:15:34 +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 1wkjLf-0002UE-RZ for openvpn-devel@lists.sourceforge.net; Fri, 17 Jul 2026 14:15:31 +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:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=i6yuUsqzKE7jvkXjlYTep4Fftrdvyf5NO2iuRyUvc6M=; b=C1sFS96qyHWF4hF7dDn1z5ajV/ fVBS/PSkKtVdH3Cd4xeNmdHh0PGRYo/Y6bU1XI9pQndlPNZshCJHuGCBv5psX3YL+vHXhKYep/D4t CFyBMPfFhOtG60AFjlCPj2sH4BMqINmcUtLC7zFWCx8XOyllhVAOgq9VVG4hkbKVrbmA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=i6yuUsqzKE7jvkXjlYTep4Fftrdvyf5NO2iuRyUvc6M=; b=BbibVqqZP2yCVIB4mrb4e6e2PR ybxErcWydFkcPvIgjBOU0sbsOabhKBBknwiZY/N1RbJYnWuONUJ//HrWxoWdv+lvnWNdVZvcLUUkk 0KSiQTT0FuZ6X3WJ6lk2CjR35dAc6gT+LC8Q/GEgo2JTD2t1JiMPFaK9o1T/NilIeHyI=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wkjLP-0004QZ-TG for openvpn-devel@lists.sourceforge.net; Fri, 17 Jul 2026 14:15:17 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 66HEF9UC023062 for ; Fri, 17 Jul 2026 16:15:09 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 66HEF9bi023061 for openvpn-devel@lists.sourceforge.net; Fri, 17 Jul 2026 16:15:09 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Fri, 17 Jul 2026 16:15:03 +0200 Message-ID: <20260717141508.23034-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.53.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-1.hosts.colo.sdot.me", 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: Arne Schwabe This is just a small refactoring to make the code a little bit better organised. Change-Id: I37ade55d7674c68dd98cf4dfde35c4ad42e20d39 Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1wkjLP-0004QZ-TG Subject: [Openvpn-devel] [PATCH v4] Extract multi_get_instance_udp_real method 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1870971784224029603 X-GMAIL-MSGID: 1870971784224029603 From: Arne Schwabe This is just a small refactoring to make the code a little bit better organised. Change-Id: I37ade55d7674c68dd98cf4dfde35c4ad42e20d39 Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1725 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1725 This mail reflects revision 4 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/openvpn/mudp.c b/src/openvpn/mudp.c index 9acf297..d22c53b 100644 --- a/src/openvpn/mudp.c +++ b/src/openvpn/mudp.c @@ -205,7 +205,6 @@ handle_connection_attempt(struct multi_context *m, struct link_socket *sock, struct mroute_addr *real, - const uint64_t hv, struct hash_bucket *bucket) { struct hash *hash = m->hash; @@ -236,6 +235,7 @@ mi = multi_create_instance(m, real, sock); if (mi) { + const uint64_t hv = hash_value(hash, real); hash_add_fast(hash, bucket, &mi->real, hv, mi); mi->did_real_hash = true; multi_assign_peer_id(m, mi); @@ -265,6 +265,28 @@ } /** + * Looks up an multi instance by its real address (IP and port) + * @param m multi context + * @param real Address to look up + * @return instance matching the address, NULL otherwise + */ +static struct multi_instance * +multi_get_instance_udp_real(struct multi_context *m, struct mroute_addr *real) +{ + struct hash *hash = m->hash; + struct hash_element *he; + const uint64_t hv = hash_value(hash, real); + struct hash_bucket *bucket = hash_bucket(hash, hv); + he = hash_lookup_fast(hash, bucket, real, hv); + if (he) + { + return he->value; + } + return NULL; +} + + +/** * Get a client instance based on real address. If * the instance doesn't exist, create it while * maintaining real address hash table atomicity. @@ -280,7 +302,6 @@ if (mroute_extract_openvpn_sockaddr(&real, &m->top.c2.from.dest, true) && m->top.c2.buf.len > 0) { - struct hash_element *he; const uint64_t hv = hash_value(hash, &real); struct hash_bucket *bucket = hash_bucket(hash, hv); uint8_t *ptr = BPTR(&m->top.c2.buf); @@ -317,17 +338,13 @@ } if (!v2 || peer_id_disabled) { - he = hash_lookup_fast(hash, bucket, &real, hv); - if (he) - { - mi = (struct multi_instance *)he->value; - } + mi = multi_get_instance_udp_real(m, &real); } /* we have no existing multi instance for this connection */ if (!mi) { - mi = handle_connection_attempt(m, sock, &real, hv, bucket); + mi = handle_connection_attempt(m, sock, &real, bucket); } #ifdef ENABLE_DEBUG