Skip to contentSkip to conversation

forward-port of all outstanding 2.1 SVN patches

Openvpn-devel In review Gert Doering 3 participants 18 messages Apr 19, 2013 – Jun 7, 2013

lore
Share & tools
lore
#0 lore raw

Hi folks,

here's a patch series that brings all not-yet-ported changes from James' SVN 2.1 tree to the current git master tree (plus one of mine, 5/5 is a bugfix for 2/5 - I decided to have it as extra patch so it's clear that this is deviating from "just take what is in SVN").

This is necessary groundwork to run OpenVPN AS with the 2.3 core, and thus bring development work of "community openvpn" and "AS" a bit more closely together again.

Patches have been tested on Linux, FreeBSD and MacOS 10.5, for standalone OpenVPN (client and p2pm server) and inside AS, and I'm fairly confident that the stuff works and nothing crashes :-)

(Don't ask me what 1/5 is for. It came from SVN, it was straightforward to port and test, and "something in the AS context" wants it)

gert

#1 lore raw

PATCH 1/5 Added remote-override option.

From: James Yonan <[email protected]...>

OpenVPN SVN r8126 (2.1.20)

---
 src/openvpn/options.c | 7 ++++++-
 src/openvpn/options.h | 2 ++
 2 files changed, 8 insertions(+), 1 deletion(-)
src/openvpn/options.c +6 -1
index ec39212..88ed88a 100644
@@ -4410,6 +4410,11 @@ add_option (struct options *options,
       options->force_connection_list = true;
     }
 #endif
+  else if (streq (p[0], "remote-override") && p[1])
+    {
+      VERIFY_PERMISSION (OPT_P_GENERAL);
+      options->remote_override = p[1];
+    }
   else if (streq (p[0], "remote") && p[1])
     {
       struct remote_entry re;
@@ -4417,7 +4422,7 @@ add_option (struct options *options,
       re.remote_port = re.proto = -1;
 
       VERIFY_PERMISSION (OPT_P_GENERAL|OPT_P_CONNECTION);
-      re.remote = p[1];
+      re.remote = options->remote_override ? options->remote_override : p[1];
       if (p[2])
 	{
 	  const int port = atoi (p[2]);
src/openvpn/options.h +2 -0
index d2ad94c..db1d3f7 100644
@@ -215,6 +215,8 @@ struct options
 
   struct remote_host_store *rh_store;
 
+  const char *remote_override;
+
   bool remote_random;
   const char *ipchange;
   const char *dev;
Signature · 1 line
1.8.1.5
#2 lore raw

Re: [Openvpn-devel] [PATCH 1/5] Added remote-override option.

Am 19.04.13 19:41, schrieb Gert Doering:

Quoted 4 lines

From: James Yonan <[email protected]...>

OpenVPN SVN r8126 (2.1.20)

I am not sure I like these remote-override but the patch is small enough to include it if OpenVPN AS really needs it.

#3 lore raw

Re: [Openvpn-devel] [PATCH 1/5] Added remote-override option.

Quoted 7 lines · Arne Schwabe

Am 19.04.13 19:41, schrieb Gert Doering:

Quoted 4 lines

From: James Yonan <[email protected]...>

OpenVPN SVN r8126 (2.1.20)

I am not sure I like these remote-override but the patch is small enough to include it if OpenVPN AS really needs it.

I completely agree with Arne. I find this feature vague in it's purpose and I'm pretty sure it will be misunderstood by users sooner or later. I do see that the GUI can benefit from such a feature. But I strongly believe this is something the GUI should have sorted out *before* even starting OpenVPN and then push the correct --remote directly to OpenVPN.

What I feel is difficult about this current approach is that only hostname is overridden. So you need identical servers configured for this to function. If one server uses tcp and another one udp, or there are MTU differences or using different ports ... this override function will not work at all. If it would just override a specific pre-configured connection profile,and maybe even with a possibility to override multiple or selected connection profiles, then I think this would make more sense.

But if OpenVPN AS really needs it and fixing AS will be too much of a pain, lets pull it in. I'm not happy about it, but lets fix this later on. Let's ensure this commit points at this mail discussion too. It's more important currently to get OpenVPN AS code base merged with the community code base currently.

Signature · 3 lines
kind regards,

David Sommerseth
#4 lore raw

PATCH 2/5 Added support for the Snappy compression algorithm

In reply to Gert Doering

From: James Yonan <[email protected]...>

Added support for the Snappy compression algorithm which has shown to have considerably better compression speed than LZO at a comparable compression ratio.

To enable Snappy add:

compress snappy

to both client and server config files.

Alternatively, enable compression framing on the client:

compress

and have the server selectively push "compress snappy" to the client.

This change also extends the client capability handshake to include IV_SNAPPY so the server can be aware that a connecting client supports Snappy.

Note that the Snappy implementation also includes an improved framing approach where the first byte of the compressed payload is replaced by the compression control byte (the first payload byte is moved to the end of the packet). This solves off-by-one alignment issues, which improves performance on ARM.

By default, the configure script will try to build with Snappy support. To disable, use the --disable-snappy option.

The --enable-lzo-stub configure directive is now --enable-comp-stub (because it's not actually "lzo" but "compression-enabled packet framing")

Add compression overhead to extra buffer unconditionally, as long as USE_COMP is defined.

OpenVPN SVN r8206 (2.1.21a) and r8212 (2.1.21b)

---
 configure.ac             |  65 ++++++++++++--
 doc/openvpn.8            |  22 ++++-
 src/openvpn/Makefile.am  |   4 +
 src/openvpn/comp.c       | 135 ++++++++++++++++++++++++++++
 src/openvpn/comp.h       | 171 ++++++++++++++++++++++++++++++++++++
 src/openvpn/compstub.c   | 118 +++++++++++++++++++++++++
 src/openvpn/forward.c    |  12 +--
 src/openvpn/init.c       | 100 +++++++++++++++------
 src/openvpn/lzo.c        | 154 +++++++++++---------------------
 src/openvpn/lzo.h        | 222 +----------------------------------------------
 src/openvpn/openvpn.h    |  16 ++--
 src/openvpn/options.c    | 100 +++++++++++++++++----
 src/openvpn/options.h    |   7 +-
 src/openvpn/sig.c        |   6 +-
 src/openvpn/snappy.c     | 189 ++++++++++++++++++++++++++++++++++++++++
 src/openvpn/snappy.h     |  39 +++++++++
 src/openvpn/ssl.c        |   6 +-
 src/openvpn/ssl_common.h |   5 ++
 src/openvpn/syshead.h    |   7 ++
 19 files changed, 975 insertions(+), 403 deletions(-)
 create mode 100644 src/openvpn/comp.c
 create mode 100644 src/openvpn/comp.h
 create mode 100644 src/openvpn/compstub.c
 create mode 100644 src/openvpn/snappy.c
 create mode 100644 src/openvpn/snappy.h
configure.ac +56 -9
index 7b35e50..5da5772 100644
@@ -46,11 +46,16 @@ AC_ARG_ENABLE(
 	[enable_lzo="yes"]
 )
 
-AC_ARG_ENABLE(
-	[lzo-stub],
-	[AS_HELP_STRING([--enable-lzo-stub], [don't compile LZO compression support but still allow limited interoperability with LZO-enabled peers @<:@default=no@:>@])],
-	,
-	[enable_lzo_stub="no"]
+AC_ARG_ENABLE(snappy,
+	[  --disable-snappy        Disable Snappy compression support],
+	[enable_snappy="$enableval"],
+	[enable_snappy="yes"]
+)
+
+AC_ARG_ENABLE(comp-stub,
+	[  --enable-comp-stub      Don't compile compression support but still allow limited interoperability with compression-enabled peers],
+	[enable_comp_stub="$enableval"],
+	[enable_comp_stub="no"]
 )
 
 AC_ARG_ENABLE(
@@ -895,6 +900,46 @@ if test "${have_lzo}" = "yes"; then
 	CFLAGS="${saved_CFLAGS}"
 fi
 
+dnl
+dnl check for Snappy library
+dnl
+
+AC_ARG_VAR([SNAPPY_CFLAGS], [C compiler flags for snappy])
+AC_ARG_VAR([SNAPPY_LIBS], [linker flags for snappy])
+if test "$enable_snappy" = "yes" && test "$enable_comp_stub" = "no"; then
+    AC_CHECKING([for Snappy Library and Header files])
+    havesnappylib=1
+
+    # if SNAPPY_LIBS is set, we assume it will work, otherwise test
+    if test -z "${SNAPPY_LIBS}"; then
+	AC_CHECK_LIB(snappy, snappy_compress,
+	    [ SNAPPY_LIBS="-lsnappy" ],
+	    [
+	        AC_MSG_RESULT([Snappy library not found.])
+	        havesnappylib=0
+	    ])
+    fi
+
+    saved_CFLAGS="${CFLAGS}"
+    CFLAGS="${CFLAGS} ${SNAPPY_CFLAGS}"
+    AC_CHECK_HEADER(snappy-c.h,
+       ,
+       [
+	   AC_MSG_RESULT([Snappy headers not found.])
+	   havesnappylib=0
+       ])
+
+    if test $havesnappylib = 0 ; then
+	AC_MSG_RESULT([Snappy library available from http://code.google.com/p/snappy/])
+        AC_MSG_ERROR([Or try ./configure --disable-snappy OR ./configure --enable-comp-stub])
+    fi
+    OPTIONAL_SNAPPY_CFLAGS="${SNAPPY_CFLAGS}"
+    OPTIONAL_SNAPPY_LIBS="${SNAPPY_LIBS}"
+    AC_DEFINE(ENABLE_SNAPPY, 1, [Enable Snappy compression library])
+    CFLAGS="${saved_CFLAGS}"
+fi
+
+
 AC_MSG_CHECKING([git checkout])
 GIT_CHECKOUT="no"
 if test -n "${GIT}" -a -d "${srcdir}/.git"; then
@@ -1003,10 +1048,10 @@ if test "${enable_lzo}" = "yes"; then
 	OPTIONAL_LZO_LIBS="${LZO_LIBS}"
 	AC_DEFINE([ENABLE_LZO], [1], [Enable LZO compression library])
 fi
-if test "${enable_lzo_stub}" = "yes"; then
-	test "${enable_lzo}" = "yes" && AC_MSG_ERROR([Cannot have both lzo stub and lzo enabled])
-	AC_DEFINE([ENABLE_LZO_STUB], [1], [Enable LZO stub capability])
-	AC_DEFINE([ENABLE_LZO], [1], [Enable LZO compression library])
+if test "${enable_comp_stub}" = "yes"; then
+	test "${enable_lzo}" = "yes" && AC_MSG_ERROR([Cannot have both comp stub and lzo enabled (use --disable-lzo)])
+	test "${enable_snappy}" = "yes" && AC_MSG_ERROR([Cannot have both comp stub and snappy enabled (use --disable-snappy)])
+	AC_DEFINE([ENABLE_COMP_STUB], [1], [Enable compression stub capability])
 fi
 
 if test "${enable_pkcs11}" = "yes"; then
@@ -1060,6 +1105,8 @@ AC_SUBST([OPTIONAL_CRYPTO_CFLAGS])
 AC_SUBST([OPTIONAL_CRYPTO_LIBS])
 AC_SUBST([OPTIONAL_LZO_CFLAGS])
 AC_SUBST([OPTIONAL_LZO_LIBS])
+AC_SUBST([OPTIONAL_SNAPPY_CFLAGS])
+AC_SUBST([OPTIONAL_SNAPPY_LIBS])
 AC_SUBST([OPTIONAL_PKCS11_HELPER_CFLAGS])
 AC_SUBST([OPTIONAL_PKCS11_HELPER_LIBS])
 
doc/openvpn.8 +21 -1
index d590714..cab1ed7 100644
@@ -2352,12 +2352,32 @@ consecutive messages in the same category.  This is useful to
 limit repetitive logging of similar message types.
 .\"*********************************************************
 .TP
+.B \-\-compress [algorithm]
+Enable a compression algorithm.
+
+The
+.B algorithm
+parameter may be "snappy", "lzo", or empty.  Snappy and LZO
+are different compression algorithms, with Snappy generally
+offering the best performance.
+
+If the
+.B algorithm
+parameter is empty, compression will be turned off, but the packet
+framing for compression will still be enabled, allowing a different
+setting to be pushed later.
+.\"*********************************************************
+.TP
 .B \-\-comp-lzo [mode]
-Use fast LZO compression \-\- may add up to 1 byte per
+Use LZO compression \-\- may add up to 1 byte per
 packet for incompressible data.
 .B mode
 may be "yes", "no", or "adaptive" (default).
 
+This option is deprecated in favor of the newer
+.B --compress
+option.
+
 In a server mode setup, it is possible to selectively turn
 compression on or off for individual clients.
 
src/openvpn/Makefile.am +4 -0
index 5d38628..70e19c2 100644
@@ -26,6 +26,7 @@ AM_CFLAGS = \
 	$(TAP_CFLAGS) \
 	$(OPTIONAL_CRYPTO_CFLAGS) \
 	$(OPTIONAL_LZO_CFLAGS) \
+	$(OPTIONAL_SNAPPY_CFLAGS) \
 	$(OPTIONAL_PKCS11_HELPER_CFLAGS)
 if WIN32
 # we want unicode entry point but not the macro
@@ -41,6 +42,7 @@ openvpn_SOURCES = \
 	circ_list.h \
 	clinat.c clinat.h \
 	common.h \
+	comp.c comp.h compstub.c \
 	crypto.c crypto.h crypto_backend.h \
 	crypto_openssl.c crypto_openssl.h \
 	crypto_polarssl.c crypto_polarssl.h \
@@ -98,6 +100,7 @@ openvpn_SOURCES = \
 	session_id.c session_id.h \
 	shaper.c shaper.h \
 	sig.c sig.h \
+	snappy.c snappy.h \
 	socket.c socket.h \
 	socks.c socks.h \
 	ssl.c ssl.h  ssl_backend.h \
@@ -116,6 +119,7 @@ openvpn_LDADD = \
 	$(top_builddir)/src/compat/libcompat.la \
 	$(SOCKETS_LIBS) \
 	$(OPTIONAL_LZO_LIBS) \
+	$(OPTIONAL_SNAPPY_LIBS) \
 	$(OPTIONAL_PKCS11_HELPER_LIBS) \
 	$(OPTIONAL_CRYPTO_LIBS) \
 	$(OPTIONAL_SELINUX_LIBS) \
src/openvpn/comp.c new file +135 -0

135 lines not on this page · raw message

src/openvpn/comp.h new file +171 -0

171 lines not on this page · raw message

src/openvpn/compstub.c new file +118 -0

118 lines not on this page · raw message

src/openvpn/forward.c +6 -6
index 024cd58..447b86d 100644
@@ -444,10 +444,10 @@ encrypt_sign (struct context *c, bool comp_frag)
 
   if (comp_frag)
     {
-#ifdef ENABLE_LZO
+#ifdef USE_COMP
       /* Compress the packet. */
-      if (lzo_defined (&c->c2.lzo_compwork))
-	lzo_compress (&c->c2.buf, b->lzo_compress_buf, &c->c2.lzo_compwork, &c->c2.frame);
+      if (c->c2.comp_context)
+	(*c->c2.comp_context->alg.compress)(&c->c2.buf, b->compress_buf, c->c2.comp_context, &c->c2.frame);
 #endif
 #ifdef ENABLE_FRAGMENT
       if (c->c2.fragment)
@@ -846,10 +846,10 @@ process_incoming_link (struct context *c)
 	fragment_incoming (c->c2.fragment, &c->c2.buf, &c->c2.frame_fragment);
 #endif
 
-#ifdef ENABLE_LZO
+#ifdef USE_COMP
       /* decompress the incoming packet */
-      if (lzo_defined (&c->c2.lzo_compwork))
-	lzo_decompress (&c->c2.buf, c->c2.buffers->lzo_decompress_buf, &c->c2.lzo_compwork, &c->c2.frame);
+      if (c->c2.comp_context)
+	(*c->c2.comp_context->alg.decompress)(&c->c2.buf, c->c2.buffers->decompress_buf, c->c2.comp_context, &c->c2.frame);
 #endif
 
 #ifdef PACKET_TRUNCATION_CHECK
src/openvpn/init.c +72 -28

177 lines not on this page · raw message

src/openvpn/lzo.c +51 -103

264 lines not on this page · raw message

src/openvpn/lzo.h +3 -219

286 lines not on this page · raw message

src/openvpn/openvpn.h +8 -8
index bdfa685..606a4f5 100644
@@ -31,7 +31,7 @@
 #include "crypto.h"
 #include "ssl.h"
 #include "packet_id.h"
-#include "lzo.h"
+#include "comp.h"
 #include "tun.h"
 #include "interval.h"
 #include "status.h"
@@ -104,10 +104,10 @@ struct context_buffers
   struct buffer decrypt_buf;
 #endif
 
-  /* workspace buffers for LZO compression */
-#ifdef ENABLE_LZO
-  struct buffer lzo_compress_buf;
-  struct buffer lzo_decompress_buf;
+  /* workspace buffers for compression */
+#ifdef USE_COMP
+  struct buffer compress_buf;
+  struct buffer decompress_buf;
 #endif
 
   /*
@@ -372,9 +372,9 @@ struct context_2
 
 #endif /* ENABLE_CRYPTO */
 
-#ifdef ENABLE_LZO
-  struct lzo_compress_workspace lzo_compwork;
-                                /**< Compression workspace used by the
+#ifdef USE_COMP
+  struct compress_context *comp_context;
+                                /**< Compression context used by the
                                  *   \link compression Data Channel
                                  *   Compression module\endlink. */
 #endif
src/openvpn/options.c +81 -19

161 lines not on this page · raw message

src/openvpn/options.h +3 -4
index db1d3f7..9d7aaf2 100644
@@ -39,7 +39,7 @@
 #include "plugin.h"
 #include "manage.h"
 #include "proxy.h"
-#include "lzo.h"
+#include "comp.h"
 #include "pushlist.h"
 #include "clinat.h"
 
@@ -314,9 +314,8 @@ struct options
   /* optimize TUN/TAP/UDP writes */
   bool fast_io;
 
-#ifdef ENABLE_LZO
-  /* LZO_x flags from lzo.h */
-  unsigned int lzo;
+#ifdef USE_COMP
+  struct compress_options comp;
 #endif
 
   /* buffer sizes */
src/openvpn/sig.c +3 -3
index 0ebde24..5dee92b 100644
@@ -265,9 +265,9 @@ print_status (const struct context *c, struct status_output *so)
   status_printf (so, "TCP/UDP read bytes," counter_format, c->c2.link_read_bytes);
   status_printf (so, "TCP/UDP write bytes," counter_format, c->c2.link_write_bytes);
   status_printf (so, "Auth read bytes," counter_format, c->c2.link_read_bytes_auth);
-#ifdef ENABLE_LZO
-  if (lzo_defined (&c->c2.lzo_compwork))
-    lzo_print_stats (&c->c2.lzo_compwork, so);
+#ifdef USE_COMP
+  if (c->c2.comp_context)
+    comp_print_stats (c->c2.comp_context, so);
 #endif
 #ifdef PACKET_TRUNCATION_CHECK
   status_printf (so, "TUN read truncations," counter_format, c->c2.n_trunc_tun_read);
src/openvpn/snappy.c new file +189 -0

189 lines not on this page · raw message

src/openvpn/snappy.h new file +39 -0
new file mode 100644
index 0000000..361a631
@@ -0,0 +1,39 @@
+/*
+ *  OpenVPN -- An application to securely tunnel IP networks
+ *             over a single UDP port, with support for SSL/TLS-based
+ *             session authentication and key exchange,
+ *             packet encryption, packet authentication, and
+ *             packet compression.
+ *
+ *  Copyright (C) 2002-2012 OpenVPN Technologies, Inc. <[email protected]...>
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License version 2
+ *  as published by the Free Software Foundation.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program (see the file COPYING included with this
+ *  distribution); if not, write to the Free Software Foundation, Inc.,
+ *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef OPENVPN_SNAPPY_H
+#define OPENVPN_SNAPPY_H
+
+#if defined(ENABLE_SNAPPY)
+
+#include "buffer.h"
+
+extern const struct compress_alg snappy_alg;
+
+struct snappy_workspace
+{
+};
+
+#endif /* ENABLE_SNAPPY */
+#endif
src/openvpn/ssl.c +3 -3
index 43b3980..cf36191 100644
@@ -1809,9 +1809,9 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
 	  buf_printf (&out, "IV_HWADDR=%s\n", format_hex_ex (rgi.hwaddr, 6, 0, 1, ":", &gc));
       }
 
-      /* push LZO status */
-#ifdef ENABLE_LZO_STUB
-      buf_printf (&out, "IV_LZO_STUB=1\n");
+      /* push compression status */
+#ifdef USE_COMP
+      comp_generate_peer_info_string(&session->opt->comp_options, &out);
 #endif
 
       /* push env vars that begin with UV_ */
src/openvpn/ssl_common.h +5 -0
index c62294f..47dbefb 100644
@@ -285,6 +285,11 @@ struct tls_options
   struct env_set *es;
   const struct plugin_list *plugins;
 
+  /* compression parms */
+#ifdef USE_COMP
+  struct compress_options comp_options;
+#endif
+
   /* configuration file boolean options */
 # define SSLF_CLIENT_CERT_NOT_REQUIRED (1<<0)
 # define SSLF_USERNAME_AS_COMMON_NAME  (1<<1)
src/openvpn/syshead.h +7 -0
index 4db29cc..629ee80 100644
@@ -720,6 +720,13 @@ socket_defined (const socket_descriptor_t sd)
 #define ENABLE_CLIENT_NAT
 
 /*
+ * Compression support
+ */
+#if defined(ENABLE_SNAPPY) || defined(ENABLE_LZO) || defined(ENABLE_COMP_STUB)
+#define USE_COMP
+#endif
+
+/*
  * Enable --memstats option
  */
 #ifdef TARGET_LINUX
Signature · 1 line
1.8.1.5
#5 lore raw

Re: [Openvpn-devel] [PATCH 2/5] Added support for the Snappy compression algorithm

Am 19.04.13 19:41, schrieb Gert Doering:

Quoted 28 lines

From: James Yonan <[email protected]...>

Added support for the Snappy compression algorithm which has shown to have considerably better compression speed than LZO at a comparable compression ratio.

To enable Snappy add:

compress snappy

to both client and server config files.

Alternatively, enable compression framing on the client:

compress

and have the server selectively push "compress snappy" to the client.

This change also extends the client capability handshake to include IV_SNAPPY so the server can be aware that a connecting client supports Snappy.

Note that the Snappy implementation also includes an improved framing approach where the first byte of the compressed payload is replaced by the compression control byte (the first payload byte is moved to the end of the packet). This solves off-by-one alignment issues, which improves performance on ARM.

Quoted 8 lines

By default, the configure script will try to build with Snappy support. To disable, use the --disable-snappy option.

The --enable-lzo-stub configure directive is now --enable-comp-stub (because it's not actually "lzo" but "compression-enabled packet framing")

Add compression overhead to extra buffer unconditionally, as long as USE_COMP is defined.

I looked through the patch. I looks reasonable good. I wonder what the overhead for always enabling USE_COMP is. That way every client would be able to understand at least the compression framing.

Arne

#6 lore raw

[Openvpn-devel] [PATCH applied] Re: Added support for the Snappy compression algorithm

In reply to Gert Doering

Patch has been applied to the master branch.

commit 38d96bd7975e626d490b3d9f9514d81e070a5495

Author: James Yonan
Date:   Tue Sep 18 08:33:34 2012 +0200
     Added support for the Snappy compression algorithm

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/7531

--
kind regards,

Gert Doering

#7 lore raw

PATCH 3/5 Minor fix to process_ipv4_header so that any combination of options can be defined.

In reply to Gert Doering

From: James Yonan <[email protected]...>

OpenVPN SVN r8219, slightly adapted for conflicts brought in by commit f0e8997a874a89b3 (IPv6 MSSFIX implementation).

---
 src/openvpn/forward.c | 6 +-----
 src/openvpn/forward.h | 4 +++-
 2 files changed, 4 insertions(+), 6 deletions(-)
src/openvpn/forward.c +1 -5
index 447b86d..8f1f1e5 100644
@@ -1026,11 +1026,7 @@ process_ip_header (struct context *c, unsigned int flags, struct buffer *buf)
        * The --passtos and --mssfix options require
        * us to examine the IPv4 header.
        */
-#if PASSTOS_CAPABILITY
-      if (flags & (PIPV4_PASSTOS|PIP_MSSFIX))
-#else
-      if (flags & PIP_MSSFIX)
-#endif
+      if (flags & PIP_OPT_MASK)
 	{
 	  struct buffer ipbuf = *buf;
 	  if (is_ipv4 (TUNNEL_TYPE (c->c1.tuntap), &ipbuf))
src/openvpn/forward.h +3 -1
index 1830a00..0ece01e 100644
@@ -229,9 +229,11 @@ bool send_control_channel_string (struct context *c, const char *str, int msglev
 
 #define PIPV4_PASSTOS         (1<<0)
 #define PIP_MSSFIX            (1<<1)         /* v4 and v6 */
-#define PIPV4_OUTGOING        (1<<2)
 #define PIPV4_EXTRACT_DHCP_ROUTER (1<<3)
 #define PIPV4_CLIENT_NAT      (1<<4)
+#define PIP_OPT_MASK          0xFFFF         /* all possible options for */
+                                             /* process_ip_header() */
+#define PIPV4_OUTGOING        (1<<16)
 
 void process_ip_header (struct context *c, unsigned int flags, struct buffer *buf);
 
Signature · 1 line
1.8.1.5
#8 lore raw

Re: [Openvpn-devel] [PATCH 3/5] Minor fix to process_ipv4_header so that any combination of options can be defined.

Am 19.04.13 19:41, schrieb Gert Doering:

Quoted 4 lines

From: James Yonan <[email protected]...>

OpenVPN SVN r8219, slightly adapted for conflicts brought in by commit f0e8997a874a89b3 (IPv6 MSSFIX implementation).

I don't think this patch is a good idea. If PASSTOS_CAPABILITY is not defined the if will always be true since PIPV4_PASSTOS is always included in flags. See my patch from today too.

Quoted 40 lines
---
  src/openvpn/forward.c | 6 +-----
  src/openvpn/forward.h | 4 +++-
  2 files changed, 4 insertions(+), 6 deletions(-)
src/openvpn/forward.c +1 -5
index 447b86d..8f1f1e5 100644
@@ -1026,11 +1026,7 @@ process_ip_header (struct context *c, unsigned int flags, struct buffer *buf)
         * The --passtos and --mssfix options require
         * us to examine the IPv4 header.
         */
-#if PASSTOS_CAPABILITY
-      if (flags & (PIPV4_PASSTOS|PIP_MSSFIX))
-#else
-      if (flags & PIP_MSSFIX)
-#endif
+      if (flags & PIP_OPT_MASK)
  	{
  	  struct buffer ipbuf = *buf;
  	  if (is_ipv4 (TUNNEL_TYPE (c->c1.tuntap), &ipbuf))
src/openvpn/forward.h +3 -1
index 1830a00..0ece01e 100644
@@ -229,9 +229,11 @@ bool send_control_channel_string (struct context *c, const char *str, int msglev
 
  #define PIPV4_PASSTOS         (1<<0)
  #define PIP_MSSFIX            (1<<1)         /* v4 and v6 */
-#define PIPV4_OUTGOING        (1<<2)
  #define PIPV4_EXTRACT_DHCP_ROUTER (1<<3)
  #define PIPV4_CLIENT_NAT      (1<<4)
+#define PIP_OPT_MASK          0xFFFF         /* all possible options for */
+                                             /* process_ip_header() */
+#define PIPV4_OUTGOING        (1<<16)
 
  void process_ip_header (struct context *c, unsigned int flags, struct buffer *buf);
 
#9 lore raw

PATCH 4/5 Always push basic set of peer info values to server.

In reply to Gert Doering

From: James Yonan <[email protected]...>

On the client, allow certain peer info fields to be pushed even if push-peer-info isn't specified in the config.

This is needed to allow the compression handshake to work correctly (i.e. where the client indicates its support for LZO and/or Snappy).

Fields that have privacy implications such as Mac Address and UV_* environment variables will not be pushed to the server as before unless push-peer-info is specified by client config.

OpenVPN SVN r8225 (2.1.21c)

---
 src/openvpn/ssl.c | 82 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 42 insertions(+), 40 deletions(-)
src/openvpn/ssl.c +42 -40
index cf36191..4843065 100644
@@ -1775,64 +1775,66 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
   bool ret = false;
 
 #ifdef ENABLE_PUSH_PEER_INFO
-  if (session->opt->push_peer_info) /* write peer info */
-    {
-      struct env_set *es = session->opt->es;
-      struct env_item *e;
-      struct buffer out = alloc_buf_gc (512*3, &gc);
+  {
+    struct env_set *es = session->opt->es;
+    struct env_item *e;
+    struct buffer out = alloc_buf_gc (512*3, &gc);
 
-      /* push version */
-      buf_printf (&out, "IV_VER=%s\n", PACKAGE_VERSION);
+    /* push version */
+    buf_printf (&out, "IV_VER=%s\n", PACKAGE_VERSION);
 
-      /* push platform */
+    /* push platform */
 #if defined(TARGET_LINUX)
-      buf_printf (&out, "IV_PLAT=linux\n");
+    buf_printf (&out, "IV_PLAT=linux\n");
 #elif defined(TARGET_SOLARIS)
-      buf_printf (&out, "IV_PLAT=solaris\n");
+    buf_printf (&out, "IV_PLAT=solaris\n");
 #elif defined(TARGET_OPENBSD)
-      buf_printf (&out, "IV_PLAT=openbsd\n");
+    buf_printf (&out, "IV_PLAT=openbsd\n");
 #elif defined(TARGET_DARWIN)
-      buf_printf (&out, "IV_PLAT=mac\n");
+    buf_printf (&out, "IV_PLAT=mac\n");
 #elif defined(TARGET_NETBSD)
-      buf_printf (&out, "IV_PLAT=netbsd\n");
+    buf_printf (&out, "IV_PLAT=netbsd\n");
 #elif defined(TARGET_FREEBSD)
-      buf_printf (&out, "IV_PLAT=freebsd\n");
+    buf_printf (&out, "IV_PLAT=freebsd\n");
 #elif defined(WIN32)
-      buf_printf (&out, "IV_PLAT=win\n");
+    buf_printf (&out, "IV_PLAT=win\n");
 #endif
 
-      /* push mac addr */
-      {
-	struct route_gateway_info rgi;
-	get_default_gateway (&rgi);
-	if (rgi.flags & RGI_HWADDR_DEFINED)
-	  buf_printf (&out, "IV_HWADDR=%s\n", format_hex_ex (rgi.hwaddr, 6, 0, 1, ":", &gc));
-      }
-
-      /* push compression status */
+    /* push compression status */
 #ifdef USE_COMP
-      comp_generate_peer_info_string(&session->opt->comp_options, &out);
+    comp_generate_peer_info_string(&session->opt->comp_options, &out);
 #endif
 
-      /* push env vars that begin with UV_ */
-      for (e=es->list; e != NULL; e=e->next)
+    if (session->opt->push_peer_info)
+      {
+	/* push mac addr */
 	{
-	  if (e->string)
-	    {
-	      if (!strncmp(e->string, "UV_", 3) && buf_safe(&out, strlen(e->string)+1))
-		buf_printf (&out, "%s\n", e->string);
-	    }
+	  struct route_gateway_info rgi;
+	  get_default_gateway (&rgi);
+	  if (rgi.flags & RGI_HWADDR_DEFINED)
+	    buf_printf (&out, "IV_HWADDR=%s\n", format_hex_ex (rgi.hwaddr, 6, 0, 1, ":", &gc));
 	}
 
-      if (!write_string(buf, BSTR(&out), -1))
-	goto error;
-    }
-  else
+	/* push env vars that begin with UV_ */
+	for (e=es->list; e != NULL; e=e->next)
+	  {
+	    if (e->string)
+	      {
+		if (!strncmp(e->string, "UV_", 3) && buf_safe(&out, strlen(e->string)+1))
+		  buf_printf (&out, "%s\n", e->string);
+	      }
+	  }
+      }
+
+    if (!write_string(buf, BSTR(&out), -1))
+      goto error;
+  }
+#else
+  {
+    if (!write_empty_string (buf)) /* no peer info */
+      goto error;
+  }
 #endif
-    {
-      if (!write_empty_string (buf)) /* no peer info */
-	goto error;
-    }
   ret = true;
 
  error:
Signature · 1 line
1.8.1.5
#10 lore raw

Re: [Openvpn-devel] [PATCH 4/5] Always push basic set of peer info values to server.

Am 19.04.13 19:41, schrieb Gert Doering:

Quoted 5 lines

From: James Yonan <[email protected]...>

On the client, allow certain peer info fields to be pushed even if push-peer-info isn't specified in the config.

Quoted 10 lines

This is needed to allow the compression handshake to work correctly (i.e. where the client indicates its support for LZO and/or Snappy).

Fields that have privacy implications such as Mac Address and UV_* environment variables will not be pushed to the server as before unless push-peer-info is specified by client config.

OpenVPN SVN r8225 (2.1.21c)

ACK.

Arne

#11 lore raw

PATCH 5/5 Fix usage of "compression ..." from global config.

In reply to Gert Doering

The new compression framework introduced by SVN r8206 only works for a P2MP server if the compression settings are re-installed for each client via management interface, ccd/ file or client-connect script, but the "global" settings get lost due to (needlessly) clearing the c2.comp_context in the per-client instance. Fixed. (also trac#273)

---
 src/openvpn/init.c | 4 ----
 1 file changed, 4 deletions(-)
src/openvpn/init.c +0 -4
index 16501fd..b5bad65 100644
@@ -3643,10 +3643,6 @@ inherit_context_child (struct context *dest,
       dest->c2.link_socket_info->lsa = &dest->c1.link_socket_addr;
       dest->c2.link_socket_info->connection_established = false;
     }
-
-#ifdef USE_COMP
-  dest->c2.comp_context = NULL;
-#endif
 }
 
 void
Signature · 1 line
1.8.1.5
#12 lore raw

Re: [Openvpn-devel] [PATCH 5/5] Fix usage of "compression ..." from global config.

Am 19.04.13 19:41, schrieb Gert Doering:

Quoted 7 lines

The new compression framework introduced by SVN r8206 only works for a P2MP server if the compression settings are re-installed for each client via management interface, ccd/ file or client-connect script, but the "global" settings get lost due to (needlessly) clearing the c2.comp_context in the per-client instance. Fixed. (also trac#273)

ACK.

Arne

#13 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix usage of 'compression ...' from global config.

In reply to Gert Doering

Patch has been applied to the master branch.

commit 1690f290f4bd2b203634e8fef9a82f7a03e5b06b

Author: Gert Doering
Date:   Fri Apr 19 19:41:08 2013 +0200
     Fix usage of 'compression ...' from global config.

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/7529

--
kind regards,

Gert Doering

#14 lore raw

PATCH v2 4/5 Always push basic set of peer info values to server.

In reply to Gert Doering

From: James Yonan <[email protected]...>

On the client, allow certain peer info fields to be pushed even if push-peer-info isn't specified in the config.

This is needed to allow the compression handshake to work correctly (i.e. where the client indicates its support for LZO and/or Snappy).

Fields that have privacy implications such as Mac Address and UV_* environment variables will not be pushed to the server as before unless push-peer-info is specified by client config.

v1: equivalent to OpenVPN SVN r8225 (2.1.21c)

v2: distinguish 3 levels of peer-info detail

--push-peer-info specified --> send all we have
--pull specified --> send basic set, as per r8225
default --> send nothing (do not leak from server)

---
 src/openvpn/init.c       |  7 ++++++-
 src/openvpn/ssl.c        | 43 ++++++++++++++++++++++---------------------
 src/openvpn/ssl_common.h |  2 +-
 3 files changed, 29 insertions(+), 23 deletions(-)
src/openvpn/init.c +6 -1
index e700cd6..2a0ba85 100644
@@ -2213,7 +2213,12 @@ do_init_crypto_tls (struct context *c, const unsigned int flags)
   to.renegotiate_seconds = options->renegotiate_seconds;
   to.single_session = options->single_session;
 #ifdef ENABLE_PUSH_PEER_INFO
-  to.push_peer_info = options->push_peer_info;
+  if (options->push_peer_info)		/* all there is */
+    to.push_peer_info_detail = 2;
+  else if (options->pull)		/* pull clients send some details */
+    to.push_peer_info_detail = 1;
+  else					/* default: no peer-info at all */
+    to.push_peer_info_detail = 0;
 #endif
 
   /* should we not xmit any packets until we get an initial
src/openvpn/ssl.c +22 -21

67 lines not on this page · raw message

src/openvpn/ssl_common.h +1 -1
index 47dbefb..0e97487 100644
@@ -233,7 +233,7 @@ struct tls_options
   bool disable_occ;
 #endif
 #ifdef ENABLE_PUSH_PEER_INFO
-  bool push_peer_info;
+  int push_peer_info_detail;
 #endif
   int transition_window;
   int handshake_window;
Signature · 1 line
1.8.1.5
#15 lore raw

PATCH v3 4/5 Always push basic set of peer info values to server.

In reply to Gert Doering

From: James Yonan <[email protected]...>

On the client, allow certain peer info fields to be pushed even if push-peer-info isn't specified in the config.

This is needed to allow the compression handshake to work correctly (i.e. where the client indicates its support for LZO and/or Snappy).

Fields that have privacy implications such as Mac Address and UV_* environment variables will not be pushed to the server as before unless push-peer-info is specified by client config.

v1: equivalent to OpenVPN SVN r8225 (2.1.21c)

v2: distinguish 3 levels of peer-info detail

--push-peer-info specified --> send all we have
--pull specified --> send basic set, as per r8225
default --> send nothing (do not leak from server)

v3: undo extra whitespace changes in v1 and v2

---
 src/openvpn/init.c       |  7 ++++++-
 src/openvpn/ssl.c        | 31 ++++++++++++++++---------------
 src/openvpn/ssl_common.h |  2 +-
 3 files changed, 23 insertions(+), 17 deletions(-)
src/openvpn/init.c +6 -1
index e700cd6..2a0ba85 100644
@@ -2213,7 +2213,12 @@ do_init_crypto_tls (struct context *c, const unsigned int flags)
   to.renegotiate_seconds = options->renegotiate_seconds;
   to.single_session = options->single_session;
 #ifdef ENABLE_PUSH_PEER_INFO
-  to.push_peer_info = options->push_peer_info;
+  if (options->push_peer_info)		/* all there is */
+    to.push_peer_info_detail = 2;
+  else if (options->pull)		/* pull clients send some details */
+    to.push_peer_info_detail = 1;
+  else					/* default: no peer-info at all */
+    to.push_peer_info_detail = 0;
 #endif
 
   /* should we not xmit any packets until we get an initial
src/openvpn/ssl.c +16 -15
index 9ca409f..1026ad4 100644
@@ -1775,7 +1775,7 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
   bool ret = false;
 
 #ifdef ENABLE_PUSH_PEER_INFO
-  if (session->opt->push_peer_info) /* write peer info */
+  if (session->opt->push_peer_info_detail > 0)
     {
       struct env_set *es = session->opt->es;
       struct env_item *e;
@@ -1803,26 +1803,27 @@ push_peer_info(struct buffer *buf, struct tls_session *session)
       buf_printf (&out, "IV_PLAT=win\n");
 #endif
 
-      /* push mac addr */
-      {
-	struct route_gateway_info rgi;
-	get_default_gateway (&rgi);
-	if (rgi.flags & RGI_HWADDR_DEFINED)
-	  buf_printf (&out, "IV_HWADDR=%s\n", format_hex_ex (rgi.hwaddr, 6, 0, 1, ":", &gc));
-      }
-
       /* push compression status */
 #ifdef USE_COMP
       comp_generate_peer_info_string(&session->opt->comp_options, &out);
 #endif
 
-      /* push env vars that begin with UV_ */
-      for (e=es->list; e != NULL; e=e->next)
-	{
-	  if (e->string)
+      if (session->opt->push_peer_info_detail >= 2)
+        {
+	  /* push mac addr */
+	  struct route_gateway_info rgi;
+	  get_default_gateway (&rgi);
+	  if (rgi.flags & RGI_HWADDR_DEFINED)
+	    buf_printf (&out, "IV_HWADDR=%s\n", format_hex_ex (rgi.hwaddr, 6, 0, 1, ":", &gc));
+
+	  /* push env vars that begin with UV_ */
+	  for (e=es->list; e != NULL; e=e->next)
 	    {
-	      if (!strncmp(e->string, "UV_", 3) && buf_safe(&out, strlen(e->string)+1))
-		buf_printf (&out, "%s\n", e->string);
+	      if (e->string)
+		{
+		  if (!strncmp(e->string, "UV_", 3) && buf_safe(&out, strlen(e->string)+1))
+		    buf_printf (&out, "%s\n", e->string);
+		}
 	    }
 	}
 
src/openvpn/ssl_common.h +1 -1
index 47dbefb..0e97487 100644
@@ -233,7 +233,7 @@ struct tls_options
   bool disable_occ;
 #endif
 #ifdef ENABLE_PUSH_PEER_INFO
-  bool push_peer_info;
+  int push_peer_info_detail;
 #endif
   int transition_window;
   int handshake_window;
Signature · 1 line
1.8.1.5
#16 lore raw

Re: [Openvpn-devel] [PATCH 4/5 v3] Always push basic set of peer info values to server.

Am 20.05.13 12:13, schrieb Gert Doering:

Quoted 5 lines

From: James Yonan <[email protected]...>

On the client, allow certain peer info fields to be pushed even if push-peer-info isn't specified in the config.

Quoted 7 lines

This is needed to allow the compression handshake to work correctly (i.e. where the client indicates its support for LZO and/or Snappy).

Fields that have privacy implications such as Mac Address and UV_* environment variables will not be pushed to the server as before unless push-peer-info is specified by client config.

ACK to this patch.

Arne

#17 lore raw

[Openvpn-devel] [PATCH applied] Re: Always push basic set of peer info values to server.

In reply to Gert Doering

Patch has been applied to the master and release/2.3 branches.

commit 598e03f0e7bce434e501a9895819f2af0714d5f6 (master) commit eed9b8eec911a26a952f07ad18d4397c334ac089 (release/2.3)

Author: James Yonan
Date:   Mon May 20 12:13:21 2013 +0200
     Always push basic set of peer info values to server.

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/7604

--
kind regards,

Gert Doering