From patchwork Mon Nov 16 09:09:16 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gert Doering X-Patchwork-Id: 5708 Return-Path: Delivered-To: patchwork@openvpn.net Received: by 2002:a05:6022:9292:b0:11a:f58a:e788 with SMTP id dc18csp940157lab; Mon, 16 Nov 2026 01:09:36 -0800 (PST) X-Forwarded-Encrypted: i=2; AL+hErGu73fXv3j55gLo0VR44i1oXSqaAOPufNGcT/WkmyjMDbssAJLGcM8DdfZuCQv7uMiRYYdqSVNbjAQ=@openvpn.net X-Received: by 2002:a05:7022:1701:b0:1b3:9b4d:85f3 with SMTP id a92af1059eb24-1b5030ffe36mr9372957c88.19.1794820175778; Mon, 16 Nov 2026 01:09:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1794820175; cv=none; d=google.com; s=arc-20260327; b=T306QZVAI3p4dZxeG7M3NN0AtA6prZvFo1zG1J4MIP2XE7roDbqWs4zi+CoclbOJyB monHsJHYqvCGuoJeRZFyRcMn3Xwx9hWFOcGM5ZusUecTnaBuuJll8c6bcbbnzTmbuEC0 4MzmciLgAj6325fhnl75Dtxmkb20vdxDxqp5H1vm1Lfc04tFl0d1HN+3vT2kzzjugeY9 I56a7B8BTZh75zC/c9VnTwY/OfwlG7KM+hCq8dFxqy4YLg8dmMb9AsZI5QTQhWmOoJ5M eU+ciEeUQHVoLLM8iiI9eAdk79auGoV+n/6CuQsUu/iBsNi8kjpQHay7Oq+vI6HCGdDD pcug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=errors-to:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :dkim-signature:dkim-signature:dkim-signature; bh=lhKx8tJO/qcWJx7cO2dLF+dk70hzqxZtPvrg0n09rh8=; fh=4NbAC/LsuMLI0S0hprUlLSLCiHwg6SCAifhH718Jh0Q=; b=LG+1azwCYg6EvOTb6MDwie9y26JlpJPYBBzep95eyOaZDpyQ/CgXx54y28RTv8lw+l KWwZ/cKHz1PrMmyy0ZQgXS6AsXAcO8xWRlx+2pxoOGcYpjjs5YG4IgTSDPqw63eSMsLt QZFsFuljxbrlAntMOg8ojpsqk1rmxPwJvyKf3pSnE7sPNQl8taxdP9GzvK7zIaH70bim at/usvMk9m6FZ4mgFLn9une8xhmj1hQQ10U6V0ILd3q3vh9+yk9bXqXqdzaiv8Sw0xGR +jhtAVVJPZeLvY5YIQ66pcuaTpo6WdGc4rotKFgsQzzHhGCSFTx+0JLm8RBtRQSbuoiw uaTQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="OO7p/vc4"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=jwE1XHSx; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="cBUL/sdM"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de Received: from lists.sourceforge.net (lists.sourceforge.net. [216.105.38.7]) by mx.google.com with ESMTPS id a92af1059eb24-1b5032133b3si27724753c88.44.2026.11.16.01.09.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Nov 2026 01:09:35 -0800 (PST) Received-SPF: pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) client-ip=216.105.38.7; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.sourceforge.net header.s=beta header.b="OO7p/vc4"; dkim=neutral (body hash did not verify) header.i=@sourceforge.net header.s=x header.b=jwE1XHSx; dkim=neutral (body hash did not verify) header.i=@sf.net header.s=x header.b="cBUL/sdM"; spf=pass (google.com: domain of openvpn-devel-bounces@lists.sourceforge.net designates 216.105.38.7 as permitted sender) smtp.mailfrom=openvpn-devel-bounces@lists.sourceforge.net; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=muc.de DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.sourceforge.net; s=beta; h=Content-Transfer-Encoding:Content-Type: List-Subscribe:List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id: Subject:MIME-Version:References:In-Reply-To:Message-ID:Date:To:From:Sender: Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Unsubscribe-Post: List-Owner; bh=lhKx8tJO/qcWJx7cO2dLF+dk70hzqxZtPvrg0n09rh8=; b=OO7p/vc4wI+5Q6 rceRv8fbZoFLqJUJxXL41ToPokte3xBt+p97CpIXI8rpNG+9aWll78hwmFF0LFTxfWmncOesEWG35 FcMTvxd8m+Dlh2Hrr6gt1/WX0YVdwep2IP1ItyTq+IbHG3RxPVkK8Xb+28y4o1WpjBYStA4+jL8A4 JTY=; Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.100.1) (envelope-from ) id 1xSsiS-000000003C1-2VaZ; Mon, 16 Nov 2026 09:09:32 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xSsiR-000000003Bv-1A7t for openvpn-devel@lists.sourceforge.net; Mon, 16 Nov 2026 09:09:31 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Unsubscribe-Post:List-Subscribe:List-Post:List-Owner:List-Archive; bh=VNF2p5zE3maXuZIK3Qdsat7XckNmQAxL5pZ0jUtOL58=; b=jwE1XHSxWPtvBFCiOH67EpTFKB 3FoxeoJineps3Mf+tLl4hH7nG49waDJ7rvVSIwW6I2F84/KXjfwM+VcxGNXNySr8P1IuL+F1l6Xzq GvPNlKD/i4fJZ+9j77/hR6eHlvhvGTK7irv2kOodPh51uhz7pldpBJWWYHjXE83/ierk=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:To:From:Sender:Reply-To:Cc:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Unsubscribe-Post: List-Subscribe:List-Post:List-Owner:List-Archive; bh=VNF2p5zE3maXuZIK3Qdsat7XckNmQAxL5pZ0jUtOL58=; b=cBUL/sdM9MZmqsxZIh75x5d8la wdXQWNUKhJIXoPC2v1++7kAlqpkt01UDtxXPRSLVV2tNype3dre9cBD1CrZf+c7uUwrJm65gm2PBZ P0hUYmjq/+oAeKwaFl35Mcch5179ePmAwz6TvIMYfw35BXtm8hwrD5j566uXT9SqVwbs=; Received: from [193.149.48.129] (helo=blue.greenie.muc.de) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.100.1) id 1xSsiP-000000000Y1-1kVg for openvpn-devel@lists.sourceforge.net; Mon, 16 Nov 2026 09:09:31 +0000 Received: from blue.greenie.muc.de (localhost [127.0.0.1]) by blue.greenie.muc.de (8.18.1/8.18.1) with ESMTP id 6AG99Mjc006671 for ; Mon, 16 Nov 2026 10:09:22 +0100 Received: (from gert@localhost) by blue.greenie.muc.de (8.18.2/8.18.1/Submit) id 6AG99M6h006670 for openvpn-devel@lists.sourceforge.net; Mon, 16 Nov 2026 10:09:22 +0100 From: Gert Doering To: openvpn-devel@lists.sourceforge.net Date: Mon, 16 Nov 2026 10:09:16 +0100 Message-ID: <20261116090922.6658-1-gert@greenie.muc.de> X-Mailer: git-send-email 2.55.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Score: 1.3 (+) X-Spam-Report: Spam detection software, running on the system "sfi-spamd-2.hosts.colo.sdot.me", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Razvan Cojocaru Since 7f0214c9 ("Remove support for compression on send") the LZO and LZ4 compress methods only add the stub framing, duplicating stub_compress() and stubv2_compress(). Export those as comp_stub_compr [...] Content analysis details: (1.3 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.3 RDNS_NONE Delivered to internal network by a host with no rDNS X-Headers-End: 1xSsiP-000000000Y1-1kVg Subject: [Openvpn-devel] [PATCH v1] comp: share the stub compress methods with LZO and LZ4 X-BeenThere: openvpn-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: openvpn-devel-bounces@lists.sourceforge.net X-getmail-retrieved-from-mailbox: Inbox X-GMAIL-THRID: 1882005360379363132 X-GMAIL-MSGID: 1882005360379363132 From: Razvan Cojocaru Since 7f0214c9 ("Remove support for compression on send") the LZO and LZ4 compress methods only add the stub framing, duplicating stub_compress() and stubv2_compress(). Export those as comp_stub_compress() and compv2_stub_compress() and use them for all methods. Also allocate the context only once in comp_init(). This also fixes LZO sending dropped packets. encrypt_sign() drops packets by setting buf.len to 0 (e.g. before client-connect has completed) and still calls the compress method. lzo_compress() prepended NO_COMPRESS_BYTE regardless, turning the dropped packet into a one byte packet that was sent. The stub methods return early on empty buffers. Change-Id: I7c9e123a458b9d3757e9de93f401e4e421741675 Signed-off-by: Razvan Cojocaru Acked-by: Frank Lichtenheld Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2143 --- This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master. Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/2143 This mail reflects revision 1 of this Change. Acked-by according to Gerrit (reflected above): Frank Lichtenheld diff --git a/doc/doxygen/doc_compression.h b/doc/doxygen/doc_compression.h index 1f2e93bd1..efd18bf 100644 --- a/doc/doxygen/doc_compression.h +++ b/doc/doxygen/doc_compression.h @@ -60,10 +60,10 @@ * Data Channel Control module\endlink and processes them according to the * settings of the packet's VPN tunnel. The \link data_control Data * Channel Control module\endlink uses the following interface functions: - * - For packets which will be sent to a remote OpenVPN peer: \c - * lzo_compress() - * - For packets which have been received from a remote OpenVPN peer: \c - * lzo_decompress() + * - For packets which will be sent to a remote OpenVPN peer: the \c + * compress method of \c compress_alg + * - For packets which have been received from a remote OpenVPN peer: the + * \c decompress method of \c compress_alg * * @par Settings that control this module's activity * Whether or not the Data Channel Compression module is active depends on diff --git a/src/openvpn/comp-lz4.c b/src/openvpn/comp-lz4.c index 57c6bb3..192d1bd 100644 --- a/src/openvpn/comp-lz4.c +++ b/src/openvpn/comp-lz4.c @@ -55,40 +55,6 @@ { } -/* Doesn't do any actual compression anymore */ -static void -lz4_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, - const struct frame *frame) -{ - if (buf->len <= 0) - { - return; - } - - uint8_t comp_head_byte = NO_COMPRESS_BYTE_SWAP; - uint8_t *head = BPTR(buf); - uint8_t *tail = BEND(buf); - ASSERT(buf_safe(buf, 1)); - ++buf->len; - - /* move head byte of payload to tail */ - *tail = *head; - *head = comp_head_byte; -} - -/* Doesn't do any actual compression anymore */ -static void -lz4v2_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, - const struct frame *frame) -{ - if (buf->len <= 0) - { - return; - } - - compv2_escape_data_ifneeded(buf); -} - static void do_lz4_decompress(int zlen_max, struct buffer *work, struct buffer *buf, struct compress_context *compctx) @@ -198,9 +164,9 @@ } } -const struct compress_alg lz4_alg = { "lz4", lz4_compress_init, lz4_compress_uninit, lz4_compress, - lz4_decompress }; +const struct compress_alg lz4_alg = { "lz4", lz4_compress_init, lz4_compress_uninit, + comp_stub_compress, lz4_decompress }; const struct compress_alg lz4v2_alg = { "lz4v2", lz4v2_compress_init, lz4_compress_uninit, - lz4v2_compress, lz4v2_decompress }; + compv2_stub_compress, lz4v2_decompress }; #endif /* ENABLE_LZ4 */ diff --git a/src/openvpn/comp.c b/src/openvpn/comp.c index 387a7c4..357eabc 100644 --- a/src/openvpn/comp.c +++ b/src/openvpn/comp.c @@ -38,47 +38,41 @@ struct compress_context * comp_init(const struct compress_options *opt) { - struct compress_context *compctx = NULL; + const struct compress_alg *alg; switch (opt->alg) { case COMP_ALG_STUB: - ALLOC_OBJ_CLEAR(compctx, struct compress_context); - compctx->flags = opt->flags; - compctx->alg = comp_stub_alg; + alg = &comp_stub_alg; break; case COMP_ALGV2_UNCOMPRESSED: - ALLOC_OBJ_CLEAR(compctx, struct compress_context); - compctx->flags = opt->flags; - compctx->alg = compv2_stub_alg; + alg = &compv2_stub_alg; break; #ifdef ENABLE_LZO case COMP_ALG_LZO: - ALLOC_OBJ_CLEAR(compctx, struct compress_context); - compctx->flags = opt->flags; - compctx->alg = lzo_alg; + alg = &lzo_alg; break; #endif #ifdef ENABLE_LZ4 case COMP_ALG_LZ4: - ALLOC_OBJ_CLEAR(compctx, struct compress_context); - compctx->flags = opt->flags; - compctx->alg = lz4_alg; + alg = &lz4_alg; break; case COMP_ALGV2_LZ4: - ALLOC_OBJ_CLEAR(compctx, struct compress_context); - compctx->flags = opt->flags; - compctx->alg = lz4v2_alg; + alg = &lz4v2_alg; break; #endif + default: + return NULL; } - if (compctx) - { - (*compctx->alg.compress_init)(compctx); - } + + struct compress_context *compctx; + ALLOC_OBJ_CLEAR(compctx, struct compress_context); + compctx->flags = opt->flags; + compctx->alg = *alg; + (*compctx->alg.compress_init)(compctx); return compctx; } diff --git a/src/openvpn/comp.h b/src/openvpn/comp.h index ad80243..3f6411b 100644 --- a/src/openvpn/comp.h +++ b/src/openvpn/comp.h @@ -208,6 +208,14 @@ void compv2_escape_data_ifneeded(struct buffer *buf); +/* Compress methods of the stub algorithms, also used by LZO and LZ4, which + * no longer compress on send */ +void comp_stub_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, + const struct frame *frame); + +void compv2_stub_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, + const struct frame *frame); + static inline bool comp_enabled(const struct compress_options *info) { diff --git a/src/openvpn/compstub.c b/src/openvpn/compstub.c index 2eef587..b1115c9 100644 --- a/src/openvpn/compstub.c +++ b/src/openvpn/compstub.c @@ -44,9 +44,9 @@ { } -static void -stub_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, - const struct frame *frame) +void +comp_stub_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, + const struct frame *frame) { if (buf->len <= 0) { @@ -104,9 +104,9 @@ } -static void -stubv2_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, - const struct frame *frame) +void +compv2_stub_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, + const struct frame *frame) { if (buf->len <= 0) { @@ -154,8 +154,8 @@ } const struct compress_alg compv2_stub_alg = { "stubv2", stub_compress_init, stub_compress_uninit, - stubv2_compress, stubv2_decompress }; + compv2_stub_compress, stubv2_decompress }; const struct compress_alg comp_stub_alg = { "stub", stub_compress_init, stub_compress_uninit, - stub_compress, stub_decompress }; + comp_stub_compress, stub_decompress }; #endif /* USE_STUB */ diff --git a/src/openvpn/forward.h b/src/openvpn/forward.h index 375635b..1a67319 100644 --- a/src/openvpn/forward.h +++ b/src/openvpn/forward.h @@ -102,7 +102,7 @@ * - Check that the client authentication has succeeded; if not, drop the * packet. * - If the \a comp_frag argument is true: - * - Call \c lzo_compress() of the \link compression Data Channel Compression + * - Call the \c compress method of the \link compression Data Channel Compression * module\endlink to (possibly) compress the packet. * - Call \c fragment_outgoing() of the \link fragmentation Data Channel Fragmentation * module\endlink to (possibly) fragment the packet. @@ -191,7 +191,7 @@ * - Call \c fragment_incoming() of the \link fragmentation Data Channel * Fragmentation module\endlink to reassemble the packet if it's * fragmented. - * - Call \c lzo_decompress() of the \link compression Data Channel + * - Call the \c decompress method of the \link compression Data Channel * Compression module\endlink to decompress the packet if it's * compressed. * - Place the resulting packet in \c c->c2.to_tun so that it can be sent diff --git a/src/openvpn/lzo.c b/src/openvpn/lzo.c index 51cf5e8..3cf0d79 100644 --- a/src/openvpn/lzo.c +++ b/src/openvpn/lzo.c @@ -65,14 +65,6 @@ } static void -lzo_compress(struct buffer *buf, struct buffer work, struct compress_context *compctx, - const struct frame *frame) -{ - uint8_t *header = buf_prepend(buf, 1); - *header = NO_COMPRESS_BYTE; -} - -static void lzo_decompress(struct buffer *buf, struct buffer work, struct compress_context *compctx, const struct frame *frame) { @@ -120,6 +112,6 @@ } } -const struct compress_alg lzo_alg = { "lzo", lzo_compress_init, lzo_compress_uninit, lzo_compress, - lzo_decompress }; +const struct compress_alg lzo_alg = { "lzo", lzo_compress_init, lzo_compress_uninit, + comp_stub_compress, lzo_decompress }; #endif /* ENABLE_LZO */