Attention is currently required from: Arne Schwabe.
Hello Arne Schwabe,
I'd like you to do a code review.
Please visit
https://gerrit.openvpn.net/c/openvpn/+/2328?usp=email
to review the following change.
Change subject: comp: drop compression on send leftovers
......................................................................
comp: drop compression on send leftovers
7f0214c9 ("Remove support for compression on send") left the LZO
compression workspace, adaptive compression state and related defines
behind. lzo1x_decompress_safe() ignores its work memory argument, so
stop allocating LZO1X_1_15_MEM_COMPRESS bytes (256 KiB on 64-bit) per
LZO compression context and pass NULL instead.
Remove the now empty compress_workspace_union, COMPRESS_THRESHOLD and
D_COMP_LOW, probe for lzo1x_decompress_safe() instead of the unused
compressor in configure, and update the compression module docs.
Change-Id: I189f3a311719b5c4476351702a44870d485d10d8
Signed-off-by: Razvan Cojocaru <[email protected]>
---
M configure.ac
M doc/doxygen/doc_compression.h
M src/openvpn/comp-lz4.h
M src/openvpn/comp.h
M src/openvpn/errlevel.h
M src/openvpn/lzo.c
M src/openvpn/lzo.h
7 files changed, 29 insertions(+), 127 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/28/2328/1
diff --git a/configure.ac b/configure.ac
index 585c3bd..05fa964 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1001,11 +1001,11 @@
have_lzo="yes"
AC_CHECK_LIB(
[lzo2],
- [lzo1x_1_15_compress],
+ [lzo1x_decompress_safe],
[LZO_LIBS="-llzo2"],
[AC_CHECK_LIB(
[lzo],
- [lzo1x_1_15_compress],
+ [lzo1x_decompress_safe],
[LZO_LIBS="-llzo"],
[have_lzo="no"]
)]
diff --git a/doc/doxygen/doc_compression.h b/doc/doxygen/doc_compression.h
index efd18bf..4c60e74 100644
--- a/doc/doxygen/doc_compression.h
+++ b/doc/doxygen/doc_compression.h
@@ -29,31 +29,21 @@
/**
* @defgroup compression Data Channel Compression module
*
- * This module offers compression of data channel packets.
+ * This module decompresses incoming data channel packets and adds
+ * compression framing to outgoing ones.
*
* @par State structures
* The Data Channel Compression module stores its internal state in a \c
- * lzo_compress_workspace structure. This state includes flags which
- * control the module's behavior and preallocated working memory. One
- * such structure is present for each VPN tunnel, and is stored in the \c
- * context.c2.lzo_compwork of the \c context associated with that VPN
- * tunnel.
+ * compress_context structure. One such structure is present for each VPN
+ * tunnel, and is stored in the \c context.c2.comp_context of the \c
+ * context associated with that VPN tunnel.
*
* @par Initialization and cleanup
- * Every time a new \c lzo_compress_workspace is needed, it must be
- * initialized using the \c lzo_compress_init() function. Similarly,
- * every time a \c lzo_compress_workspace is no longer needed, it must be
- * cleaned up using the \c lzo_compress_uninit() function. These
- * functions take care of the allocation and freeing of internal working
- * memory, but not of the \c lzo_compress_workspace structures themselves.
- *
- * @par
- * Because of the one-to-one relationship between \c
- * lzo_compress_workspace structures and VPN tunnels, the above-mentioned
- * initialization and cleanup functions are called directly from the \c
- * init_instance() and \c close_instance() functions, which control the
- * initialization and cleanup of VPN tunnel instances and their associated
- * \c context structures.
+ * \c comp_init() allocates a \c compress_context and calls the \c
+ * compress_init method of its \c compress_alg; \c comp_uninit() calls
+ * the \c compress_uninit method and frees the structure. Both are called
+ * from \c init_instance() and \c close_instance(), and when pushed
+ * options change.
*
* @par Packet processing functions
* This module receives data channel packets from the \link data_control
@@ -67,25 +57,25 @@
*
* @par Settings that control this module's activity
* Whether or not the Data Channel Compression module is active depends on
- * the compile-time \c ENABLE_LZO preprocessor macro and the runtime flags
- * stored in \c lzo_compress_workspace.flags of the associated VPN tunnel.
- * The latter are initialized from \c options.lzo, which gets its value
- * from the process's configuration sources, such as its configuration
- * file or command line %options.
+ * the compile-time \c USE_COMP preprocessor macro and on \c
+ * options.comp.alg, which gets its value from the process's configuration
+ * sources, such as its configuration file or command line %options.
+ * \c comp_init() creates no \c compress_context if no algorithm is set.
+ * The flags in \c compress_context.flags, copied from \c
+ * options.comp.flags, only adjust framing, option checks and which
+ * algorithms are advertised to the peer.
*
- * @par Adaptive compression
- * The compression module supports adaptive compression. If this feature
- * is enabled, the compression routines monitor their own performance and
- * turn compression on or off depending on whether it is leading to
- * significantly reduced payload size.
+ * @par Outgoing packets
+ * Outgoing packets are never compressed, only framed so that the peer
+ * can parse them.
*
* @par Compression algorithms
- * This module uses the Lempel-Ziv-Oberhumer (LZO) compression algorithms.
- * These offer lossless compression and are designed for high-performance
- * decompression. This module uses the external \c lzo library's
- * implementation of the algorithms.
+ * This module supports the Lempel-Ziv-Oberhumer (LZO) and LZ4
+ * algorithms, as implemented by the external \c lzo and \c lz4
+ * libraries.
*
* @par
- * For more information on the LZO library, see:\n
- * https://www.oberhumer.com/opensource/lzo/
+ * For more information on these libraries, see:\n
+ * https://www.oberhumer.com/opensource/lzo/ \n
+ * https://lz4.org/
*/
diff --git a/src/openvpn/comp-lz4.h b/src/openvpn/comp-lz4.h
index 3d04771..10dbe59 100644
--- a/src/openvpn/comp-lz4.h
+++ b/src/openvpn/comp-lz4.h
@@ -31,10 +31,5 @@
extern const struct compress_alg lz4_alg;
extern const struct compress_alg lz4v2_alg;
-struct lz4_workspace
-{
- int dummy;
-};
-
#endif /* ENABLE_LZ4 */
#endif
diff --git a/src/openvpn/comp.h b/src/openvpn/comp.h
index 3f6411b..4abf870 100644
--- a/src/openvpn/comp.h
+++ b/src/openvpn/comp.h
@@ -132,11 +132,6 @@
*/
#define COMP_EXTRA_BUFFER(len) ((len) / 6 + 128 + 3 + COMP_PREFIX_LEN)
-/*
- * Don't try to compress any packet smaller than this.
- */
-#define COMPRESS_THRESHOLD 100
-
/* Forward declaration of compression context */
struct compress_context;
@@ -167,26 +162,12 @@
#endif
/*
- * Workspace union of all supported compression algorithms
- */
-union compress_workspace_union
-{
-#ifdef ENABLE_LZO
- struct lzo_compress_workspace lzo;
-#endif
-#ifdef ENABLE_LZ4
- struct lz4_workspace lz4;
-#endif
-};
-
-/*
* Context for active compression session
*/
struct compress_context
{
unsigned int flags;
struct compress_alg alg;
- union compress_workspace_union wu;
/* statistics */
counter_type pre_decompress;
diff --git a/src/openvpn/errlevel.h b/src/openvpn/errlevel.h
index 5cea0ad..62ec731 100644
--- a/src/openvpn/errlevel.h
+++ b/src/openvpn/errlevel.h
@@ -123,7 +123,6 @@
#define D_MTU_DEBUG LOGLEV(7, 70, M_DEBUG) /* show MTU debugging info
*/
#define D_MULTI_DEBUG LOGLEV(7, 70, M_DEBUG) /* show medium-freq multi
debugging info */
#define D_MSS LOGLEV(7, 70, M_DEBUG) /* show MSS adjustments */
-#define D_COMP_LOW LOGLEV(7, 70, M_DEBUG) /* show adaptive
compression state changes */
#define D_CONNECTION_LIST LOGLEV(7, 70, M_DEBUG) /* show <connection> list
info */
#define D_SCRIPT LOGLEV(7, 70, M_DEBUG) /* show parms & env vars
passed to scripts */
#define D_SHOW_NET LOGLEV(7, 70, M_DEBUG) /* show routing table and
adapter list */
diff --git a/src/openvpn/lzo.c b/src/openvpn/lzo.c
index 207cea6..f5ae776 100644
--- a/src/openvpn/lzo.c
+++ b/src/openvpn/lzo.c
@@ -35,7 +35,6 @@
#include "comp.h"
#include "error.h"
-#include "otime.h"
#include "memdbg.h"
@@ -50,7 +49,6 @@
{
msg(D_INIT_MEDIUM, "LZO compression initializing");
ASSERT(!(compctx->flags & COMP_F_SWAP));
- compctx->wu.lzo.wmem_size = LZO_WORKSPACE;
int lzo_status = lzo_init();
if (lzo_status != LZO_E_OK)
@@ -58,15 +56,11 @@
msg(M_FATAL, "Cannot initialize LZO compression library (lzo_init()
returns %d)",
lzo_status);
}
- compctx->wu.lzo.wmem = (lzo_voidp)malloc(compctx->wu.lzo.wmem_size);
- check_malloc_return(compctx->wu.lzo.wmem);
}
static void
lzo_compress_uninit(struct compress_context *compctx)
{
- free(compctx->wu.lzo.wmem);
- compctx->wu.lzo.wmem = NULL;
}
static void
@@ -89,7 +83,7 @@
if (c == LZO_COMPRESS_BYTE) /* packet was compressed */
{
ASSERT(buf_safe(&work, zlen));
- int err = LZO_DECOMPRESS(BPTR(buf), BLENZ(buf), BPTR(&work), &zlen,
compctx->wu.lzo.wmem);
+ int err = LZO_DECOMPRESS(BPTR(buf), BLENZ(buf), BPTR(&work), &zlen,
NULL);
if (err != LZO_E_OK)
{
dmsg(D_COMP_ERRORS, "LZO decompression error: %d", err);
diff --git a/src/openvpn/lzo.h b/src/openvpn/lzo.h
index bb9cc81..3a8586c 100644
--- a/src/openvpn/lzo.h
+++ b/src/openvpn/lzo.h
@@ -57,17 +57,6 @@
/**************************************************************************/
/** @name LZO library interface defines */ /** @{ */ /***********************/
-#define LZO_COMPRESS lzo1x_1_15_compress
-/**< LZO library compression function.
- *
- * Use \c lzo1x_1_15_compress because it
- * is described as faster than the
- * standard routine, although it does
- * need a bit more memory. */
-#define LZO_WORKSPACE LZO1X_1_15_MEM_COMPRESS
-/**< The size in bytes of the memory
- * %buffer required by the LZO library
- * compression algorithm. */
#define LZO_DECOMPRESS lzo1x_decompress_safe
/**< LZO library decompression function.
*
@@ -80,52 +69,6 @@
* using the non-safe version. */
/** @} name LZO library interface */ /**************************************/
-
-/**************************************************************************/
-/** @name Adaptive compression defines */ /** @{ */ /************************/
-#define AC_SAMP_SEC 2 /**< Number of seconds in
a sample period. */
-#define AC_MIN_BYTES
\
- 1000 /**< Minimum number of
bytes a sample \
- * period must contain
for it to be \
- * evaluated. */
-#define AC_SAVE_PCT
\
- 5 /**< Minimum size
reduction percentage \
- * below which
compression will be \
- * turned off. */
-#define AC_OFF_SEC
\
- 60 /**< Seconds to wait after
compression has \
- * been turned off
before retesting. */
-/** @} name Adaptive compression defines */
/*******************************/
-
-/**
- * Adaptive compression state.
- */
-struct lzo_adaptive_compress
-{
- bool compress_state;
- time_t next;
- int n_total;
- int n_comp;
-};
-
-
-/**
- * State for the compression and decompression routines.
- *
- * This structure contains compression module state, such as whether
- * compression is enabled and the status of the adaptive compression
- * routines. It also contains an allocated working buffer.
- *
- * One of these compression workspace structures is maintained for each
- * VPN tunnel.
- */
-struct lzo_compress_workspace
-{
- lzo_voidp wmem;
- int wmem_size;
- struct lzo_adaptive_compress ac;
-};
-
/** @} addtogroup compression */
--
To view, visit https://gerrit.openvpn.net/c/openvpn/+/2328?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I189f3a311719b5c4476351702a44870d485d10d8
Gerrit-Change-Number: 2328
Gerrit-PatchSet: 1
Gerrit-Owner: Răzvan Cojocaru <[email protected]>
Gerrit-Reviewer: Arne Schwabe <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: Arne Schwabe <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel