From: "cron2 (Code Review)" Date: Sat, 9 Nov 2024 10:42:45 +0000 In-Reply-To: References: Reply-To: gert@...1296..., arne-openvpn@...1227..., openvpn-devel@lists.sourceforge.net, frank@...2641... Message-ID: <179e1fcb73a1aa68f5c3b1f361c1a077acc0e2ab-EmailReplacePatchSet-HTML@...2715...> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Disposition: inline Content-Type: multipart/alternative; boundary="Y6N+Pobtw9w="; charset=UTF-8 Subject: [Openvpn-devel] [L] Change in openvpn[master]: Remove support for compression on send List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: flichtenheld , plaisthos Cc: openvpn-devel --Y6N+Pobtw9w= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable cron2 has uploaded a new patch set (#7) to the change originally created by= flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/755?usp=3Demail ) The following approvals got outdated and were removed: Code-Review+2 by cron2 Change subject: Remove support for compression on send ...................................................................... Remove support for compression on send We can't disable compression support on receive because that would break too many configurations out there. But we can remove the support for compressing outgoing traffic, it was disabled by default anyway. Makes "--allow-compression yes" an alias for "--allow-compression asym" and removes all resulting dead code. Change-Id: I402ba016b75cfcfec4fc8b2b01cc4eca7e2bcc60 Signed-off-by: Frank Lichtenheld Acked-by: Arne Schwabe Acked-by: Gert Doering Message-Id: <20241108173851.436-1-gert@...1296...> URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg29= 718.html Signed-off-by: Gert Doering --- M Changes.rst M doc/man-sections/protocol-options.rst M src/openvpn/comp-lz4.c M src/openvpn/comp.h M src/openvpn/dco.c M src/openvpn/lzo.c M src/openvpn/options.c 7 files changed, 58 insertions(+), 327 deletions(-) git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/755/7 diff --git a/Changes.rst b/Changes.rst index 7d19577..a6cc3be 100644 --- a/Changes.rst +++ b/Changes.rst @@ -59,6 +59,12 @@ Support for building with OpenSSL 1.0.2 has been removed. The minimum supported OpenSSL version is now 1.1.0. +Compression on send + OpenVPN 2.7 will never compress data before sending. Decompression of + received data is still supported. + ``--allow-compression yes`` is now an alias for + ``--allow-compression asym``. + Overview of changes in 2.6 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D diff --git a/doc/man-sections/protocol-options.rst b/doc/man-sections/proto= col-options.rst index 8b061d2..05f87cc 100644 --- a/doc/man-sections/protocol-options.rst +++ b/doc/man-sections/protocol-options.rst @@ -10,17 +10,11 @@ dangerous option. This option allows controlling the behaviour of OpenVPN when compression is used and allowed. - Valid syntaxes: - :: - - allow-compression - allow-compression mode - The ``mode`` argument can be one of the following values: :code:`asym` - OpenVPN will only *decompress downlink packets* but *not compress - uplink packets*. This also allows migrating to disable compression + OpenVPN will only *decompress incoming packets* but *not compress + outgoing packets*. This also allows migrating to disable compression when changing both server and client configurations to remove compression at the same time is not a feasible option. @@ -30,7 +24,9 @@ framing (stub). :code:`yes` - OpenVPN will send and receive compressed packets. + **DEPRECATED** This option is an alias for :code:`asym`. Previously + it did enable compression for outgoing packets, but OpenVPN never + compresses packets on send now. --auth alg Authenticate data channel packets and (if enabled) ``tls-auth`` control @@ -135,48 +131,26 @@ entirely sure that the above does not apply to your traffic, you are advised to *not* enable compression. + For this reason compression support was removed from current versions + of OpenVPN. It will still decompress compressed packets received via + a VPN connection but it will never compress any outgoing packets. + --comp-lzo mode **DEPRECATED** Enable LZO compression algorithm. Compression is generally not recommended. VPN tunnels which uses compression are suspectible to the VORALCE attack vector. - Use LZO compression -- may add up to 1 byte per packet for incompressible - data. ``mode`` may be :code:`yes`, :code:`no`, or :code:`adaptive` - (default). + Allows the other side of the connection to use LZO compression. Due + to difference in packet format this may add 1 additional byte per packet. + With current versions of OpenVPN no actual compression will happen. - In a server mode setup, it is possible to selectively turn compression - on or off for individual clients. + ``mode`` may be :code:`yes`, :code:`no`, or :code:`adaptive` + but there is no actual change in behavior anymore. - First, make sure the client-side config file enables selective - compression by having at least one ``--comp-lzo`` directive, such as - ``--comp-lzo no``. This will turn off compression by default, but allow - a future directive push from the server to dynamically change the - :code:`on`/:code:`off`/:code:`adaptive` setting. - - Next in a ``--client-config-dir`` file, specify the compression setting - for the client, for example: - :: - - comp-lzo yes - push "comp-lzo yes" - - The first line sets the ``comp-lzo`` setting for the server side of the - link, the second sets the client side. --comp-noadapt - **DEPRECATED** When used in conjunction with ``--comp-lzo``, this option - will disable OpenVPN's adaptive compression algorithm. Normally, adaptive - compression is enabled with ``--comp-lzo``. - - Adaptive compression tries to optimize the case where you have - compression enabled, but you are sending predominantly incompressible - (or pre-compressed) packets over the tunnel, such as an FTP or rsync - transfer of a large, compressed file. With adaptive compression, OpenVPN - will periodically sample the compression process to measure its - efficiency. If the data being sent over the tunnel is already - compressed, the compression efficiency will be very low, triggering - openvpn to disable compression for a period of time until the next - re-sample test. + **DEPRECATED** This option does not have any effect anymore since current + versions of OpenVPN never compress outgoing packets. --key-direction Alternative way of specifying the optional direction parameter for the diff --git a/src/openvpn/comp-lz4.c b/src/openvpn/comp-lz4.c index ac020a4..b35df4a 100644 --- a/src/openvpn/comp-lz4.c +++ b/src/openvpn/comp-lz4.c @@ -55,129 +55,40 @@ { } -static bool -do_lz4_compress(struct buffer *buf, - struct buffer *work, - struct compress_context *compctx, - const struct frame *frame) -{ - /* - * In order to attempt compression, length must be at least COMPRESS_T= HRESHOLD. - * and asymmetric compression must be disabled - */ - if (buf->len >=3D COMPRESS_THRESHOLD && (compctx->flags & COMP_F_ALLOW= _COMPRESS)) - { - const size_t ps =3D frame->buf.payload_size; - int zlen_max =3D ps + COMP_EXTRA_BUFFER(ps); - int zlen; - - ASSERT(buf_init(work, frame->buf.headroom)); - ASSERT(buf_safe(work, zlen_max)); - - if (buf->len > ps) - { - dmsg(D_COMP_ERRORS, "LZ4 compression buffer overflow"); - buf->len =3D 0; - return false; - } - - zlen =3D LZ4_compress_default((const char *)BPTR(buf), (char *)BPT= R(work), BLEN(buf), zlen_max); - - if (zlen <=3D 0) - { - dmsg(D_COMP_ERRORS, "LZ4 compression error"); - buf->len =3D 0; - return false; - } - - ASSERT(buf_safe(work, zlen)); - work->len =3D zlen; - - - dmsg(D_COMP, "LZ4 compress %d -> %d", buf->len, work->len); - compctx->pre_compress +=3D buf->len; - compctx->post_compress +=3D work->len; - return true; - } - return false; -} - - +/* Doesn't do any actual compression anymore */ static void lz4_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, const struct frame *frame) { - bool compressed; if (buf->len <=3D 0) { return; } - compressed =3D do_lz4_compress(buf, &work, compctx, frame); + uint8_t comp_head_byte =3D NO_COMPRESS_BYTE_SWAP; + uint8_t *head =3D BPTR(buf); + uint8_t *tail =3D BEND(buf); + ASSERT(buf_safe(buf, 1)); + ++buf->len; - /* On error do_lz4_compress sets buf len to zero, just return */ - if (buf->len =3D=3D 0) - { - return; - } - - /* did compression save us anything? */ - { - uint8_t comp_head_byte =3D NO_COMPRESS_BYTE_SWAP; - if (compressed && work.len < buf->len) - { - *buf =3D work; - comp_head_byte =3D LZ4_COMPRESS_BYTE; - } - - { - uint8_t *head =3D BPTR(buf); - uint8_t *tail =3D BEND(buf); - ASSERT(buf_safe(buf, 1)); - ++buf->len; - - /* move head byte of payload to tail */ - *tail =3D *head; - *head =3D comp_head_byte; - } - } + /* move head byte of payload to tail */ + *tail =3D *head; + *head =3D comp_head_byte; } - +/* Doesn't do any actual compression anymore */ static void lz4v2_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, const struct frame *frame) { - bool compressed; if (buf->len <=3D 0) { return; } - compressed =3D do_lz4_compress(buf, &work, compctx, frame); - - /* On Error just return */ - if (buf->len =3D=3D 0) - { - return; - } - - /* did compression save us anything? Include 2 byte compression header - * in calculation */ - if (compressed && work.len + 2 < buf->len) - { - ASSERT(buf_prepend(&work, 2)); - uint8_t *head =3D BPTR(&work); - head[0] =3D COMP_ALGV2_INDICATOR_BYTE; - head[1] =3D COMP_ALGV2_LZ4_BYTE; - *buf =3D work; - } - else - { - compv2_escape_data_ifneeded(buf); - } + compv2_escape_data_ifneeded(buf); } static void diff --git a/src/openvpn/comp.h b/src/openvpn/comp.h index 267f680b..7eed331 100644 --- a/src/openvpn/comp.h +++ b/src/openvpn/comp.h @@ -32,8 +32,10 @@ * outside of the USE_COMP define */ /* Compression flags */ -#define COMP_F_ADAPTIVE (1<<0) /* COMP_ALG_LZO only */ -#define COMP_F_ALLOW_COMPRESS (1<<1) /* not only downlink is compres= sed but also uplink */ +/* Removed + #define COMP_F_ADAPTIVE (1<<0) / * COMP_ALG_LZO only * / + #define COMP_F_ALLOW_COMPRESS (1<<1) / * not only incoming is compr= essed but also outgoing * / + */ #define COMP_F_SWAP (1<<2) /* initial command byte is swap= ped with last byte in buffer to preserve payload alignment */ #define COMP_F_ADVERTISE_STUBS_ONLY (1<<3) /* tell server that we only sup= port compression stubs */ #define COMP_F_ALLOW_STUB_ONLY (1<<4) /* Only accept stub compression= , even with COMP_F_ADVERTISE_STUBS_ONLY diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c index 38f934a..dcc80d3 100644 --- a/src/openvpn/dco.c +++ b/src/openvpn/dco.c @@ -426,8 +426,7 @@ #if defined(USE_COMP) if (o->comp.alg !=3D COMP_ALG_UNDEF - || o->comp.flags & COMP_F_ALLOW_ASYM - || o->comp.flags & COMP_F_ALLOW_COMPRESS) + || o->comp.flags & COMP_F_ALLOW_ASYM) { msg(msglevel, "Note: '--allow-compression' is not set to 'no', dis= abling data channel offload."); diff --git a/src/openvpn/lzo.c b/src/openvpn/lzo.c index bab2d78..5cd5ea2 100644 --- a/src/openvpn/lzo.c +++ b/src/openvpn/lzo.c @@ -39,61 +39,6 @@ #include "memdbg.h" -/** - * Perform adaptive compression housekeeping. - * - * @param ac the adaptive compression state structure. - * - * @return - */ -static bool -lzo_adaptive_compress_test(struct lzo_adaptive_compress *ac) -{ - const bool save =3D ac->compress_state; - const time_t local_now =3D now; - - if (!ac->compress_state) - { - if (local_now >=3D ac->next) - { - if (ac->n_total > AC_MIN_BYTES - && (ac->n_total - ac->n_comp) < (ac->n_total / (100 / AC_S= AVE_PCT))) - { - ac->compress_state =3D true; - ac->next =3D local_now + AC_OFF_SEC; - } - else - { - ac->next =3D local_now + AC_SAMP_SEC; - } - dmsg(D_COMP, "lzo_adaptive_compress_test: comp=3D%d total=3D%d= ", ac->n_comp, ac->n_total); - ac->n_total =3D ac->n_comp =3D 0; - } - } - else - { - if (local_now >=3D ac->next) - { - ac->next =3D local_now + AC_SAMP_SEC; - ac->n_total =3D ac->n_comp =3D 0; - ac->compress_state =3D false; - } - } - - if (ac->compress_state !=3D save) - { - dmsg(D_COMP_LOW, "Adaptive compression state %s", (ac->compress_st= ate ? "OFF" : "ON")); - } - - return !ac->compress_state; -} - -static inline void -lzo_adaptive_compress_data(struct lzo_adaptive_compress *ac, int n_total, = int n_comp) -{ - ac->n_total +=3D n_total; - ac->n_comp +=3D n_comp; -} static void lzo_compress_init(struct compress_context *compctx) @@ -118,92 +63,13 @@ compctx->wu.lzo.wmem =3D NULL; } -static inline bool -lzo_compression_enabled(struct compress_context *compctx) -{ - if (!(compctx->flags & COMP_F_ALLOW_COMPRESS)) - { - return false; - } - else - { - if (compctx->flags & COMP_F_ADAPTIVE) - { - return lzo_adaptive_compress_test(&compctx->wu.lzo.ac); - } - else - { - return true; - } - } -} - static void lzo_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, const struct frame *frame) { - lzo_uint zlen =3D 0; - int err; - bool compressed =3D false; - - if (buf->len <=3D 0) - { - return; - } - - /* - * In order to attempt compression, length must be at least COMPRESS_T= HRESHOLD, - * and our adaptive level must give the OK. - */ - if (buf->len >=3D COMPRESS_THRESHOLD && lzo_compression_enabled(compct= x)) - { - const size_t ps =3D frame->buf.payload_size; - ASSERT(buf_init(&work, frame->buf.headroom)); - ASSERT(buf_safe(&work, ps + COMP_EXTRA_BUFFER(ps))); - - if (buf->len > ps) - { - dmsg(D_COMP_ERRORS, "LZO compression buffer overflow"); - buf->len =3D 0; - return; - } - - err =3D LZO_COMPRESS(BPTR(buf), BLEN(buf), BPTR(&work), &zlen, com= pctx->wu.lzo.wmem); - if (err !=3D LZO_E_OK) - { - dmsg(D_COMP_ERRORS, "LZO compression error: %d", err); - buf->len =3D 0; - return; - } - - ASSERT(buf_safe(&work, zlen)); - work.len =3D zlen; - compressed =3D true; - - dmsg(D_COMP, "LZO compress %d -> %d", buf->len, work.len); - compctx->pre_compress +=3D buf->len; - compctx->post_compress +=3D work.len; - - /* tell adaptive level about our success or lack thereof in gettin= g any size reduction */ - if (compctx->flags & COMP_F_ADAPTIVE) - { - lzo_adaptive_compress_data(&compctx->wu.lzo.ac, buf->len, work= .len); - } - } - - /* did compression save us anything ? */ - if (compressed && work.len < buf->len) - { - uint8_t *header =3D buf_prepend(&work, 1); - *header =3D LZO_COMPRESS_BYTE; - *buf =3D work; - } - else - { - uint8_t *header =3D buf_prepend(buf, 1); - *header =3D NO_COMPRESS_BYTE; - } + uint8_t *header =3D buf_prepend(buf, 1); + *header =3D NO_COMPRESS_BYTE; } static void diff --git a/src/openvpn/options.c b/src/openvpn/options.c index 61f6285..1beb0ee 100644 --- a/src/openvpn/options.c +++ b/src/openvpn/options.c @@ -5715,17 +5715,10 @@ { if (comp_non_stub_enabled(info)) { - /* - * Check if already displayed the strong warning and enabled full - * compression - */ - if (!(info->flags & COMP_F_ALLOW_COMPRESS)) - { - msg(M_WARN, "WARNING: Compression for receiving enabled. " - "Compression has been used in the past to break encryption= . " - "Sent packets are not compressed unless \"allow-compressio= n yes\" " - "is also set."); - } + msg(M_WARN, "WARNING: Compression for receiving enabled. " + "Compression has been used in the past to break encryption. " + "Compression support is deprecated and we recommend to disable= " + "it completely."); } } @@ -8435,18 +8428,14 @@ } else if (streq(p[1], "asym")) { - options->comp.flags &=3D ~COMP_F_ALLOW_COMPRESS; options->comp.flags |=3D COMP_F_ALLOW_ASYM; } else if (streq(p[1], "yes")) { - msg(M_WARN, "WARNING: Compression for sending and receiving en= abled. Compression has " - "been used in the past to break encryption. Allowing compr= ession allows " - "attacks that break encryption. Using \"--allow-compressio= n yes\" is " - "strongly discouraged for common usage. See --compress in = the manual " - "page for more information "); + msg(M_WARN, "DEPRECATED OPTION: \"--allow-compression yes\" ha= s been removed. " + "We will use \"asym\" mode instead. See the manual page fo= r more information."); - options->comp.flags |=3D COMP_F_ALLOW_COMPRESS; + options->comp.flags |=3D COMP_F_ALLOW_ASYM; } else { @@ -8461,45 +8450,29 @@ /* All lzo variants do not use swap */ options->comp.flags &=3D ~COMP_F_SWAP; + options->comp.alg =3D COMP_ALG_LZO; - if (p[1] && streq(p[1], "no")) + if (p[1]) { - options->comp.alg =3D COMP_ALG_STUB; - options->comp.flags &=3D ~COMP_F_ADAPTIVE; - } - else if (p[1]) - { - if (streq(p[1], "yes")) + if (streq(p[1], "no")) { - options->comp.alg =3D COMP_ALG_LZO; - options->comp.flags &=3D ~COMP_F_ADAPTIVE; + options->comp.alg =3D COMP_ALG_STUB; } - else if (streq(p[1], "adaptive")) - { - options->comp.alg =3D COMP_ALG_LZO; - options->comp.flags |=3D COMP_F_ADAPTIVE; - } - else + /* There is no actual difference anymore between these variant= s. + * We never compress. On the server side we replace this with + * --compress migrate later anyway. + */ + else if (!(streq(p[1], "yes") || streq(p[1], "adaptive"))) { msg(msglevel, "bad comp-lzo option: %s -- must be 'yes', '= no', or 'adaptive'", p[1]); goto err; } } - else - { - options->comp.alg =3D COMP_ALG_LZO; - options->comp.flags |=3D COMP_F_ADAPTIVE; - } show_compression_warning(&options->comp); } else if (streq(p[0], "comp-noadapt") && !p[1]) { - /* - * We do not need to check here if we allow compression since - * it only modifies a flag if compression is enabled - */ - VERIFY_PERMISSION(OPT_P_COMP); - options->comp.flags &=3D ~COMP_F_ADAPTIVE; + /* NO-OP since we never compress anymore */ } else if (streq(p[0], "compress") && !p[2]) { @@ -8528,7 +8501,7 @@ else if (streq(alg, "lzo")) { options->comp.alg =3D COMP_ALG_LZO; - options->comp.flags &=3D ~(COMP_F_ADAPTIVE | COMP_F_SWAP); + options->comp.flags &=3D ~COMP_F_SWAP; } else if (streq(alg, "lz4")) { -- To view, visit http://gerrit.openvpn.net/c/openvpn/+/755?usp=3Demail To unsubscribe, or for help writing mail filters, visit http://gerrit.openv= pn.net/settings Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I402ba016b75cfcfec4fc8b2b01cc4eca7e2bcc60 Gerrit-Change-Number: 755 Gerrit-PatchSet: 7 Gerrit-Owner: flichtenheld Gerrit-Reviewer: cron2 Gerrit-Reviewer: plaisthos Gerrit-CC: openvpn-devel Gerrit-MessageType: newpatchset --Y6N+Pobtw9w= Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

cron2 uploaded patch set #7 to the change originally cr= eated by flichtenheld.

View Change

The following approvals got outda= ted and were removed: Code-Review+2 by cron2

Remove support for compression on send

We can= 't disable compression support on receive because
that would break t= oo many configurations out there. But
we can remove the support for comp= ressing outgoing traffic,
it was disabled by default anyway.

Make= s "--allow-compression yes" an alias for
"--allow-compres= sion asym" and removes all resulting dead code.

Change-Id: I402= ba016b75cfcfec4fc8b2b01cc4eca7e2bcc60
Signed-off-by: Frank Lichtenheld &= lt;frank@...2641...>
Acked-by: Arne Schwabe <arne-openvpn@...2639...= ..>
Acked-by: Gert Doering <gert@...1296...>
Message-Id: <= ;20241108173851.436-1-gert@...1296...>
URL: https://www.mail-archive.= com/openvpn-devel@lists.sourceforge.net/msg29718.html
Signed-off-by: Ger= t Doering <gert@...1296...>
---
M Changes.rst
M doc/man-sect= ions/protocol-options.rst
M src/openvpn/comp-lz4.c
M src/openvpn/comp= .h
M src/openvpn/dco.c
M src/openvpn/lzo.c
M src/openvpn/options.c=
7 files changed, 58 insertions(+), 327 deletions(-)

git pull =
ssh://gerrit.openvpn.net:29418/openvpn refs/changes/55/755/7
diff -=
-git a/Changes.rst b/Changes.rst
index 7d19577..a6cc3be 100= 644
--- a/Changes.rst
+++ b/Changes.rst
@@ -59,6 +59,12 @@
Support for building w= ith OpenSSL 1.0.2 has been removed. The minimum
suppor= ted OpenSSL version is now 1.1.0.

+Compression on send
+ OpenVPN 2.7 will never compress data = before sending. Decompression of
+ received data is still supported.
+ ``--allow-compression yes`` is now an al= ias for
+ ``--allo= w-compression asym``.
+
Overview of changes in 2.6
=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D

diff --git a/doc/man-sections/protocol-options= .rst b/doc/man-sections/protocol-options.rst
index 8b061d2.= .05f87cc 100644
--- a/doc/man-sections/protocol-options.rst=
+++ b/doc/man-sections/protocol-options.rst
@@ -10,17 +10,11 @@

dangerous option. This option all= ows controlling the behaviour of
OpenVPN when compressio= n is used and allowed.

- Valid syntaxes:
- ::
-
- allow-compression=
- allow-compressi= on mode
-
The ``mode`` argument can be one of the following values:

<= span>

:code:`asym`
- OpenVPN will only *decompress downlink packets* but = *not compress
- up= link packets*. This also allows migrating to disable compression+ OpenVPN will only *deco= mpress incoming packets* but *not compress
+ outgoing packets*. This also allows migrating= to disable compression
when changing both server an= d client configurations to remove
compression at the= same time is not a feasible option.

@@ -= 30,7 +24,9 @@
framing (stub).

:code:`yes`
- OpenVPN will send and receive compressed packets.
+ **DEPRECATED** This option i= s an alias for :code:`asym`. Previously

+ it did enable compression for outgoing packets, b= ut OpenVPN never
+ = compresses packets on send now.

--aut= h alg
Authenticate data channel packets and (if enabled)= ``tls-auth`` control
@@ -135,48 +131,26 @@
entirely sure that the above does not apply to your traffic, you are
advised to *not* enable compression.

+ For this reason compr= ession support was removed from current versions
+ of OpenVPN. It will still decompress compres= sed packets received via
+ a VPN connection but it will never compress any outgoing packets.
+
--co= mp-lzo mode
**DEPRECATED** Enable LZO compression algori= thm. Compression is
generally not recommended. VPN tun= nels which uses compression are
suspectible to the VORAL= CE attack vector.

- Use LZO compression -- may add up to 1 byte per packet for = incompressible
- data.= ``mode`` may be :code:`yes`, :code:`no`, or :code:`adaptive`
- (default).

+ Allows the other side of the connection= to use LZO compression. Due
+ to difference in packet format this may add 1 additional byte pe= r packet.
+ With cur= rent versions of OpenVPN no actual compression will happen.

- In a server mode = setup, it is possible to selectively turn compression
- on or off for individual clients.<= br>+ ``mode`` may be :code:`ye= s`, :code:`no`, or :code:`adaptive`
+ but there is no actual change in behavior anymore.=

- First, m= ake sure the client-side config file enables selective
- compression by having at least one ``--c= omp-lzo`` directive, such as
- ``--comp-lzo no``. This will turn off compression by default, but = allow
- a future direc= tive push from the server to dynamically change the
- :code:`on`/:code:`off`/:code:`adaptive` s= etting.
-
- Next in a ``--client-config-dir``= file, specify the compression setting
- for the client, for example:
- ::
-
- comp-lzo= yes
- push "co= mp-lzo yes"
-
- The first line sets the = ``comp-lzo`` setting for the server side of the
- link, the second sets the client side.
--comp-noadapt
- **DEPRECATED** When used in conjunction with ``--comp= -lzo``, this option
- = will disable OpenVPN's adaptive compression algorithm. Normally, adapti= ve
- compression is en= abled with ``--comp-lzo``.
-
- Adaptive compr= ession tries to optimize the case where you have
- compression enabled, but you are sending predo= minantly incompressible
- (or pre-compressed) packets over the tunnel, such as an FTP or rsync
- transfer of a large, c= ompressed file. With adaptive compression, OpenVPN
- will periodically sample the compression pro= cess to measure its
- = efficiency. If the data being sent over the tunnel is already
- compressed, the compression effic= iency will be very low, triggering

- openvpn to disable compression for a period of time until th= e next
- re-sample tes= t.
+ **DEPRECATED** = This option does not have any effect anymore since current
+ versions of OpenVPN never compress= outgoing packets.

--key-direction

Alternative way of specifying the optional direction paramete= r for the
diff --git a/src/openvpn/comp-lz4.c b/src/openvpn= /comp-lz4.c
index ac020a4..b35df4a 100644
-= -- a/src/openvpn/comp-lz4.c
+++ b/src/openvpn/comp-lz4.c
@@ -55,129 +55,40 @@
{
}

-static= bool
-do_lz4_compress(= struct buffer *buf,
- = struct buffer *work,
- struct compress_context *compctx,
- const struct frame= *frame)

-{
<= span style=3D"color: hsl(0, 100%, 40%);">- /*

- * In order to attempt compression, length m= ust be at least COMPRESS_THRESHOLD.
- * and asymmetric compression must be disabled
= - */
- if (buf->len >=3D COMPRESS_THRESHOLD= && (compctx->flags & COMP_F_ALLOW_COMPRESS))
- {
- const size_t ps =3D frame->buf.payload_si= ze;
- int zlen_m= ax =3D ps + COMP_EXTRA_BUFFER(ps);
- int zlen;
-
- ASSE= RT(buf_init(work, frame->buf.headroom));
- ASSERT(buf_safe(work, zlen_max));
<= span style=3D"color: hsl(0, 100%, 40%);">-
- if (buf->len > ps)
- {
- dmsg(D_COMP_ERRORS, "LZ4 compression b= uffer overflow");
= - buf->len =3D 0;
- return false;
- }
-
- zlen =3D LZ= 4_compress_default((const char *)BPTR(buf), (char *)BPTR(work), BLEN(buf), = zlen_max);
-
= - if (zlen <=3D 0)

- {
- dmsg(D_COMP_ERRORS, "= LZ4 compression error");
- buf->len =3D 0;
- return false;
- }
-
- ASSE= RT(buf_safe(work, zlen));
- work->len =3D zlen;
-
-<= br>- dmsg(D_COMP, "LZ= 4 compress %d -> %d", buf->len, work->len);
- compctx->pre_compress +=3D b= uf->len;
- co= mpctx->post_compress +=3D work->len;
- return true;
- }
- return false;
-= }
-
-
+/* Doesn't do any actual compression anymore */ static void
lz4_compress(struct buffer *buf, stru= ct buffer work,
struct compress_context *comp= ctx,
const struct frame *frame)
{
- bool compres= sed;
if (buf->len <=3D 0)
{=
return;
}
<= /span>
- compressed =3D do_= lz4_compress(buf, &work, compctx, frame);
+ uint8_t comp_head_byte =3D NO_COMPRESS_BYTE_S= WAP;
+ uint8_t *he= ad =3D BPTR(buf);
+ = uint8_t *tail =3D BEND(buf);
+ ASSERT(buf_safe(buf, 1));
+ ++buf->len;

- /* On error do_lz4_compress sets bu= f len to zero, just return */
- if (buf->len =3D=3D 0)
- {
-= return;
- }<= /span>
-
- /* did compression save us anything? */=
- {
- uint8_t comp_head_byte =3D NO= _COMPRESS_BYTE_SWAP;

- = if (compressed && work.len < buf->len)
- {

- *buf =3D work;
- comp_head_byte =3D LZ4_COMPRESS= _BYTE;
- }
-
- {
- uint8_t *head =3D BPTR(buf);
- uint8_t *tail =3D BEND(buf);=
- ASSERT(bu= f_safe(buf, 1));
- = ++buf->len;
-=
- /* move h= ead byte of payload to tail */
- *tail =3D *head;
- *head =3D comp_head_byte;
- }
- }
+ /* move head byte of payload to tail */
+ *tail =3D *head;
+ *head =3D comp_head_byte;
}


= -
+/* Doesn't do = any actual compression anymore */
static void
lz4v2_compress(struct buffer *buf, struct buffer work,
struct compress_context *compctx,
= const struct frame *frame)
{
- bool compressed;
i= f (buf->len <=3D 0)
{
r= eturn;
}

- compressed =3D do_lz4_compress(buf, &work= , compctx, frame);
-

- /* On Error just ret= urn */
- if (buf->= ;len =3D=3D 0)
- {
- return;<= br>- }
-
- /* did compression save us anything? Include 2 byte compres= sion header
- * in = calculation */
- if = (compressed && work.len + 2 < buf->len)
- {
- ASSERT(buf_prepend(&work, 2));
- uint8_t *head =3D BPTR(&wo= rk);
- head[0] = =3D COMP_ALGV2_INDICATOR_BYTE;
- head[1] =3D COMP_ALGV2_LZ4_BYTE;
- *buf =3D work;
- }
- else
-= {
- compv2_e= scape_data_ifneeded(buf);
- }
+ compv2= _escape_data_ifneeded(buf);
}

= static void
diff --git a/src/openvpn/comp.h b/src/op= envpn/comp.h
index 267f680b..7eed331 100644
--- a/src/openvpn/comp.h

+++ b/src/openvpn/comp.h@@ -32,8 +32,10 @@
* outside of the USE_COMP defi= ne */

/* Compression flags */
= -#define COMP_F_ADAPTIVE = (1<<0) /* COMP_ALG_LZO only */
-#define COMP_F_ALLOW_COMPRESS (1<<1) /* not = only downlink is compressed but also uplink */
+/* Removed
+ #define COMP_F_ADAPTIVE (1<<0) / * COM= P_ALG_LZO only * /
+ = #define COMP_F_ALLOW_COMPRESS (1<<1) / * not only incoming is c= ompressed but also outgoing * /
+ */
#define COMP_F_SWAP (1<= <2) /* initial command byte is swapped with last byte in buffer to prese= rve payload alignment */
#define COMP_F_ADVERTISE_STUBS_ON= LY (1<<3) /* tell server that we only support compression stubs */
#define COMP_F_ALLOW_STUB_ONLY (1<<4) /* Only acc= ept stub compression, even with COMP_F_ADVERTISE_STUBS_ONLY
diff --git a/src/openvpn/dco.c b/src/openvpn/dco.c

index 3= 8f934a..dcc80d3 100644
--- a/src/openvpn/dco.c
+++ b/src/openvpn/dco.c
@@ -426,8 +426,7 @@
<= span>
#if defined(USE_COMP)
if (o-&g= t;comp.alg !=3D COMP_ALG_UNDEF
- || o->comp.flags & COMP_F_ALLOW_ASYM
- || o->comp.flags & CO= MP_F_ALLOW_COMPRESS)
= + || o->comp.flags & COMP_F_ALLOW_ASYM)
= {
msg(msglevel, "Note: '--allow-compressi= on' is not set to 'no', disabling data channel offload.");=

diff --git a/src/openvpn/lzo.c b/src/ope= nvpn/lzo.c
index bab2d78..5cd5ea2 100644
--= - a/src/openvpn/lzo.c
+++ b/src/openvpn/lzo.c
@@ -39,61 +39,6 @@

#include "mem= dbg.h"

-/**
- * Perform= adaptive compression housekeeping.
- *
- * @p= aram ac the adaptive compression state structure.
- *
- * @return
- *= /
-static bool-lzo_adaptive_compress_test(str= uct lzo_adaptive_compress *ac)
-{
- const b= ool save =3D ac->compress_state;
- const time_t local_now =3D now;
-
- if (!ac->compress_state)
- {
= - if (local_now >=3D ac->next)
- {
- if (ac->n_total > AC_MIN_BYTES
- && (ac->n_t= otal - ac->n_comp) < (ac->n_total / (100 / AC_SAVE_PCT)))- {
- ac->compress_state = =3D true;
- = ac->next =3D local_now + AC_OFF_SEC;
- }
- else
- {
= - ac->next =3D local_now + AC_SAMP_SEC;
- }
- dmsg(D_COMP, "lzo_adaptive_com= press_test: comp=3D%d total=3D%d", ac->n_comp, ac->n_total);

- ac->n_tota= l =3D ac->n_comp =3D 0;
- }
- }
- else
- {

- if (local_now >=3D ac->next)- {
- ac->next =3D local_now + AC_= SAMP_SEC;
- = ac->n_total =3D ac->n_comp =3D 0;
- ac->compress_state =3D false;
- }
- }
-
- if (= ac->compress_state !=3D save)
- {
- = dmsg(D_COMP_LOW, "Adaptive compression state %s", (ac->comp= ress_state ? "OFF" : "ON"));
- }
-
- return= !ac->compress_state;
-
-static inline void
-lzo_adaptive_compress_data(struct lzo_ada= ptive_compress *ac, int n_total, int n_comp)
-{
- ac->n_comp +=3D n_comp;
-}

static void

lzo_compress_init(struct compress_context *compctx)@@ -118,92 +63,13 @@
compctx->wu.lzo.wmem = =3D NULL;
}

-static inline bool
-lzo_compression_enabled(struct compress_context *comp= ctx)
-{
- if (!(compctx->flags & COM= P_F_ALLOW_COMPRESS))
- = {
- return fa= lse;
- }
<= span style=3D"color: hsl(0, 100%, 40%);">- else
- {
- if (compctx->flags & COMP_F_ADAPTIVE)- {
- return lzo_adaptive_compress_te= st(&compctx->wu.lzo.ac);
- }
- = else
- {
- return true= ;
- }
= - }
-}
-
static void
lzo_compress(struct b= uffer *buf, struct buffer work,
struct compre= ss_context *compctx,
const struct frame *fram= e)
{
-= lzo_uint zlen =3D 0;
- bo= ol compressed =3D false;
- if (buf->le= n <=3D 0)
- {
- return;- }
-
- /*
- * I= n order to attempt compression, length must be at least COMPRESS_THRESHOLD,=
- * and our adapti= ve level must give the OK.
- */
- if (b= uf->len >=3D COMPRESS_THRESHOLD && lzo_compression_enabled(co= mpctx))
- {- const size_t ps =3D fr= ame->buf.payload_size;
- ASSERT(buf_init(&work, frame->buf.headroom));
= - ASSERT(buf_safe(&wor= k, ps + COMP_EXTRA_BUFFER(ps)));
-
- if= (buf->len > ps)
= - {
- = dmsg(D_COMP_ERRORS, "LZO compression buffer overflow");- buf->len =3D 0;=
- return;
- }
-

- err =3D LZO_COMPRESS(BPTR(buf), BLEN(buf), BPTR(= &work), &zlen, compctx->wu.lzo.wmem);
- if (err !=3D LZO_E_OK)
- {
- dmsg(D_COMP_ERRORS, "LZO compressi= on error: %d", err);
- buf->len =3D 0;
- return;
- }
-<= /span>
- ASSERT(buf_saf= e(&work, zlen));
- = work.len =3D zlen;
- compressed =3D true;
-
- dm= sg(D_COMP, "LZO compress %d -> %d", buf->len, work.len);
- compctx->pre_= compress +=3D buf->len;
- compctx->post_compress +=3D work.len;
-
- /* tell adaptive level about our success or lack thereof= in getting any size reduction */
- if (compctx->flags & COMP_F_ADAPTIVE)
= - {
- lzo_adaptive_compress_data(&= ;compctx->wu.lzo.ac, buf->len, work.len);
- }
- }
-
- /* did compression = save us anything ? */
-= if (compressed && work.len < buf->len)
- {
- uint8_t *header =3D buf_prepend(&work, 1);
- *header =3D LZO= _COMPRESS_BYTE;
- = *buf =3D work;
- }=
- else
- {

- uint8_t *header =3D buf_prepend(buf, 1);
- *header =3D NO_= COMPRESS_BYTE;
- }
+ uint8_t *header = =3D buf_prepend(buf, 1);
+ *header =3D NO_COMPRESS_BYTE;
}
=
static void
diff --git a/src/openvpn/opti= ons.c b/src/openvpn/options.c
index 61f6285..1beb0ee 100644=
--- a/src/openvpn/options.c
+++ b/src/open= vpn/options.c
@@ -5715,17 +5715,10 @@
{
if (comp_non_stub_enabled(info))
{<= /span>
- /*
<= span style=3D"color: hsl(0, 100%, 40%);">- * Check if already displ= ayed the strong warning and enabled full

- * compression
- */
- if (!(info->flags & COMP_F_ALLOW_COMPRESS))=
- {
- msg(M_WARN, "WARNING: C= ompression for receiving enabled. "
- "Compression has been used in the p= ast to break encryption. "
- "Sent packets are not compressed unless \&qu= ot;allow-compression yes\" "
- "is also set.");
- }

+ msg(M_WARN, "WARNING: Compression = for receiving enabled. "
+ "Compression has been used in the past to break = encryption. "
+ = "Compression support is deprecated and we recommend to disa= ble "
+ = "it completely.");
}
}

@@ -8435,18 +8428,14 @@
= }
else if (streq(p[1], "asym"))
{
- options->comp.flags &=3D ~COMP_F_ALLOW_COMPRESS;
options->comp.flags |=3D COMP_F_ALLOW_ASYM;
}
else if (streq(p[1], &quo= t;yes"))
{
- msg(M_WARN, "WARNING: Compression for s= ending and receiving enabled. Compression has "
- "been used in the past= to break encryption. Allowing compression allows "
- "attacks that break= encryption. Using \"--allow-compression yes\" is "- "strongly= discouraged for common usage. See --compress in the manual "- "page for= more information ");
+ msg(M_WARN, "DEPRECATED OPTION: \"--allow-comp= ression yes\" has been removed. "
+ "We will use \"asym\"= ; mode instead. See the manual page for more information.");
- o= ptions->comp.flags |=3D COMP_F_ALLOW_COMPRESS;
+ options->comp.flags |=3D COMP_= F_ALLOW_ASYM;
}
else
{
@@ -8461,45 +8450,29 @@

/* All lzo variants do not use swap */

options->comp.flags &=3D ~COMP_F_SWAP;+ options->comp.alg = =3D COMP_ALG_LZO;

- if (p[1] && streq(p[1], "no"))
+ if (p[1])=
{
- = options->comp.alg =3D COMP_ALG_STUB;
- options->comp.flags &=3D ~C= OMP_F_ADAPTIVE;
- = }
- else if (p= [1])
- {<= br>- if (streq(p[1], &= quot;yes"))
+ = if (streq(p[1], "no"))
{
- options-= >comp.alg =3D COMP_ALG_LZO;
- options->comp.flags &=3D ~COMP_F_ADAPTIVE;<= /span>
+ opti= ons->comp.alg =3D COMP_ALG_STUB;
}- else if (streq(p[1= ], "adaptive"))
- {
- = options->comp.alg =3D COMP_ALG_LZO;
- options->comp.flags |=3D CO= MP_F_ADAPTIVE;
- = }
- els= e
+ /* The= re is no actual difference anymore between these variants.
+ * We never compress. On= the server side we replace this with
+ * --compress migrate later anyway.+ */
+ else if (!(streq(p[1]= , "yes") || streq(p[1], "adaptive")))

= {
msg(msglevel, "bad comp= -lzo option: %s -- must be 'yes', 'no', or 'adaptive= 9;", p[1]);
goto err;
}

}
- else
- {
-= options->comp.alg =3D COMP_ALG_LZO;
- options->comp.flags |=3D COMP_F= _ADAPTIVE;
- }
show_compression_warning(&options->comp);
}
else if (streq(p[0], "comp-n= oadapt") && !p[1])
{
- /*
- * We do not need to check here if we allow c= ompression since
- = * it only modifies a flag if compression is enabled
- */
- VERIFY_PERMISSION(OPT_P_COMP);
- options->comp.flags &am= p;=3D ~COMP_F_ADAPTIVE;

+ /* NO-OP since we never compress anymore */
= }
else if (streq(p[0], "compress") &&a= mp; !p[2])
{
@@ -8528,7 +8501,7 @@
else if (streq(alg, "lzo"))
{

options->comp.alg =3D COMP_ALG_= LZO;
- optio= ns->comp.flags &=3D ~(COMP_F_ADAPTIVE | COMP_F_SWAP);
+ options->comp.flags= &=3D ~COMP_F_SWAP;

}
= else if (streq(alg, "lz4"))
{

To view, visit change 755. To unsubscribe, or for hel= p writing mail filters, visit settings.

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I402ba016b75cfcfec4fc8b2b01c= c4eca7e2bcc60
Gerrit-Change-Number: 755
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <frank@...2723...= .>
Gerrit-Reviewer: cron2 <gert@...1296...>=
Gerrit-Reviewer: plaisthos <arne-openvpn@...1186...= .1227...>
Gerrit-CC: openvpn-devel <openvpn-devel@...1484...= ts.sourceforge.net>
Gerrit-MessageType: newpatchset
--Y6N+Pobtw9w=--