From patchwork Sat Jul 25 13:48:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arne Schwabe X-Patchwork-Id: 1336 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director9.mail.ord1d.rsapps.net ([172.31.255.6]) by backend30.mail.ord1d.rsapps.net with LMTP id KA6UHPvEHF9hEQAAIUCqbw for ; Sat, 25 Jul 2020 19:49:15 -0400 Received: from proxy12.mail.iad3b.rsapps.net ([172.31.255.6]) by director9.mail.ord1d.rsapps.net with LMTP id 4NplG/vEHF/UPQAAalYnBA (envelope-from ) for ; Sat, 25 Jul 2020 19:49:15 -0400 Received: from smtp10.gate.iad3b ([172.31.255.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy12.mail.iad3b.rsapps.net with LMTP id oH+TFfvEHF/CGAAAEsW3lA ; Sat, 25 Jul 2020 19:49:15 -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: smtp10.gate.iad3b.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: 71e68e3c-ced1-11ea-a738-52540055034d-1-1 Received: from [216.105.38.7] ([216.105.38.7:43568] helo=lists.sourceforge.net) by smtp10.gate.iad3b.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 00/02-18108-AF4CC1F5; Sat, 25 Jul 2020 19:49:15 -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 1jzTts-0002x5-KQ; Sat, 25 Jul 2020 23:48:20 +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 1jzTtr-0002wy-Df for openvpn-devel@lists.sourceforge.net; Sat, 25 Jul 2020 23:48:19 +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=XixLgLplWmeu90ZnCEj8+u2nyAAkRccFnDdxvRh1Udw=; b=FUMOfVv/IFw+GNWRBox0RRSDhj WIsMBzD7tdp+UNIMzmmHMPempxP08oyF26ouJUnQnbWXWtCwEjB5njDoqnjU70YviM10q8vL1H+l5 T4wemRy1nHFPNQOqLsiguiUJjRTNlNuBsRtdmCfsJz3sAVgvOwmPrDiIiFepQi8d28d0=; 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=XixLgLplWmeu90ZnCEj8+u2nyAAkRccFnDdxvRh1Udw=; b=eWHNkaCwv9aA4/mOtxzaojfeQ5 9GuvCj6L1gDQx7H2EjIFoda8xe0vzCuzPzra231Biuy1MDniyNg6WUIyq+LKZRhq/ubT46oYhAkQJ XBK+SAFMSIqVRt8/RtqWSuwDI6NBw3yI2D/12XTK0POLIwxRiz3Quxe8Npt8qOTEg0zs=; 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 1jzTtp-0097GT-F3 for openvpn-devel@lists.sourceforge.net; Sat, 25 Jul 2020 23:48:19 +0000 Received: from kamera.blinkt.de ([2001:638:502:390:20c:29ff:fec8:535c]) by mail.blinkt.de with smtp (Exim 4.94 (FreeBSD)) (envelope-from ) id 1jzTtb-0006si-PY for openvpn-devel@lists.sourceforge.net; Sun, 26 Jul 2020 01:48:03 +0200 Received: (nullmailer pid 22103 invoked by uid 10006); Sat, 25 Jul 2020 23:48:03 -0000 From: Arne Schwabe To: openvpn-devel@lists.sourceforge.net Date: Sun, 26 Jul 2020 01:48:02 +0200 Message-Id: <20200725234803.22058-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: 1jzTtp-0097GT-F3 Subject: [Openvpn-devel] [PATCH 1/2] Simplify calling logic of check_connection_established_dowork 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 The check event_timeout_defined in check_connection_established is completely redundant as event_timeout_trigger will do the very same check as first action. Removing this check makes the function superfluous. To further improve the code move the call check if the time is expired into process_coarse_timers Signed-off-by: Arne Schwabe Acked-by: Gert Doering --- src/openvpn/forward.c | 77 +++++++++++++++++++------------------------ src/openvpn/forward.h | 2 +- 2 files changed, 34 insertions(+), 45 deletions(-) diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 3d462d0a..30a3fd46 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -138,21 +138,6 @@ check_incoming_control_channel(struct context *c) #endif } -/* - * Options like --up-delay need to be triggered by this function which - * checks for connection establishment. - */ -static inline void -check_connection_established(struct context *c) -{ - void check_connection_established_dowork(struct context *c); - - if (event_timeout_defined(&c->c2.wait_for_connect)) - { - check_connection_established_dowork(c); - } -} - /* * Should we add routes? */ @@ -437,43 +422,45 @@ check_push_request_dowork(struct context *c) /* * Things that need to happen immediately after connection initiation should go here. + * + * Options like --up-delay need to be triggered by this function which + * checks for connection establishment. */ void -check_connection_established_dowork(struct context *c) +check_connection_established(struct context *c) { - if (event_timeout_trigger(&c->c2.wait_for_connect, &c->c2.timeval, ETT_DEFAULT)) + + if (CONNECTION_ESTABLISHED(c)) { - if (CONNECTION_ESTABLISHED(c)) - { #if P2MP - /* if --pull was specified, send a push request to server */ - if (c->c2.tls_multi && c->options.pull) - { + /* if --pull was specified, send a push request to server */ + if (c->c2.tls_multi && c->options.pull) + { #ifdef ENABLE_MANAGEMENT - if (management) - { - management_set_state(management, - OPENVPN_STATE_GET_CONFIG, - NULL, - NULL, - NULL, - NULL, - NULL); - } -#endif - /* fire up push request right away (already 1s delayed) */ - event_timeout_init(&c->c2.push_request_interval, 0, now); - reset_coarse_timers(c); - } - else -#endif /* if P2MP */ + if (management) { - do_up(c, false, 0); + management_set_state(management, + OPENVPN_STATE_GET_CONFIG, + NULL, + NULL, + NULL, + NULL, + NULL); } - - event_timeout_clear(&c->c2.wait_for_connect); +#endif + /* fire up push request right away (already 1s delayed) */ + event_timeout_init(&c->c2.push_request_interval, 0, now); + reset_coarse_timers(c); } + else +#endif /* if P2MP */ + { + do_up(c, false, 0); + } + + event_timeout_clear(&c->c2.wait_for_connect); } + } bool @@ -777,8 +764,10 @@ process_coarse_timers(struct context *c) check_status_file(c); /* process connection establishment items */ - check_connection_established(c); - + if (event_timeout_trigger(&c->c2.wait_for_connect, &c->c2.timeval, ETT_DEFAULT)) + { + check_connection_established(c); + } #if P2MP /* see if we should send a push_request in response to --pull */ check_push_request(c); diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index ff898133..635e84ae 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -88,7 +88,7 @@ void check_fragment_dowork(struct context *c); #endif /* ENABLE_FRAGMENT */ -void check_connection_established_dowork(struct context *c); +void check_connection_established(struct context *c); void check_add_routes_dowork(struct context *c);