From: James Yonan Date: Thu, 10 Mar 2011 00:04:39 +0000 (+0000) Subject: Added --enable-lzo-stub configure option to build an OpenVPN client without LZO,... X-Git-Tag: v2.3-alpha1~238^2~20 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=6c34e74f1340a72ab7dce077e4d326f03989322c;p=thirdparty%2Fopenvpn.git Added --enable-lzo-stub configure option to build an OpenVPN client without LZO, but that has limited interoperability with LZO-enabled servers. Modified "push-peer-info" option to push IV_LZO_STUB=1 to server when client was built with --enable-lzo-stub configure option. This tells the server that the client lacks LZO capabilities, so the server should turn off LZO compression for this client via "lzo no". Added "setenv PUSH_PEER_INFO" option having the same effect as "push-peer-info". Version 2.1.3j git-svn-id: http://svn.openvpn.net/projects/branches/BETA21@7023 e7ae566f-a301-0410-adde-c780ea21d3b5 --- diff --git a/configure.ac b/configure.ac index 55757053b..729ce40fa 100644 --- a/configure.ac +++ b/configure.ac @@ -69,6 +69,12 @@ AC_ARG_ENABLE(lzo, [LZO="yes"] ) +AC_ARG_ENABLE(lzo-stub, + [ --enable-lzo-stub Don't compile LZO compression support but still allow limited interoperability with LZO-enabled peers], + [LZO_STUB="$enableval"], + [LZO_STUB="no"] +) + AC_ARG_ENABLE(crypto, [ --disable-crypto Disable OpenSSL crypto support], [CRYPTO="$enableval"], @@ -657,7 +663,7 @@ dnl dnl check for LZO library dnl -if test "$LZO" = "yes"; then +if test "$LZO" = "yes" && test "$LZO_STUB" = "no"; then LZO_H="" AC_CHECKING([for LZO Library and Header files]) AC_CHECK_HEADER(lzo/lzo1x.h, @@ -687,10 +693,15 @@ if test "$LZO" = "yes"; then else AC_MSG_RESULT([LZO headers were not found]) AC_MSG_RESULT([LZO library available from http://www.oberhumer.com/opensource/lzo/]) - AC_MSG_ERROR([Or try ./configure --disable-lzo]) + AC_MSG_ERROR([Or try ./configure --disable-lzo OR ./configure --enable-lzo-stub]) fi fi +dnl enable multi-client mode +if test "$LZO_STUB" = "yes"; then + AC_DEFINE(LZO_STUB, 1, [Enable LZO stub capability]) +fi + dnl dnl check for OpenSSL-crypto library dnl diff --git a/lzo.c b/lzo.c index 6ea0d0313..734305122 100644 --- a/lzo.c +++ b/lzo.c @@ -32,6 +32,8 @@ #include "memdbg.h" +#ifndef LZO_STUB + static bool lzo_adaptive_compress_test (struct lzo_adaptive_compress *ac) { @@ -79,6 +81,8 @@ lzo_adaptive_compress_data (struct lzo_adaptive_compress *ac, int n_total, int n ac->n_comp += n_comp; } +#endif /* LZO_STUB */ + void lzo_adjust_frame_parameters (struct frame *frame) { /* Leave room for our one-byte compressed/didn't-compress prefix byte. */ @@ -94,14 +98,18 @@ lzo_compress_init (struct lzo_compress_workspace *lzowork, unsigned int flags) { CLEAR (*lzowork); - lzowork->wmem_size = LZO_WORKSPACE; lzowork->flags = flags; +#ifndef LZO_STUB + lzowork->wmem_size = LZO_WORKSPACE; if (lzo_init () != LZO_E_OK) msg (M_FATAL, "Cannot initialize LZO compression library"); lzowork->wmem = (lzo_voidp) lzo_malloc (lzowork->wmem_size); check_malloc_return (lzowork->wmem); msg (M_INFO, "LZO compression initialized"); +#else + msg (M_INFO, "LZO stub compression initialized"); +#endif lzowork->defined = true; } @@ -111,8 +119,10 @@ lzo_compress_uninit (struct lzo_compress_workspace *lzowork) if (lzowork) { ASSERT (lzowork->defined); +#ifndef LZO_STUB lzo_free (lzowork->wmem); lzowork->wmem = NULL; +#endif lzowork->defined = false; } } @@ -120,6 +130,7 @@ lzo_compress_uninit (struct lzo_compress_workspace *lzowork) static inline bool lzo_compression_enabled (struct lzo_compress_workspace *lzowork) { +#ifndef LZO_STUB if ((lzowork->flags & (LZO_SELECTED|LZO_ON)) == (LZO_SELECTED|LZO_ON)) { if (lzowork->flags & LZO_ADAPTIVE) @@ -127,6 +138,7 @@ lzo_compression_enabled (struct lzo_compress_workspace *lzowork) else return true; } +#endif return false; } @@ -139,15 +151,18 @@ lzo_compress (struct buffer *buf, struct buffer work, struct lzo_compress_workspace *lzowork, const struct frame* frame) { +#ifndef LZO_STUB lzo_uint zlen = 0; int err; bool compressed = false; +#endif ASSERT (lzowork->defined); if (buf->len <= 0) return; +#ifndef LZO_STUB /* * In order to attempt compression, length must be at least COMPRESS_THRESHOLD, * and our adaptive level must give the OK. @@ -193,6 +208,7 @@ lzo_compress (struct buffer *buf, struct buffer work, *buf = work; } else +#endif { uint8_t *header = buf_prepend (buf, 1); *header = NO_COMPRESS; @@ -204,9 +220,11 @@ lzo_decompress (struct buffer *buf, struct buffer work, struct lzo_compress_workspace *lzowork, const struct frame* frame) { +#ifndef LZO_STUB lzo_uint zlen = EXPANDED_SIZE (frame); - uint8_t c; /* flag indicating whether or not our peer compressed */ int err; +#endif + uint8_t c; /* flag indicating whether or not our peer compressed */ ASSERT (lzowork->defined); @@ -220,6 +238,7 @@ lzo_decompress (struct buffer *buf, struct buffer work, if (c == YES_COMPRESS) /* packet was compressed */ { +#ifndef LZO_STUB ASSERT (buf_safe (&work, zlen)); err = LZO_DECOMPRESS (BPTR (buf), BLEN (buf), BPTR (&work), &zlen, lzowork->wmem); @@ -238,6 +257,11 @@ lzo_decompress (struct buffer *buf, struct buffer work, lzowork->post_decompress += work.len; *buf = work; +#else + dmsg (D_COMP_ERRORS, "LZO decompression error: LZO capability not compiled"); + buf->len = 0; + return; +#endif } else if (c == NO_COMPRESS) /* packet was not compressed */ { @@ -264,10 +288,12 @@ void lzo_print_stats (const struct lzo_compress_workspace *lzo_compwork, struct { ASSERT (lzo_compwork->defined); +#ifndef LZO_STUB status_printf (so, "pre-compress bytes," counter_format, lzo_compwork->pre_compress); status_printf (so, "post-compress bytes," counter_format, lzo_compwork->post_compress); status_printf (so, "pre-decompress bytes," counter_format, lzo_compwork->pre_decompress); status_printf (so, "post-decompress bytes," counter_format, lzo_compwork->post_decompress); +#endif } #else diff --git a/lzo.h b/lzo.h index bb15753a2..831f20429 100644 --- a/lzo.h +++ b/lzo.h @@ -27,6 +27,7 @@ #ifdef USE_LZO +#ifndef LZO_STUB #ifdef LZO_HEADER_DIR #include "lzo/lzoutil.h" #include "lzo/lzo1x.h" @@ -34,6 +35,7 @@ #include "lzoutil.h" #include "lzo1x.h" #endif +#endif #include "buffer.h" #include "mtu.h" @@ -45,6 +47,18 @@ #define LZO_ON (1<<1) #define LZO_ADAPTIVE (1<<2) +/* + * Length of prepended prefix on LZO packets + */ +#define LZO_PREFIX_LEN 1 + +/* + * LZO 2.0 worst case size expansion + */ +#define LZO_EXTRA_BUFFER(len) ((len)/8 + 128 + 3) + +#ifndef LZO_STUB + /* * Use LZO compress routine lzo1x_1_15_compress which is described * as faster but needs a bit more memory than the standard routine. @@ -58,18 +72,11 @@ #define LZO_WORKSPACE LZO1X_1_15_MEM_COMPRESS #define LZO_DECOMPRESS lzo1x_decompress_safe -#define LZO_EXTRA_BUFFER(len) ((len)/8 + 128 + 3) /* LZO 2.0 worst case size expansion. */ - /* * Don't try to compress any packet smaller than this. */ #define COMPRESS_THRESHOLD 100 -/* - * Length of prepended prefix on LZO packets - */ -#define LZO_PREFIX_LEN 1 - /* * Adaptive compress parameters */ @@ -88,23 +95,27 @@ struct lzo_adaptive_compress { int n_comp; }; +#endif /* LZO_STUB */ + /* * Compress and Uncompress routines. */ struct lzo_compress_workspace { + bool defined; + unsigned int flags; +#ifndef LZO_STUB lzo_voidp wmem; int wmem_size; struct lzo_adaptive_compress ac; - unsigned int flags; - bool defined; /* statistics */ counter_type pre_decompress; counter_type post_decompress; counter_type pre_compress; counter_type post_compress; +#endif }; void lzo_adjust_frame_parameters(struct frame *frame); diff --git a/options.c b/options.c index dfba94175..e8e0d7a7a 100644 --- a/options.c +++ b/options.c @@ -4754,6 +4754,12 @@ add_option (struct options *options, msg (msglevel, "this is a generic configuration and cannot directly be used"); goto err; } +#ifdef ENABLE_PUSH_PEER_INFO + else if (streq (p[1], "PUSH_PEER_INFO")) + { + options->push_peer_info = true; + } +#endif #if P2MP else if (streq (p[1], "SERVER_POLL_TIMEOUT") && p[2]) { diff --git a/ssl.c b/ssl.c index 16e4c0960..dbc65eb16 100644 --- a/ssl.c +++ b/ssl.c @@ -3809,6 +3809,11 @@ push_peer_info(struct buffer *buf, struct tls_session *session) buf_printf (&out, "IV_HWADDR=%s\n", format_hex_ex (macaddr, 6, 0, 1, ":", &gc)); } + /* push LZO status */ +#ifdef LZO_STUB + buf_printf (&out, "IV_LZO_STUB=1\n"); +#endif + /* push env vars that begin with UV_ */ for (e=es->list; e != NULL; e=e->next) { diff --git a/syshead.h b/syshead.h index 1c894c91c..0da1fc263 100644 --- a/syshead.h +++ b/syshead.h @@ -697,4 +697,16 @@ socket_defined (const socket_descriptor_t sd) */ #define ENABLE_CLIENT_NAT +/* + * Support LZO as a stub in client? (LZO lib not included, but we + * we still support LZO protocol changes that allow us to + * communicate with an LZO-enabled server) + */ +#ifdef LZO_STUB +#undef USE_LZO +#undef LZO_VERSION_NUM +#define USE_LZO 1 +#define LZO_VERSION_NUM "STUB" +#endif + #endif diff --git a/version.m4 b/version.m4 index f89b00729..e173442b8 100644 --- a/version.m4 +++ b/version.m4 @@ -1,5 +1,5 @@ dnl define the OpenVPN version -define(PRODUCT_VERSION,[2.1.3i]) +define(PRODUCT_VERSION,[2.1.3j]) dnl define the TAP version define(PRODUCT_TAP_ID,[tap0901]) define(PRODUCT_TAP_WIN32_MIN_MAJOR,[9])