From patchwork Mon Nov 12 00:56:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 594 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.30.191.6]) by backend30.mail.ord1d.rsapps.net with LMTP id sDe6HNpq6Vu5CgAAIUCqbw for ; Mon, 12 Nov 2018 06:58:18 -0500 Received: from proxy14.mail.ord1d.rsapps.net ([172.30.191.6]) by director9.mail.ord1d.rsapps.net with LMTP id mKKUHNpq6VszDgAAalYnBA ; Mon, 12 Nov 2018 06:58:18 -0500 Received: from smtp8.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy14.mail.ord1d.rsapps.net with LMTP id CJRHHNpq6VuYcwAAtEH5vw ; Mon, 12 Nov 2018 06:58:18 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO X-Virus-Scanned: OK X-Orig-To: openvpnslackdevel@openvpn.net X-Originating-Ip: [216.105.38.7] Authentication-Results: smtp8.gate.ord1d.rsapps.net; iprev=pass policy.iprev="216.105.38.7"; spf=pass smtp.mailfrom="openvpn-devel-bounces@lists.sourceforge.net" smtp.helo="lists.sourceforge.net"; dkim=fail (signature verification failed) header.d=sourceforge.net; dkim=fail (signature verification failed) header.d=sf.net; dmarc=none (p=nil; dis=none) header.from=rfc2549.org X-Suspicious-Flag: YES X-Classification-ID: 3d8c08fe-e672-11e8-949e-5254001e5a60-1-1 Received: from [216.105.38.7] ([216.105.38.7:20903] helo=lists.sourceforge.net) by smtp8.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 1E/7B-15592-9DA69EB5; Mon, 12 Nov 2018 06:58:17 -0500 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.90_1) (envelope-from ) id 1gMAq9-0002Sh-6z; Mon, 12 Nov 2018 11:57:13 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1gMAq3-0002RI-TF for openvpn-devel@lists.sourceforge.NET; Mon, 12 Nov 2018 11:57:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=References:In-Reply-To:Message-Id:Date:Subject:To: From:Sender:Reply-To:Cc:MIME-Version:Content-Type:Content-Transfer-Encoding: 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=vY9b9i6krtdpYYbWU/c8sPxq+7D1V+jqW9dU2ErBBlY=; b=F/I12Fe4TSVT4KnfJlRM1LlOFb 3joKbLBMYZNgOosymVhfsaSrFh29mAlp47dkE3mL47Y5IUlzkIqGAm7QdL4l9SwM/VRLWsjWIsk6g LxdNrOsJZhHTDBx2UAYyrOci7u0kRFSOrhiTfILVkFUgGT5fdWVAwb7fnj8/sJrNZbuU=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=References:In-Reply-To:Message-Id:Date:Subject:To:From:Sender:Reply-To:Cc :MIME-Version:Content-Type:Content-Transfer-Encoding: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=vY9b9i6krtdpYYbWU/c8sPxq+7D1V+jqW9dU2ErBBlY=; b=IjrYH4pREkGQPHlCLcKAiqiG0s wKAVoR5pFv0FNBLcTbhTbgA1vrFCtHzVzjHpyQvbXkHDlB1Q/zUmm49alnEystupxVmGle8woxUvT bK+rJSsg/KAU0GUqRFhpB69giOyGrLKJpMeMsdT2XRd1KJvfWIMMl4+B/jk4ofrqBI6g=; Received: from mail.blinkt.de ([192.26.174.232]) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1gMApo-000iol-Pa for openvpn-devel@lists.sourceforge.NET; Mon, 12 Nov 2018 11:57:04 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.91 (FreeBSD)) (envelope-from ) id 1gMApQ-000JA5-DA for openvpn-devel@lists.sourceforge.net; Mon, 12 Nov 2018 12:56:28 +0100 Received: (nullmailer pid 5159 invoked by uid 10006); Mon, 12 Nov 2018 11:56:28 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Mon, 12 Nov 2018 12:56:20 +0100 Message-Id: <20181112115627.5096-7-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181112115627.5096-1-arne@rfc2549.org> References: <20181112115627.5096-1-arne@rfc2549.org> X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.4 AWL AWL: Adjusted score from AWL reputation of From: address X-Headers-End: 1gMApo-000iol-Pa Subject: [Openvpn-devel] [PATCH v3 06/13] client-connect: Change connection_established_flag from bool to enum 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: , MIME-Version: 1.0 Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox This prepares from the yes/no logic to a tristate logic with defered being the third state. This deviates from Fabian's original patch that that used a pointer being NULL or non NULL as implicit third state. Signed-off-by: Arne Schwabe --- src/openvpn/multi.c | 14 ++++++++------ src/openvpn/multi.h | 8 +++++++- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index 10a5af9a..3dbfb63f 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -574,7 +574,8 @@ static void multi_client_disconnect_script(struct multi_context *m, struct multi_instance *mi) { - if ((mi->context.c2.context_auth == CAS_SUCCEEDED && mi->connection_established_flag) + if ((mi->context.c2.context_auth == CAS_SUCCEEDED && + mi->client_connect_status == CC_STATUS_ESTABLISHED) || mi->context.c2.context_auth == CAS_PARTIAL) { multi_client_disconnect_setenv(m, mi); @@ -2052,7 +2053,7 @@ multi_client_connect_early_setup(struct multi_context *m, * Try to source a dynamic config file from the * --client-config-dir directory. */ -enum client_connect_return +static enum client_connect_return multi_client_connect_source_ccd(struct multi_context *m, struct multi_instance *mi, unsigned int *option_types_found) @@ -2197,7 +2198,7 @@ multi_connection_established(struct multi_context *m, struct multi_instance *mi) } /* set flag so we don't get called again */ - mi->connection_established_flag = true; + mi->client_connect_status = CC_STATUS_ESTABLISHED; /* increment number of current authenticated clients */ ++m->n_clients; @@ -2480,7 +2481,8 @@ multi_process_post(struct multi_context *m, struct multi_instance *mi, const uns { /* connection is "established" when SSL/TLS key negotiation succeeds * and (if specified) auth user/pass succeeds */ - if (!mi->connection_established_flag && CONNECTION_ESTABLISHED(&mi->context)) + if (mi->client_connect_status != CC_STATUS_ESTABLISHED + && CONNECTION_ESTABLISHED(&mi->context)) { multi_connection_established(m, mi); } @@ -3386,7 +3388,7 @@ management_client_auth(void *arg, { if (auth) { - if (!mi->connection_established_flag) + if (mi->client_connect_status == CC_STATUS_NOT_ESTABLISHED) { set_cc_config(mi, cc_config); cc_config_owned = false; @@ -3398,7 +3400,7 @@ management_client_auth(void *arg, { msg(D_MULTI_LOW, "MULTI: connection rejected: %s, CLI:%s", reason, np(client_reason)); } - if (mi->connection_established_flag) + if (mi->client_connect_status == CC_STATUS_ESTABLISHED) { send_auth_failed(&mi->context, client_reason); /* mid-session reauth failed */ multi_schedule_context_wakeup(m, mi); diff --git a/src/openvpn/multi.h b/src/openvpn/multi.h index 7f8d4f99..c476a67e 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -63,6 +63,12 @@ struct deferred_signal_schedule_entry struct timeval wakeup; }; +enum client_connect_status +{ + CC_STATUS_NOT_ESTABLISHED, + CC_STATUS_ESTABLISHED +}; + /** * Server-mode state structure for one single VPN tunnel. * @@ -105,7 +111,7 @@ struct multi_instance { bool did_cid_hash; struct buffer_list *cc_config; #endif - bool connection_established_flag; + enum client_connect_status client_connect_status; bool did_iroutes; int n_clients_delta; /* added to multi_context.n_clients when instance is closed */