[Openvpn-devel,v7] Factor out lookup_session_by_mda_key_id into its own method
Commit Message
From: Arne Schwabe <arne@rfc2549.org>
This makes the code a bit easier to read and also allows reusing
the function later.
Change-Id: Ib7d9aa61fd878d7e025e9d1050c563dd114eb438
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
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 <frank@lichtenheld.com>
Comments
"makes sense"... ACK from Frank, all green from BB, etc.
Your patch has been applied to the master branch.
commit e9b9f6c0b61a3aaaa4c696ac3c091c4ee580a305
Author: Arne Schwabe
Date: Wed Aug 26 20:53:04 2026 +0200
Factor out lookup_session_by_mda_key_id into its own method
Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1854
Message-Id: <20260826185309.18083-1-gert@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg38736.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
--
kind regards,
Gert Doering
@@ -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;
}