Skip to content

Refactor client-connect / add support for deferred handling

Fabian Knittel openvpn-devel 2 versions – In review

Get series with b4
b4 am [email protected]...

Versions newest first · linked by author and title

  1. v2 Latest9 patches 1 replyIn review
  2. v19 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- rebased to the current master,
- reports errors during file delete

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/9client-connect: Split multi_connection_established into separate functionssrc/openvpn/multi.c src/openvpn/options.h+224 -1040 replies
2/9client-connect: Properly indent all functionssrc/openvpn/multi.c+204 -2040 replies
3/9client-connect: Refactor multi_client_connect_source_ccdsrc/openvpn/multi.c+13 -160 replies
4/9client-connect: Move multi_client_connect_setenv into early_setupsrc/openvpn/multi.c+10 -90 replies
5/9client-connect: Refactor to use return values instead of modifying a passed-in flagsrc/openvpn/multi.c src/openvpn/multi.h+82 -510 replies
6/9client-connect: Refactor client-connect handling to calling a bunch of hooks in a loopsrc/openvpn/multi.c+16 -410 replies
7/9client-connect: Add CC_RET_DEFERRED and cope with deferred client-connectsrc/openvpn/multi.c src/openvpn/multi.h+185 -880 replies
8/9client-connect: Add deferred support to the client-connect script handlersrc/openvpn/multi.c src/openvpn/multi.h+177 -110 replies
9/9client-connect: Add deferred support to the client-connect plugin v1 handlersrc/openvpn/multi.c+20 -121 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [Openvpn-devel] [PATCH v2 0/9] Refactor client-connect / add support for deferred handling

Hi,

changes from v1:
- rebased to the current master,
- reports errors during file delete

Introduction to the patch-set:

A few years ago I wrote a patch-set concerning OpenVPN's client-connect code. The first part of the patch-set (patches 1 to 6) refactors and unifies the client-connect code.

The second part of the patch-set allows client-connect handling to proceed asynchronously, similar to how OpenVPN supports asynchronous (or deferred) authentication. Basically, the scripts or v1-plugins handling the client-connect event can now write back an additional status code that indicates deferred handling of the client-connect. This causes the OpenVPN server to continue with other things and to regularly re-read the status file. As soon as the status changes from "deferred" to "failed" or "succeeded", the client-connect processing for the connection is continued. (As mentioned before, the auth code does something very similar.)

The motivation for the deferred handling approach were relatively long running client-connect scripts (> 2s) intended for high-traffic servers. As the OpenVPN server completely blocks while synchronously waiting for client-connect scripts to complete, the asynchronous / deferred approach was needed.

The deferred script code path has been in production use for a few years now, although this freshly rebased patch-set has only seen light testing so far.

Feed-back would be very welcome.

The patches are also availabe on a Github branch:
https://github.com/fknittel/openvpn/tree/feat_deferred_client-connect

Cheers
Fabian

PS: See
https://github.com/fknittel/openvpn/wiki/Patch-set-%22deferred-client-connect%22
in case you're interested in ready-made Debian packages.

Fabian Knittel (9):
client-connect: Split multi_connection_established into separate
functions
client-connect: Properly indent all functions
client-connect: Refactor multi_client_connect_source_ccd
client-connect: Move multi_client_connect_setenv into early_setup
client-connect: Refactor to use return values instead of modifying a
passed-in flag
client-connect: Refactor client-connect handling to calling a bunch of
hooks in a loop
client-connect: Add CC_RET_DEFERRED and cope with deferred
client-connect
client-connect: Add deferred support to the client-connect script
handler
client-connect: Add deferred support to the client-connect plugin v1
handler

 src/openvpn/multi.c   | 839 +++++++++++++++++++++++++++++++++++---------------
 src/openvpn/multi.h   |  32 +-
 src/openvpn/options.h |   6 +
 3 files changed, 636 insertions(+), 241 deletions(-)
Signature · 1 line
2.1.4