Hi Arne,
Some final comments (mostly just nitpicking). Other than this, I think
the patch is ready to be merged. I tested it against James' openvpn 3
test server.
On 02-01-16 11:20, Arne Schwabe wrote:
+static void
+lz4_compress (struct buffer *buf, struct buffer work,
+ struct compress_context *compctx,
+ const struct frame* frame)
+{
+ bool compressed;
+ if (buf->len <= 0)
+ return;
+
+ compressed = do_lz4_compress(buf, &work, compctx, frame);
+
+ /* On error do_lz4_compress sets buf len to zero, just return */
+ if (buf->len == 0)
+ return;
/* did compression save us anything? */
{
uint8_t comp_head_byte = NO_COMPRESS_BYTE_SWAP;
- if (compressed && work.len < buf->len)
+ if (compressed && work.len +2 < buf->len)
This +2 needs to go too - it only makes sense for the v2 format.
+static void
+lz4v2_compress (struct buffer *buf, struct buffer work,
+ struct compress_context *compctx,
+ const struct frame* frame)
+{
+ bool compressed;
+ if (buf->len <= 0)
+ return;
+
+ compressed = do_lz4_compress(buf, &work, compctx, frame);
+
+ /* On Error just return */
+ if (buf->len == 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 = BPTR (&work);
+ head[0] = COMP_ALGV2_INDICATOR_BYTE;
+ head[1] = COMP_ALGV2_LZ4_BYTE;
+ *buf = work;
+ }
+ else
+ {
+ compv2_escape_data_ifneeded(buf);
+ }
+ }
This extra pair of scoping braces is not needed.
diff --git a/src/openvpn/options.c b/src/openvpn/options.c
index 5a83897..b00059a 100644
--- a/src/openvpn/options.c
+++ b/src/openvpn/options.c
@@ -6318,16 +6318,20 @@ add_option (struct options *options,
VERIFY_PERMISSION (OPT_P_COMP);
if (p[1])
{
+ options->comp.flags = 0;
if (streq (p[1], "stub"))
{
options->comp.alg = COMP_ALG_STUB;
options->comp.flags = (COMP_F_SWAP|COMP_F_ADVERTISE_STUBS_ONLY);
}
+ else if (streq(p[1], "stub-v2"))
+ {
+ options->comp.alg = COMP_ALGV2_UNCOMPRESSED;
I think this also needs
options->comp.flags = COMP_F_ADVERTISE_STUBS_ONLY;
-Steffan