From patchwork Thu Jul 2 23:55:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1200 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 WNG8KLAA/172RAAAIUCqbw for ; Fri, 03 Jul 2020 05:56:00 -0400 Received: from proxy12.mail.ord1d.rsapps.net ([172.30.191.6]) by director9.mail.ord1d.rsapps.net with LMTP id KLiDKLAA/16/VQAAalYnBA ; Fri, 03 Jul 2020 05:56:00 -0400 Received: from smtp28.gate.ord1d ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy12.mail.ord1d.rsapps.net with LMTP id wN8eKLAA/14GFwAA7PHxkg ; Fri, 03 Jul 2020 05:56:00 -0400 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: smtp28.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: 65b60cc0-bd13-11ea-9475-525400ea129b-1-1 Received: from [216.105.38.7] ([216.105.38.7:56468] helo=lists.sourceforge.net) by smtp28.gate.ord1d.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 6F/A5-28683-0B00FFE5; Fri, 03 Jul 2020 05:56:00 -0400 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 1jrIPf-0000An-DZ; Fri, 03 Jul 2020 09:55:19 +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 1jrIPd-0000Ad-BC for openvpn-devel@lists.sourceforge.net; Fri, 03 Jul 2020 09:55:17 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=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:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=lS+qfanUHg5p7orrW+wlbqB0c6oAMpwzKa5Ulk0Es+c=; b=ZtrIwXSYqqe7w3vsijwPSF1Jyp iY4wtWuiAOwJM25rHs5cIcmd4oawkmDvIsKemUfA+ITevnvDuBbBQXfCUzpE4aefOLgxF0AmCqhKj 3R/4OuXP+amiziSmVCnxqCpKMzYKG4l90kyiDhH14bdYMowqjy993CesYW7/BNoBq4+M=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=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: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=lS+qfanUHg5p7orrW+wlbqB0c6oAMpwzKa5Ulk0Es+c=; b=GPdCwi5nLu8RRvM1vfpK6oaToE uiDtxb+cyo6oC9vWMJjw7D4Mgw4VmQx38eCepgl+x0C0Fmx3I9IAKr0KG/nm7K+af8iIgfRcA5CX1 7HbEOycU+TtF6bGzdSooHJO55034zY3nktW6Ia0PBHBgbqMLdEWLLwAeMLPPSwhOYagU=; 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.92.2) id 1jrIPb-00Bnwx-CT for openvpn-devel@lists.sourceforge.net; Fri, 03 Jul 2020 09:55:17 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.92.3 (FreeBSD)) (envelope-from ) id 1jrIPS-000H7d-FL for openvpn-devel@lists.sourceforge.net; Fri, 03 Jul 2020 11:55:06 +0200 Received: (nullmailer pid 28609 invoked by uid 10006); Fri, 03 Jul 2020 09:55:06 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Fri, 3 Jul 2020 11:55:06 +0200 Message-Id: <20200703095506.28559-1-arne@rfc2549.org> X-Mailer: git-send-email 2.17.1 X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. 0.0 URIBL_BLOCKED ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [URIs: rfc2549.org] 0.0 HEADER_FROM_DIFFERENT_DOMAINS From and EnvelopeFrom 2nd level mail domains are different 0.0 SPF_NONE SPF: sender does not publish an SPF Record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record X-Headers-End: 1jrIPb-00Bnwx-CT Subject: [Openvpn-devel] [PATCH] Remove did_open_context, defined and connection_established_flag 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 multi_instance->defined is not used anywhere. did_open_context is always set to true when a context is created in multi_create_instance, so checking it for true is always true. context_auth is also always set to CAS_PENDING in multi_create_instance. connection_established_flag is only set to true if context_auth is changed from CAS_PENDING to one another state, so we can also check for cas_context != CAS_PENDING. Signed-off-by: Arne Schwabe Acked-by: Antonio Quartulli --- src/openvpn/multi.c | 18 ++++++------------ src/openvpn/multi.h | 3 --- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/openvpn/multi.c b/src/openvpn/multi.c index e9f021bb..6923d2ce 100644 --- a/src/openvpn/multi.c +++ b/src/openvpn/multi.c @@ -574,7 +574,7 @@ multi_client_disconnect_setenv(struct multi_instance *mi) static void multi_client_disconnect_script(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->context.c2.context_auth == CAS_PARTIAL) { multi_client_disconnect_setenv(mi); @@ -686,10 +686,7 @@ multi_close_instance(struct multi_context *m, multi_client_disconnect_script(mi); - if (mi->did_open_context) - { - close_context(&mi->context, SIGTERM, CC_GC_FREE); - } + close_context(&mi->context, SIGTERM, CC_GC_FREE); multi_tcp_instance_specific_free(mi); @@ -788,7 +785,6 @@ multi_create_instance(struct multi_context *m, const struct mroute_addr *real) generate_prefix(mi); } - mi->did_open_context = true; inherit_context_child(&mi->context, &m->top); if (IS_SIG(&mi->context)) { @@ -2089,9 +2085,6 @@ script_failed: mi->context.c2.context_auth = cc_succeeded_count ? CAS_PARTIAL : CAS_FAILED; } - /* set flag so we don't get called again */ - mi->connection_established_flag = true; - /* increment number of current authenticated clients */ ++m->n_clients; update_mstat_n_clients(m->n_clients); @@ -2395,7 +2388,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->context.c2.context_auth == CAS_PENDING + && CONNECTION_ESTABLISHED(&mi->context)) { multi_connection_established(m, mi); } @@ -3349,7 +3343,7 @@ management_client_auth(void *arg, { if (auth) { - if (!mi->connection_established_flag) + if (mi->context.c2.context_auth == CAS_PENDING) { set_cc_config(mi, cc_config); cc_config_owned = false; @@ -3361,7 +3355,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->context.c2.context_auth != CAS_PENDING) { 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 3d949e30..8c9c4609 100644 --- a/src/openvpn/multi.h +++ b/src/openvpn/multi.h @@ -75,7 +75,6 @@ struct deferred_signal_schedule_entry struct multi_instance { struct schedule_entry se; /* this must be the first element of the structure */ struct gc_arena gc; - bool defined; bool halt; int refcount; int route_count; /* number of routes (including cached routes) owned by this instance */ @@ -97,14 +96,12 @@ struct multi_instance { in_addr_t reporting_addr; /* IP address shown in status listing */ struct in6_addr reporting_addr_ipv6; /* IPv6 address in status listing */ - bool did_open_context; bool did_real_hash; bool did_iter; #ifdef MANAGEMENT_DEF_AUTH bool did_cid_hash; struct buffer_list *cc_config; #endif - bool connection_established_flag; bool did_iroutes; int n_clients_delta; /* added to multi_context.n_clients when instance is closed */