Browse code

version 2.1_beta1

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@588 e7ae566f-a301-0410-adde-c780ea21d3b5

james authored on 2005/10/02 12:41:35
Showing 10 changed files
... ...
@@ -3,6 +3,14 @@ Copyright (C) 2002-2005 OpenVPN Solutions LLC <info@openvpn.net>
3 3
 
4 4
 $Id$
5 5
 
6
+2005.10.01 -- Version 2.1-beta2
7
+
8
+* Made LZO setting pushable.
9
+* Renamed sample-keys/tmp-ca.crt to ca.crt.
10
+* Fixed bug where remove_iroutes_from_push_route_list
11
+  was missing routes if those routes had
12
+  an implied netmask (by omission) of 255.255.255.255. 
13
+
6 14
 2005.09.26 -- Version 2.1-beta1
7 15
 
8 16
 * Merged with 2.0.3-rc1
... ...
@@ -115,7 +115,7 @@
115 115
 #define D_PID_DEBUG_LOW      LOGLEV(7, 70, M_DEBUG)  /* show low-freq packet-id debugging info */
116 116
 #define D_MULTI_DEBUG        LOGLEV(7, 70, M_DEBUG)  /* show medium-freq multi debugging info */
117 117
 #define D_MSS                LOGLEV(7, 70, M_DEBUG)  /* show MSS adjustments */
118
-#define D_COMP_LOW           LOGLEV(7, 70, M_DEBUG)  /* show adaptive compression state changes */
118
+#define D_COMP_LOW           LOGLEV(3, 70, M_DEBUG)  /* show adaptive compression state changes JYFIXME */
119 119
 #define D_REMOTE_LIST        LOGLEV(7, 70, M_DEBUG)  /* show --remote list */
120 120
 #define D_SCRIPT             LOGLEV(7, 70, M_DEBUG)  /* show parms & env vars passed to scripts */
121 121
 #define D_SHOW_NET           LOGLEV(7, 70, M_DEBUG)  /* show routing table and adapter list */
... ...
@@ -142,7 +142,7 @@
142 142
 
143 143
 #define D_TLS_DEBUG          LOGLEV(9, 70, M_DEBUG)  /* show detailed info from TLS routines */
144 144
 #define D_CRYPTO_DEBUG       LOGLEV(9, 70, M_DEBUG)  /* show detailed info from crypto.c routines */
145
-#define D_COMP               LOGLEV(9, 70, M_DEBUG)  /* show compression info */
145
+#define D_COMP               LOGLEV(4, 70, M_DEBUG)  /* show compression info JYFIXME */
146 146
 #define D_READ_WRITE         LOGLEV(9, 70, M_DEBUG)  /* show all tun/tcp/udp reads/writes/opens */
147 147
 #define D_PACKET_CONTENT     LOGLEV(9, 70, M_DEBUG)  /* show before/after encryption packet content */
148 148
 #define D_TLS_NO_SEND_KEY    LOGLEV(9, 70, M_DEBUG)  /* show when no data channel send-key exists */
... ...
@@ -397,7 +397,7 @@ encrypt_sign (struct context *c, bool comp_frag)
397 397
     {
398 398
 #ifdef USE_LZO
399 399
       /* Compress the packet. */
400
-      if (c->options.comp_lzo)
400
+      if (lzo_defined (&c->c2.lzo_compwork))
401 401
 	lzo_compress (&c->c2.buf, b->lzo_compress_buf, &c->c2.lzo_compwork, &c->c2.frame);
402 402
 #endif
403 403
 #ifdef ENABLE_FRAGMENT
... ...
@@ -764,7 +764,7 @@ process_incoming_link (struct context *c)
764 764
 
765 765
 #ifdef USE_LZO
766 766
       /* decompress the incoming packet */
767
-      if (c->options.comp_lzo)
767
+      if (lzo_defined (&c->c2.lzo_compwork))
768 768
 	lzo_decompress (&c->c2.buf, c->c2.buffers->lzo_decompress_buf, &c->c2.lzo_compwork, &c->c2.frame);
769 769
 #endif
770 770
 
... ...
@@ -956,6 +956,7 @@ pull_permission_mask (const struct context *c)
956 956
     | OPT_P_SETENV
957 957
     | OPT_P_SHAPER
958 958
     | OPT_P_TIMER
959
+    | OPT_P_COMP
959 960
     | OPT_P_PERSIST
960 961
     | OPT_P_MESSAGES
961 962
     | OPT_P_EXPLICIT_NOTIFY
... ...
@@ -998,6 +999,17 @@ do_deferred_options (struct context *c, const unsigned int found)
998 998
     }
999 999
 #endif
1000 1000
 
1001
+#ifdef USE_LZO
1002
+  if (found & OPT_P_COMP)
1003
+    {
1004
+      if (lzo_defined (&c->c2.lzo_compwork))
1005
+	{
1006
+	  msg (D_PUSH, "OPTIONS IMPORT: LZO parms modified");
1007
+	  lzo_modify_flags (&c->c2.lzo_compwork, c->options.lzo);
1008
+	}
1009
+    }
1010
+#endif
1011
+
1001 1012
   if (found & OPT_P_SHAPER)
1002 1013
     {
1003 1014
       msg (D_PUSH, "OPTIONS IMPORT: traffic shaper enabled");
... ...
@@ -1474,7 +1486,7 @@ do_init_frame (struct context *c)
1474 1474
   /*
1475 1475
    * Initialize LZO compression library.
1476 1476
    */
1477
-  if (c->options.comp_lzo)
1477
+  if (c->options.lzo & LZO_SELECTED)
1478 1478
     {
1479 1479
       lzo_adjust_frame_parameters (&c->c2.frame);
1480 1480
 
... ...
@@ -1493,7 +1505,7 @@ do_init_frame (struct context *c)
1493 1493
       lzo_adjust_frame_parameters (&c->c2.frame_fragment_omit);	/* omit LZO frame delta from final frame_fragment */
1494 1494
 #endif
1495 1495
     }
1496
-#endif
1496
+#endif /* USE_LZO */
1497 1497
 
1498 1498
 #ifdef ENABLE_SOCKS
1499 1499
   /*
... ...
@@ -2404,8 +2416,8 @@ init_instance (struct context *c, const struct env_set *env, const unsigned int
2404 2404
 
2405 2405
 #ifdef USE_LZO
2406 2406
   /* initialize LZO compression library. */
2407
-  if (options->comp_lzo && (c->mode == CM_P2P || child))
2408
-    lzo_compress_init (&c->c2.lzo_compwork, options->comp_lzo_adaptive);
2407
+  if ((options->lzo & LZO_SELECTED) && (c->mode == CM_P2P || child))
2408
+    lzo_compress_init (&c->c2.lzo_compwork, options->lzo);
2409 2409
 #endif
2410 2410
 
2411 2411
   /* initialize MTU variables */
... ...
@@ -2496,7 +2508,7 @@ close_instance (struct context *c)
2496 2496
 	do_close_check_if_restart_permitted (c);
2497 2497
 
2498 2498
 #ifdef USE_LZO
2499
-	if (c->options.comp_lzo)
2499
+	if (lzo_defined (&c->c2.lzo_compwork))
2500 2500
 	  lzo_compress_uninit (&c->c2.lzo_compwork);
2501 2501
 #endif
2502 2502
 
... ...
@@ -44,9 +44,6 @@ lzo_adaptive_compress_test (struct lzo_adaptive_compress *ac)
44 44
   const bool save = ac->compress_state;
45 45
   const time_t local_now = now;
46 46
 
47
-  if (!ac->enabled)
48
-    return true;
49
-
50 47
   if (!ac->compress_state)
51 48
     {
52 49
       if (local_now >= ac->next)
... ...
@@ -84,11 +81,8 @@ lzo_adaptive_compress_test (struct lzo_adaptive_compress *ac)
84 84
 inline static void
85 85
 lzo_adaptive_compress_data (struct lzo_adaptive_compress *ac, int n_total, int n_comp)
86 86
 {
87
-  if (ac->enabled)
88
-    {
89
-      ac->n_total += n_total;
90
-      ac->n_comp += n_comp;
91
-    }
87
+  ac->n_total += n_total;
88
+  ac->n_comp += n_comp;
92 89
 }
93 90
 
94 91
 void lzo_adjust_frame_parameters (struct frame *frame)
... ...
@@ -102,18 +96,19 @@ void lzo_adjust_frame_parameters (struct frame *frame)
102 102
 }
103 103
 
104 104
 void
105
-lzo_compress_init (struct lzo_compress_workspace *lzowork, bool adaptive)
105
+lzo_compress_init (struct lzo_compress_workspace *lzowork, unsigned int flags)
106 106
 {
107 107
   CLEAR (*lzowork);
108 108
 
109 109
   lzowork->wmem_size = LZO_WORKSPACE;
110
-  lzowork->ac.enabled = adaptive;
110
+  lzowork->flags = flags;
111 111
 
112 112
   if (lzo_init () != LZO_E_OK)
113 113
     msg (M_FATAL, "Cannot initialize LZO compression library");
114 114
   lzowork->wmem = (lzo_voidp) lzo_malloc (lzowork->wmem_size);
115 115
   check_malloc_return (lzowork->wmem);
116 116
   msg (M_INFO, "LZO compression initialized");
117
+  lzowork->defined = true;
117 118
 }
118 119
 
119 120
 void
... ...
@@ -121,9 +116,24 @@ lzo_compress_uninit (struct lzo_compress_workspace *lzowork)
121 121
 {
122 122
   if (lzowork)
123 123
     {
124
+      ASSERT (lzowork->defined);
124 125
       lzo_free (lzowork->wmem);
125 126
       lzowork->wmem = NULL;
127
+      lzowork->defined = false;
128
+    }
129
+}
130
+
131
+static inline bool
132
+lzo_compression_enabled (struct lzo_compress_workspace *lzowork)
133
+{
134
+  if ((lzowork->flags & (LZO_SELECTED|LZO_ON)) == (LZO_SELECTED|LZO_ON))
135
+    {
136
+      if (lzowork->flags & LZO_ADAPTIVE)
137
+	return lzo_adaptive_compress_test (&lzowork->ac);
138
+      else
139
+	return true;
126 140
     }
141
+  return false;
127 142
 }
128 143
 
129 144
 /* Magic numbers to tell our peer if we compressed or not */
... ...
@@ -139,6 +149,8 @@ lzo_compress (struct buffer *buf, struct buffer work,
139 139
   int err;
140 140
   bool compressed = false;
141 141
 
142
+  ASSERT (lzowork->defined);
143
+
142 144
   if (buf->len <= 0)
143 145
     return;
144 146
 
... ...
@@ -146,7 +158,7 @@ lzo_compress (struct buffer *buf, struct buffer work,
146 146
    * In order to attempt compression, length must be at least COMPRESS_THRESHOLD,
147 147
    * and our adaptive level must give the OK.
148 148
    */
149
-  if (buf->len >= COMPRESS_THRESHOLD && lzo_adaptive_compress_test (&lzowork->ac))
149
+  if (buf->len >= COMPRESS_THRESHOLD && lzo_compression_enabled (lzowork))
150 150
     {
151 151
       ASSERT (buf_init (&work, FRAME_HEADROOM (frame)));
152 152
       ASSERT (buf_safe (&work, LZO_EXTRA_BUFFER (PAYLOAD_SIZE (frame))));
... ...
@@ -169,7 +181,8 @@ lzo_compress (struct buffer *buf, struct buffer work,
169 169
       lzowork->post_compress += work.len;
170 170
 
171 171
       /* tell adaptive level about our success or lack thereof in getting any size reduction */
172
-      lzo_adaptive_compress_data(&lzowork->ac, buf->len, work.len);
172
+      if (lzowork->flags & LZO_ADAPTIVE)
173
+	lzo_adaptive_compress_data (&lzowork->ac, buf->len, work.len);
173 174
     }
174 175
 
175 176
   /* did compression save us anything ? */
... ...
@@ -195,6 +208,8 @@ lzo_decompress (struct buffer *buf, struct buffer work,
195 195
   uint8_t c;		/* flag indicating whether or not our peer compressed */
196 196
   int err;
197 197
 
198
+  ASSERT (lzowork->defined);
199
+
198 200
   if (buf->len <= 0)
199 201
     return;
200 202
 
... ...
@@ -235,11 +250,20 @@ lzo_decompress (struct buffer *buf, struct buffer work,
235 235
     }
236 236
 }
237 237
 
238
+void
239
+lzo_modify_flags (struct lzo_compress_workspace *lzowork, unsigned int flags)
240
+{
241
+  ASSERT (lzowork->defined);
242
+  lzowork->flags = flags;
243
+}
244
+
238 245
 /*
239 246
  * Print statistics
240 247
  */
241 248
 void lzo_print_stats (const struct lzo_compress_workspace *lzo_compwork, struct status_output *so)
242 249
 {
250
+  ASSERT (lzo_compwork->defined);
251
+
243 252
   status_printf (so, "pre-compress bytes," counter_format, lzo_compwork->pre_compress);
244 253
   status_printf (so, "post-compress bytes," counter_format, lzo_compwork->post_compress);
245 254
   status_printf (so, "pre-decompress bytes," counter_format, lzo_compwork->pre_decompress);
... ...
@@ -22,6 +22,9 @@
22 22
  *  59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
23 23
  */
24 24
 
25
+#ifndef OPENVPN_LZO_H
26
+#define OPENVPN_LZO_H
27
+
25 28
 #ifdef USE_LZO
26 29
 
27 30
 #ifdef LZO_HEADER_DIR
... ...
@@ -37,6 +40,11 @@
37 37
 #include "common.h"
38 38
 #include "status.h"
39 39
 
40
+/* LZO flags */
41
+#define LZO_SELECTED   (1<<0)
42
+#define LZO_ON         (1<<1)
43
+#define LZO_ADAPTIVE   (1<<2)  
44
+
40 45
 /*
41 46
  * Use LZO compress routine lzo1x_1_15_compress which is described
42 47
  * as faster but needs a bit more memory than the standard routine.
... ...
@@ -74,7 +82,6 @@
74 74
 				 retest for n seconds */
75 75
 
76 76
 struct lzo_adaptive_compress {
77
-  bool enabled;
78 77
   bool compress_state;
79 78
   time_t next;
80 79
   int n_total;
... ...
@@ -90,6 +97,8 @@ struct lzo_compress_workspace
90 90
   lzo_voidp wmem;
91 91
   int wmem_size;
92 92
   struct lzo_adaptive_compress ac;
93
+  unsigned int flags;
94
+  bool defined;
93 95
 
94 96
   /* statistics */
95 97
   counter_type pre_decompress;
... ...
@@ -100,10 +109,12 @@ struct lzo_compress_workspace
100 100
 
101 101
 void lzo_adjust_frame_parameters(struct frame *frame);
102 102
 
103
-void lzo_compress_init (struct lzo_compress_workspace *lzowork, bool adaptive);
103
+void lzo_compress_init (struct lzo_compress_workspace *lzowork, unsigned int flags);
104 104
 
105 105
 void lzo_compress_uninit (struct lzo_compress_workspace *lzowork);
106 106
 
107
+void lzo_modify_flags (struct lzo_compress_workspace *lzowork, unsigned int flags);
108
+
107 109
 void lzo_compress (struct buffer *buf, struct buffer work,
108 110
 		   struct lzo_compress_workspace *lzowork,
109 111
 		   const struct frame* frame);
... ...
@@ -114,4 +125,12 @@ void lzo_decompress (struct buffer *buf, struct buffer work,
114 114
 
115 115
 void lzo_print_stats (const struct lzo_compress_workspace *lzo_compwork, struct status_output *so);
116 116
 
117
+static inline bool
118
+lzo_defined (const struct lzo_compress_workspace *lzowork)
119
+{
120
+  return lzowork->defined;
121
+}
122
+
123
+
117 124
 #endif /* USE_LZO */
125
+#endif
... ...
@@ -1284,7 +1284,8 @@ multi_connection_established (struct multi_context *m, struct multi_instance *mi
1284 1284
     {
1285 1285
       struct gc_arena gc = gc_new ();
1286 1286
       unsigned int option_types_found = 0;
1287
-      const unsigned int option_permissions_mask = OPT_P_INSTANCE|OPT_P_INHERIT|OPT_P_PUSH|OPT_P_TIMER|OPT_P_CONFIG|OPT_P_ECHO;
1287
+      const unsigned int option_permissions_mask =
1288
+	OPT_P_INSTANCE|OPT_P_INHERIT|OPT_P_PUSH|OPT_P_TIMER|OPT_P_CONFIG|OPT_P_ECHO|OPT_P_COMP;
1288 1289
       int cc_succeeded = true; /* client connect script status */
1289 1290
       int cc_succeeded_count = 0;
1290 1291
 
... ...
@@ -560,9 +560,6 @@ init_options (struct options *o)
560 560
   o->rcvbuf = 65536;
561 561
   o->sndbuf = 65536;
562 562
 #endif
563
-#ifdef USE_LZO
564
-  o->comp_lzo_adaptive = true;
565
-#endif
566 563
 #ifdef TARGET_LINUX
567 564
   o->tuntap_options.txqueuelen = 100;
568 565
 #endif
... ...
@@ -1062,8 +1059,7 @@ show_settings (const struct options *o)
1062 1062
   SHOW_BOOL (fast_io);
1063 1063
 
1064 1064
 #ifdef USE_LZO
1065
-  SHOW_BOOL (comp_lzo);
1066
-  SHOW_BOOL (comp_lzo_adaptive);
1065
+  SHOW_INT (lzo);
1067 1066
 #endif
1068 1067
 
1069 1068
   SHOW_STR (route_script);
... ...
@@ -1833,7 +1829,7 @@ options_string (const struct options *o,
1833 1833
     }
1834 1834
 
1835 1835
 #ifdef USE_LZO
1836
-  if (o->comp_lzo)
1836
+  if (o->lzo & LZO_SELECTED)
1837 1837
     buf_printf (&out, ",comp-lzo");
1838 1838
 #endif
1839 1839
 
... ...
@@ -4318,12 +4314,28 @@ add_option (struct options *options,
4318 4318
   else if (streq (p[0], "comp-lzo"))
4319 4319
     {
4320 4320
       VERIFY_PERMISSION (OPT_P_COMP);
4321
-      options->comp_lzo = true;
4321
+      if (p[1])
4322
+	{
4323
+	  ++i;
4324
+	  if (streq (p[1], "yes"))
4325
+	    options->lzo = LZO_SELECTED|LZO_ON;
4326
+	  else if (streq (p[1], "no"))
4327
+	    options->lzo = LZO_SELECTED;
4328
+	  else if (streq (p[1], "adaptive"))
4329
+	    options->lzo = LZO_SELECTED|LZO_ON|LZO_ADAPTIVE;
4330
+	  else
4331
+	    {
4332
+	      msg (msglevel, "bad comp-lzo option: %s -- must be 'yes', 'no', or 'adaptive'", p[1]);
4333
+	      goto err;
4334
+	    }
4335
+	}
4336
+      else
4337
+	options->lzo = LZO_SELECTED|LZO_ON|LZO_ADAPTIVE;
4322 4338
     }
4323 4339
   else if (streq (p[0], "comp-noadapt"))
4324 4340
     {
4325 4341
       VERIFY_PERMISSION (OPT_P_COMP);
4326
-      options->comp_lzo_adaptive = false;
4342
+      options->lzo &= ~LZO_ADAPTIVE;
4327 4343
     }
4328 4344
 #endif /* USE_LZO */
4329 4345
 #ifdef USE_CRYPTO
... ...
@@ -39,6 +39,7 @@
39 39
 #include "plugin.h"
40 40
 #include "manage.h"
41 41
 #include "proxy.h"
42
+#include "lzo.h"
42 43
 
43 44
 /*
44 45
  * Maximum number of parameters associated with an option,
... ...
@@ -224,8 +225,8 @@ struct options
224 224
   bool fast_io;
225 225
 
226 226
 #ifdef USE_LZO
227
-  bool comp_lzo;
228
-  bool comp_lzo_adaptive;
227
+  /* LZO_x flags from lzo.h */
228
+  unsigned int lzo;
229 229
 #endif
230 230
 
231 231
   /* buffer sizes */
... ...
@@ -239,7 +239,7 @@ print_status (const struct context *c, struct status_output *so)
239 239
   status_printf (so, "TCP/UDP write bytes," counter_format, c->c2.link_write_bytes);
240 240
   status_printf (so, "Auth read bytes," counter_format, c->c2.link_read_bytes_auth);
241 241
 #ifdef USE_LZO
242
-  if (c->options.comp_lzo)
242
+  if (lzo_defined (&c->c2.lzo_compwork))
243 243
     lzo_print_stats (&c->c2.lzo_compwork, so);
244 244
 #endif
245 245
 #ifdef PACKET_TRUNCATION_CHECK