]> git.ipfire.org Git - thirdparty/openvpn.git/commit
client-connect: Add CC_RET_DEFERRED and cope with deferred client-connect
authorArne Schwabe <arne@rfc2549.org>
Thu, 16 Jul 2020 13:43:10 +0000 (15:43 +0200)
committerGert Doering <gert@greenie.muc.de>
Fri, 17 Jul 2020 11:58:16 +0000 (13:58 +0200)
commitdfb40edc4acae5f17b0062ecb13ad1fa760ed529
tree4fef1784cb65df7d5834d1f80b771a65f1145674
parentee6830c34818bf4dc30cf7f0959ea0c9246bab8d
client-connect: Add CC_RET_DEFERRED and cope with deferred client-connect

This patch moves the state, that was previously tracked within the
multi_connection_established() function, into struct client_connect_state.
The multi_connection_established() function can now be exited and
re-entered as many times as necessary - without losing the client-connect
handling state.

The patch also adds the new return value CC_RET_DEFERRED which indicates
that the handler couldn't complete immediately, and needs to be called
later.  At that point multi_connection_established() will exit without
indicating completion.

Each client-connect handler now has an additional argument: "deferred",
to signal "additional call(s) while in deferred state".  The first call
to a handler always sets "deferred = false".  If that call returns
CC_RET_DEFERRED, the next call to the handler will be "deferred = true".

For some handlers (mda, ccd) this can never happen, so we ASSERT()
on !deferred.  If that ever triggers, something is wrong in our data
structures and we should better abort.

Signed-off-by: Fabian Knittel <fabian.knittel@lettink.de>
Patch V3: Use a static struct in multi_instance instead of using
          malloc/free and use two states (deferred with and without
          result) instead of one to eliminate the counter that was
          only tested for > 0.

Patch V5: Use new states in context_auth instead of the extra state
          that the patch series previously used.

Patch V6: Restructure code to make it a bit more readable, rebase on
          master.

Patch V7: move deferred bool into client connect handler calls, switch
          to switch case

Signed-off-by: Arne Schwabe <arne@rfc2549.org>
Acked-by: Antonio Quartulli <antonio@openvpn.net>
Message-Id: <20200716134315.17742-1-arne@rfc2549.org>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg20395.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/multi.c
src/openvpn/multi.h
src/openvpn/openvpn.h