From patchwork Wed Jul 24 01:41:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Kaldor X-Patchwork-Id: 786 Return-Path: Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director8.mail.ord1d.rsapps.net ([172.27.255.52]) by backend30.mail.ord1d.rsapps.net with LMTP id 0DOfB0NEOF2cKwAAIUCqbw for ; Wed, 24 Jul 2019 07:42:59 -0400 Received: from proxy11.mail.iad3a.rsapps.net ([172.27.255.52]) by director8.mail.ord1d.rsapps.net with LMTP id uHmmBENEOF1UVAAAfY0hYg ; Wed, 24 Jul 2019 07:42:59 -0400 Received: from smtp50.gate.iad3a ([172.27.255.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy11.mail.iad3a.rsapps.net with LMTP id iA91OUJEOF1RcAAAxCvdqw ; Wed, 24 Jul 2019 07:42:58 -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: smtp50.gate.iad3a.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; dkim=fail (signature verification failed) header.d=tunnelbear-com.20150623.gappssmtp.com; dmarc=fail (p=none; dis=none) header.from=tunnelbear.com X-Suspicious-Flag: YES X-Classification-ID: 2ee276fe-ae08-11e9-bb0b-525400c2fb51-1-1 Received: from [216.105.38.7] ([216.105.38.7:44584] helo=lists.sourceforge.net) by smtp50.gate.iad3a.rsapps.net (envelope-from ) (ecelerity 4.2.38.62370 r(:)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384) id 7C/4B-07292-244483D5; Wed, 24 Jul 2019 07:42:58 -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 1hqFeY-0002cT-QD; Wed, 24 Jul 2019 11:41:50 +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 1hqFeW-0002cM-Nv for openvpn-devel@lists.sourceforge.net; Wed, 24 Jul 2019 11:41:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:To:Subject:Message-ID:Date:From: MIME-Version:Sender:Reply-To:Cc: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=+gGEbGBst80VnKJJVCxGKXlzMh7M1Hkqe6fWrIFDUIo=; b=mg1T0yR1dI18B9QhTqTc3vLBSr ZHj0dOY5e0ynzbm9Ax4DYUhmPD96gvAvtE2dhayEv8FqaI3sxz5gafH/FQFa1djcbPhL/wMIXTVOk AukGsHxRP6GPRkWPFOvPM3XMYzK5yqCtydTNDvohf5wmoOXc3K7RA6QKqH4uicZM8wBI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:To:Subject:Message-ID:Date:From:MIME-Version:Sender:Reply-To :Cc: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=+gGEbGBst80VnKJJVCxGKXlzMh7M1Hkqe6fWrIFDUIo=; b=N VfVzV99phrUK8VYoGBkDO59VhhwA/+1Hs9ojtldwvRjfPKV2zI9D86k4ZCi/IxxLf1icqdkLhlzRm peWP7Kz5X9M2+Gtb2/AkHV3vbOSLWGeLAKyHIc7/OuK5UYPgLgYZIKrmKcPptkDprc5cP2dliN1i7 hzBMBkf0Xa0DeZqQ=; Received: from mail-qt1-f195.google.com ([209.85.160.195]) by sfi-mx-3.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.90_1) id 1hqFeU-00E6G5-Q5 for openvpn-devel@lists.sourceforge.net; Wed, 24 Jul 2019 11:41:48 +0000 Received: by mail-qt1-f195.google.com with SMTP id k10so45170117qtq.1 for ; Wed, 24 Jul 2019 04:41:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tunnelbear-com.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=+gGEbGBst80VnKJJVCxGKXlzMh7M1Hkqe6fWrIFDUIo=; b=mm8HWgSr9rTpoRqt3WvF9u6PGXSFlp02a1qjFy1TZtzzpXs799CxN5AS0m++rHYTD8 7E1B+lhftmuLQgPBKxK+GpsVMSG6HBKohJ+T7GlnSfSvOaIt5C1LvWCSmTBCgl1trj7W Yz9cew2xPg+7AfQ638DIJPQDMfX7Gp2zBkwBsbdE0rEOdYgMFutMZJn2UulZpbwl8wuo 2ssmNWe7ZwLz8rd0JlIWV9H/0nR07naUaAqh12rhJV7dfw4mtZsOkByUpYmvP+V6vPuk TB9mY01/hYUrjmEvCmduQ/vAjSxMFVZk2vpF17nb3DRCrQrQIz7Kuf2I7AHS52nf6DXn fKTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=+gGEbGBst80VnKJJVCxGKXlzMh7M1Hkqe6fWrIFDUIo=; b=GIHHKO4MypjFCjEXdTovwFVUraoXEN2y6gElhRQZcIQ38yQD869v3+IRaHHBY+JLb6 pIO4IxGSBLo1WWm+RL4Wuq8bw9S+FYuxIpOLu3VxocC+jdcTwiszMRO0R2kKMHub56J5 swBy8bBTd7gzyOa1KFEXKN8AizGLX7ZkZsbLWo347UbIXrY+XnUIh8tE7/+s1u3VMM+U wY5U6pb2VzWuwktLhgpcJqK45d5GzGQYpk5MW5QVSvIfNINP4J1LCkJjWO6THzo9t9N0 mJ9LbK4fEc39SOiYucQrDtiOW/HNVjZJSAFEfKgCDvkpjlpNa2iX3GGvs7mLIIdxTiMJ VuPQ== X-Gm-Message-State: APjAAAVWSn7OI/tg3MLqS3JUpCMBjn1JUtmRBFasMoQfLDG3OZJ+tUZl 8DKAMgYws6H2j57zT2uwO9Yi7Nuz7CByf7tFeYfsCMrXAEXvXQ== X-Google-Smtp-Source: APXvYqy9Ai9t6LorBQuDEAE5ZeTfY68KWr5ahFYmySK0L7V7wjv80snME91/kLPU/+LyKuHTKD87fVen4KKK6Ehlhes= X-Received: by 2002:ac8:3449:: with SMTP id v9mr58134303qtb.163.1563968500525; Wed, 24 Jul 2019 04:41:40 -0700 (PDT) MIME-Version: 1.0 From: Daniel Kaldor Date: Wed, 24 Jul 2019 12:41:17 +0100 Message-ID: To: openvpn-devel@lists.sourceforge.net X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [209.85.160.195 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-Headers-End: 1hqFeU-00E6G5-Q5 Subject: [Openvpn-devel] [PATCH 1/1] Start TLS after connection established without waiting. 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: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox There is a ~1s delay between establishing connection with remote server and starting TLS handshake. This change removes delay and improves connection time. --- src/openvpn/forward.c | 61 +++++++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 29 deletions(-) -- 2.9.3 (Apple Git-75) diff --git a/src/openvpn/forward.c b/src/openvpn/forward.c index 35df089..2deaf93 100644 --- a/src/openvpn/forward.c +++ b/src/openvpn/forward.c @@ -433,28 +433,6 @@ check_connection_established_dowork(struct context *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) - { -#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 */ { do_up(c, false, 0); } @@ -1943,17 +1921,34 @@ pre_select(struct context *c) } } #endif - - /* check coarse timers? */ - check_coarse_timers(c); - if (c->sig->signal_received) - { - return; - } + + bool pre_connection_state = CONNECTION_ESTABLISHED(c); /* Does TLS need service? */ check_tls(c); + bool post_connection_state = CONNECTION_ESTABLISHED(c); + + if(!pre_connection_state && post_connection_state){ + + 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 + check_push_request_dowork(c); + } + } + /* In certain cases, TLS errors will require a restart */ check_tls_errors(c); if (c->sig->signal_received) @@ -1961,6 +1956,14 @@ pre_select(struct context *c) return; } + /* check coarse timers */ + check_coarse_timers(c); + if (c->sig->signal_received) + { + return; + } + + /* check for incoming configuration info on the control channel */ check_incoming_control_channel(c);