| Message ID | 1515067670-13094-1-git-send-email-steffan.karger@fox-it.com |
|---|---|
| State | Accepted |
| Headers |
Return-Path: <a@unstable.cc> Delivered-To: patchwork@openvpn.net Delivered-To: patchwork@openvpn.net Received: from director4.mail.ord1d.rsapps.net ([172.30.191.6]) by backend31.mail.ord1d.rsapps.net (Dovecot) with LMTP id m7SwArI7TloTJQAAgoeIoA for <patchwork@openvpn.net>; Thu, 04 Jan 2018 09:35:30 -0500 Received: from proxy2.mail.ord1d.rsapps.net ([172.30.191.6]) by director4.mail.ord1d.rsapps.net (Dovecot) with LMTP id c9SQArI7TlrhRAAAHDmxtw ; Thu, 04 Jan 2018 09:35:30 -0500 Received: from smtp32.gate.ord1c ([172.30.191.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) by proxy2.mail.ord1d.rsapps.net (Dovecot) with LMTP id OH0qArI7TloJIgAAfawv4w ; Thu, 04 Jan 2018 09:35:30 -0500 X-Spam-Threshold: 95 X-Spam-Score: 0 X-Spam-Flag: NO Authentication-Results: smtp32.gate.ord1c.rsapps.net x-tls.subject="/OU=Domain Control Validated/CN=www.neomailbox.net"; auth=pass (cipher=DHE-RSA-AES256-GCM-SHA384) X-Virus-Scanned: OK X-Orig-To: patchwork@openvpn.net X-Originating-Ip: [5.148.176.60] Authentication-Results: smtp32.gate.ord1c.rsapps.net; iprev=pass policy.iprev="5.148.176.60"; spf=permerror smtp.mailfrom="a@unstable.cc" smtp.helo="s2.neomailbox.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=fox-it.com X-Classification-ID: 820a4876-f15c-11e7-9c42-842b2b572c6a-1-1 Received: from [5.148.176.60] ([5.148.176.60:2351] helo=s2.neomailbox.net) by smtp32.gate.ord1c.rsapps.net (envelope-from <a@unstable.cc>) (ecelerity 4.2.1.56364 r(Core:4.2.1.14)) with ESMTPS (cipher=DHE-RSA-AES256-GCM-SHA384 subject="/OU=Domain Control Validated/CN=www.neomailbox.net") id 5C/3A-14149-1BB3E4A5; Thu, 04 Jan 2018 09:35:29 -0500 Resent-From: Antonio Quartulli <a@unstable.cc> Resent-To: patchwork@openvpn.net Resent-Date: Thu, 4 Jan 2018 22:34:24 +0800 Resent-Message-ID: <558e5e55-2c56-356b-dae4-d03c58436cd4@unstable.cc> Resent-User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:MIME-Version:Message-ID:Date:Subject: CC:To:From:Sender:Reply-To: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=tgRP2bxoX+5w02BJHqgmK6iOa28AhLriMYGIrNo5TIs=; b=FoGwD9tduA/ReZ9oMVXXCBBzEg yz6DjTt9TlKlf1rYFl95vZ7gzfzmfdhA6JTecPR6PMgfO8vGfKr+yr8zeys7e9x13NNJvPZqtFCFn 7CpN2q4gzcP7r0FwOYWbi7MHnh048d0i0X2xq1+mCH9NbQjqxXOi7K11DrY3JrN43f6A=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From:Sender: Reply-To: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=tgRP2bxoX+5w02BJHqgmK6iOa28AhLriMYGIrNo5TIs=; b=I mPGwsU0c84Oj2cHldxKXMaeyMAVW1sbbV4nByPIaMcfjXcOFcovK0Im8PKxdYNFLg/ms385PWTr/n hcl8C4XB9TjUGBRGZkX56NpYRIJyQrppkmvbLqxEapWbfPBb62dmyyh8QU3a49GlWWQd6pW7HQIe7 MPcsi5q+1td/HFpg=; From: Steffan Karger <steffan.karger@fox-it.com> To: <openvpn-devel@lists.sourceforge.net> Date: Thu, 4 Jan 2018 13:07:50 +0100 Message-ID: <1515067670-13094-1-git-send-email-steffan.karger@fox-it.com> MIME-Version: 1.0 X-ClientProxiedBy: FOXDFT52.FOX.local (10.0.0.129) To FOXDFT52.FOX.local (10.0.0.129) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -0.0 SPF_PASS SPF: sender matches SPF record X-Headers-End: 1eX4Jv-0004El-QI Subject: [Openvpn-devel] [PATCH] Check for more data in control channel X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: <openvpn-devel.lists.sourceforge.net> List-Unsubscribe: <https://lists.sourceforge.net/lists/options/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=unsubscribe> List-Archive: <http://sourceforge.net/mailarchive/forum.php?forum_name=openvpn-devel> List-Post: <mailto:openvpn-devel@lists.sourceforge.net> List-Help: <mailto:openvpn-devel-request@lists.sourceforge.net?subject=help> List-Subscribe: <https://lists.sourceforge.net/lists/listinfo/openvpn-devel>, <mailto:openvpn-devel-request@lists.sourceforge.net?subject=subscribe> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-SA-Score: -4.8 X-getmail-retrieved-from-mailbox: Inbox |
| Series |
[Openvpn-devel] Check for more data in control channel
|
|
Commit Message
Steffan Karger
Jan. 4, 2018, 1:07 a.m. UTC
If control channel packets arrive quickly after each other, or out of
order, there might be more data available than we can read in one
tls_process() call. If that happened, and no further control channel
packet arrived (e.g. because the last two packets arrived out-of-order),
we would wait for 16 second ("coarse timer") before we would read the
remaining data. To avoid that, always schedule ourself again if there
was control channel data, to check whether more data is available.
For mbedtls, we could implement a slightly more elegant "is there more
data?" function, instead of blindly rescheduling. But I can't find a way
to implement that for OpenSSL, and the current solution is very simple and
still has quite low overhead.
Signed-off-by: Steffan Karger <steffan.karger@fox-it.com>
---
src/openvpn/ssl.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On 04/01/18 13:07, Steffan Karger wrote: > If control channel packets arrive quickly after each other, or out of > order, there might be more data available than we can read in one > tls_process() call. If that happened, and no further control channel > packet arrived (e.g. because the last two packets arrived out-of-order), > we would wait for 16 second ("coarse timer") before we would read the > remaining data. To avoid that, always schedule ourself again if there > was control channel data, to check whether more data is available. > > For mbedtls, we could implement a slightly more elegant "is there more > data?" function, instead of blindly rescheduling. But I can't find a way > to implement that for OpenSSL, and the current solution is very simple and > still has quite low overhead. I haven't looked at the code paths yet (except of the patch itself) ... but how will this affect a server config with a bit of load? Like some hundred connected clients or more? Will these other clients notice that a client gets rescheduled instantly? And as well, what if more clients trigger this behaviour approximately in the same time window?
Hi David, On 05-01-18 20:48, David Sommerseth wrote: > On 04/01/18 13:07, Steffan Karger wrote: >> If control channel packets arrive quickly after each other, or out of >> order, there might be more data available than we can read in one >> tls_process() call. If that happened, and no further control channel >> packet arrived (e.g. because the last two packets arrived out-of-order), >> we would wait for 16 second ("coarse timer") before we would read the >> remaining data. To avoid that, always schedule ourself again if there >> was control channel data, to check whether more data is available. >> >> For mbedtls, we could implement a slightly more elegant "is there more >> data?" function, instead of blindly rescheduling. But I can't find a way >> to implement that for OpenSSL, and the current solution is very simple and >> still has quite low overhead. > > I haven't looked at the code paths yet (except of the patch itself) ... but > how will this affect a server config with a bit of load? Like some hundred > connected clients or more? Will these other clients notice that a client gets > rescheduled instantly? And as well, what if more clients trigger this > behaviour approximately in the same time window? Good question. One extra tls_process() loop for each connecting client should have barely any effect. Based on the code, I would expect it to be less processing than a single data channel packet. For more certainty, I ran some tests. This is the average time for setting up 50 connections simultaneously without bandwidth limits or packet loss (om my 5-year old dual core laptop), and waiting for all 50 to finish (average over 20 runs): Without the patch: Mean: 11.16 Stdev: 0.35 With the patch: Mean: 11.14 Stdev: 0.36 Same test, but now with an iperf maxing out the data channel at the same time (laptop turns into a blowdryer...): Without the patch: Mean: 11.17 Stdev: 0.68 With the patch: Mean: 11.33 Stdev: 0.55 (iperf reported for both a little over 400 Mbit/s) I think these numbers are a strong indication that my 'barely any effect' estimate is correct. -Steffan ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 So I've glared a bit on the code, and it makes sense to me (while not claiming I fully understand the full timer logic and scheduling). Smoke tested patch on RHEL7 (client) and Fedora 27 (server) and tested server code using the openvpn3-linux client as well. Everything seems to work as expected, including 'make check'. And since James didn't have any objections to this approach, I consider this safe to go. Acked-by: David Sommerseth <davids@openvpn.net> Your patch has been applied to the following branches commit b00d56e1b0cf4d71dc4944ef14ea7eca2fc8c519 (master) commit 8f15fa94dd9d7c4ce2dfe3378bd6311e2ad121ba (release/2.4) Author: Steffan Karger Date: Thu Jan 4 13:07:50 2018 +0100 Check for more data in control channel Signed-off-by: Steffan Karger <steffan.karger@fox-it.com> Acked-by: David Sommerseth <davids@openvpn.net> Message-Id: <1515067670-13094-1-git-send-email-steffan.karger@fox-it.com> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg16151.html Signed-off-by: David Sommerseth <davids@openvpn.net> - -- kind regards, David Sommerseth -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.22 (GNU/Linux) iQIcBAEBCgAGBQJaoGN5AAoJEIbPlEyWcf3ywZwQAJk0JkYcEw0PX0QbWGDsaY7F QqRMtp4kH9Agsx1/P2Sr5B8H08XBaWDrf+2u/qcZxefB5J7b6CCAR8ueqz+vBtOv PmUvHGrGKOZiqF2pQdqcZ+3pvljLVgXcw0uKOu4MM7TBeVhIN93F902xJE3r4cju G3K3Nv4CkgokNI2I/XBrZWJxeBSUn7gwuAwpIEcvo9LVMoaA1H24xdpIj39W7GdO qnouQUyQSo7UIufrkfqc06+inGGlQzSm31nVM3nGVMLOSnPi6Mjpo6GVhfLhEZMT R/IHnSL1P0/b1GXXe1OFmTw2NSIj+L2dixxFEhaaaUcfWzHn+EfnZiQNd6b+AEMV aqhJZfoQncIKLS3P4by27PSGEs3L416HGDUUGnFHtQxLw1YCUv8E1QvAznrGi2Ek m8lNntoW70y8jrHMnnkdrWI+/Ert0G0ZPDgl0O2ejnje7Y6FLgeU7HDu6dIC/2xs Xe55bdZi5rxVtgjh/jsrIZpi+yYorBKJSGKcZvappwjCGwzjY42biSOlo3dMrvFJ ASHYrzH47lRz+Wxl8Eixy43hcVqYYuebEkbzuLcMOF5LlNjX1biE8CrCgbNkL59t 9ClW9uglx7yfUP+BwgIzo/sD4s2IcAdE3dd3+v2QBvownuC6su+PQzo7GXfeeMlJ Xg514b81EsUdEeT4r5gY =C8xP -----END PGP SIGNATURE----- ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot
diff --git a/src/openvpn/ssl.c b/src/openvpn/ssl.c index 7b42845..15a37a3 100644 --- a/src/openvpn/ssl.c +++ b/src/openvpn/ssl.c @@ -2935,6 +2935,9 @@ tls_process(struct tls_multi *multi, { state_change = true; dmsg(D_TLS_DEBUG, "TLS -> Incoming Plaintext"); + + /* More data may be available, wake up again asap to check. */ + *wakeup = 0; } }