From patchwork Wed Aug 26 18:53:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5282 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:7000:4306:b0:87d:ab56:3700 with SMTP id q6csp7681051mae; Wed, 26 Aug 2026 11:53:24 -0700 (PDT) X-Forwarded-Encrypted: i=2; AHgh+RoR4lR+CpWdAOKtfAn6jIj/AMEUutEzw0cwnnBbgYTdrSd5f4y/gNfYJr5YUfomQadtnIDcbq3koUw=@openvpn.net X-Received: by 2002:a05:6820:f022:b0:6b1:6dac:8967 with SMTP id 006d021491bc7-6b1a051a664mr8508458eaf.22.1787770404333; Wed, 26 Aug 2026 11:53:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1787770404; cv=none; d=google.com; s=arc-20260327; b=lu5CklUPgpGebOIUpCVlv3s1fCcubV/QWHWiY8cAuz2ifRAiZYjM8QuILE5/mPitdm T9i5vWVTA4mTNqK8kQeSAwUXXZ43/Mh4DfYWL7gdzYg25saeQpFaX7nvojZuurzxVbBi PuIpiOxwXSmx2iPN8FxD9/kCAyekwjFoWXCARdkZ+4Fh5KZzh3/698G6zC/29XVJnb9L VZR4ICWEWd8J4rOxYG+Oil3VdRtcV/WdoNcwIaZk+4tJFE2hlJwEzbgQLHXtIsogUAuY bhs4jbThkVcOZYRWnFHJ41LCsShR24b6vJfqvpqw7Pct3LyEHMWJJ9pymoy4X/IMxuO/ vdlQ== 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=06fuP8aDaZRoRLtzNvQHfbHrbFqpe/GYEvAv71tP5JI=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=bqLtLO1C+GPV3OtgUMDpEkZJOsG0JtLIAUYuBA7byeRTBVD/6nKcFhTA9lXN+1MQj+ rLq9U8Z9jomuJllYNloXIh78+hdvdTmHR2G8NF65CVD8+PvM8ApqxXJ/+yTg6BRmJWBe B7toJ3GsfKUg/YkcwEqhxYGXpRbfqTSng31dvbPMbcal4ofCjmT/l9VQ8RGpEYWDTrcz GwG0L/X01lSjv/LFMqMLtzqwjwTR5+9DRY14jR/OmCGAjRx+DA6yhldvDUa133gdU6aZ MzJnRvIE9sIydDANWdHlv0KUrcczzEvJJIlI7D37Iw8M3hRuKZ6n2cUsnLBK3Bfu9ppw A2qw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b=RjfQm5vw; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="ImH9Y7/I"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=JrKcF8Jz; 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-465ae4a5f9esi4340365fac.95.2026.08.26.11.53.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Aug 2026 11:53:24 -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=RjfQm5vw; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b="ImH9Y7/I"; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b=JrKcF8Jz; 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=06fuP8aDaZRoRLtzNvQHfbHrbFqpe/GYEvAv71tP5JI=; b=RjfQm5vwpS0DK0wRhJ+lqcG4Qe nOB/U1gjL9uZw7C+k7IIcbDSvL9vSK4MZdz6JjoApEd0SlsFaAnvJBlVdvPNQOiZlTXJF5EKnKzz5 uMsULXKEmrZKQoAfvW5i8b2LZaHkirlandB7bFVbOwyTXccFCnozaQytRnnKbR1xGSOk=; 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 1wzIkS-0006oF-Pk; Wed, 26 Aug 2026 18:53:20 +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 1wzIkR-0006o0-ND for openvpn-devel@lists.sourceforge.net; Wed, 26 Aug 2026 18:53:19 +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=r0BnvvpVr7IDPPFeotDWZ25DA0IJfFiEiq4llrJ13js=; b=ImH9Y7/Iz9cP1ShV3dEDmUq57v Fu/spS6LhYDfD8YNP8kn8LMQ3kLRZtxtcRmQk//ryutKKZJkGZUb3OVAgsHr9Vra16iIZvewkkusD KSrhkP4AFEnOwSP5jrwE2/R/d4OkNOH0ItBwrgkwL8TydRTn3AyAMftGrh+cKGE+79nA=; 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=r0BnvvpVr7IDPPFeotDWZ25DA0IJfFiEiq4llrJ13js=; b=JrKcF8JzJjWnMa/O4nBkMVgATH r9m4U1wL1ryG7IDPbwAsdcPUYbeyKALi/LyTVDRbul7fOkX3iBenfFhR4to9SkYCtSq5uIB0Sj/NQ rGzLKkxdBA61jbdzpKdjTwLo+gFRiZBZ8vCuBXK/FnU/skHFHx5dJ2tkHnaJN0XOV3Ek=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1wzIkP-0005gW-QF for openvpn-devel@lists.sourceforge.net; Wed, 26 Aug 2026 18:53:19 +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 67QIrAvF018116 for ; Wed, 26 Aug 2026 20:53:10 +0200 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 67QIrALb018115 for openvpn-devel@lists.sourceforge.net; Wed, 26 Aug 2026 20:53:10 +0200 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Wed, 26 Aug 2026 20:53:04 +0200 Message-ID: <20260826185309.18083-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-2.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 makes the code a bit easier to read and also allows reusing the function later. Change-Id: Ib7d9aa61fd878d7e025e9d1050c563dd114eb438 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: 1wzIkP-0005gW-QF Subject: [Openvpn-devel] [PATCH v7] Factor out lookup_session_by_mda_key_id into its own 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: 1874613139222282584 X-GMAIL-MSGID: 1874613139222282584 From: Arne Schwabe This makes the code a bit easier to read and also allows reusing the function later. Change-Id: Ib7d9aa61fd878d7e025e9d1050c563dd114eb438 Signed-off-by: Arne Schwabe Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1854 --- 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/+/1854 This mail reflects revision 7 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index d8dd99b..46ff1ba 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -4014,6 +4014,24 @@ } } +static struct tls_session * +lookup_session_by_mda_key_id(struct tls_multi *multi, + const unsigned int mda_key_id) +{ + if (multi->session[TM_INITIAL].key[KS_PRIMARY].mda_key_id == mda_key_id) + { + return &multi->session[TM_INITIAL]; + } + else if (multi->session[TM_ACTIVE].key[KS_PRIMARY].mda_key_id == mda_key_id) + { + return &multi->session[TM_ACTIVE]; + } + else + { + return NULL; + } +} + static bool management_client_pending_auth(void *arg, const unsigned long cid, const unsigned int mda_key_id, const char *extra, unsigned int timeout) @@ -4024,17 +4042,9 @@ if (mi) { struct tls_multi *multi = mi->context.c2.tls_multi; - struct tls_session *session; + struct tls_session *session = lookup_session_by_mda_key_id(multi, mda_key_id); - if (multi->session[TM_INITIAL].key[KS_PRIMARY].mda_key_id == mda_key_id) - { - session = &multi->session[TM_INITIAL]; - } - else if (multi->session[TM_ACTIVE].key[KS_PRIMARY].mda_key_id == mda_key_id) - { - session = &multi->session[TM_ACTIVE]; - } - else + if (!session) { return false; }