[NetworkManager-openvpn: 7/8] all: add lz4-v2 compression option



commit 093694734ce03cb42c6181084408da94f0bb8221
Author: Beniamino Galvani <bgalvani redhat com>
Date:   Wed Feb 26 21:42:33 2020 +0100

    all: add lz4-v2 compression option
    
    Add the lz4-v2 compression option, which is currently (version 2.4.8)
    not documented in the man page but apparently supported since years
    [1].
    
    The difference with lz4 is "packet data alignment, which is better
    with the -v2 compression algorithms - which reflects into 'less CPU
    usage, less power drain on mobile devices, possibly higher
    throughput'".
    
    [1] https://community.openvpn.net/openvpn/ticket/820

 properties/import-export.c            | 2 +-
 properties/nm-openvpn-dialog.ui       | 3 +++
 properties/tests/conf/tls-inline.ovpn | 2 +-
 properties/tests/test-import-export.c | 2 +-
 shared/utils.c                        | 5 +++++
 shared/utils.h                        | 1 +
 src/nm-openvpn-service.c              | 3 +++
 7 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index 81f02d1..da18be3 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -1023,7 +1023,7 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
                        if (!args_params_check_nargs_minmax (params, 0, 1, &line_error))
                                goto handle_line_error;
                        if (params[1]) {
-                               if (!NM_IN_STRSET (params[1], "lzo", "lz4")) {
+                               if (!NM_IN_STRSET (params[1], "lzo", "lz4", "lz4-v2")) {
                                        line_error = g_strdup_printf (_("unsupported compress argument"));
                                        goto handle_line_error;
                                }
diff --git a/properties/nm-openvpn-dialog.ui b/properties/nm-openvpn-dialog.ui
index 4080265..773e0dc 100644
--- a/properties/nm-openvpn-dialog.ui
+++ b/properties/nm-openvpn-dialog.ui
@@ -76,6 +76,9 @@
       <row>
         <col id="0" translatable="yes">LZ4</col>
       </row>
+      <row>
+        <col id="0" translatable="yes">LZ4 v2</col>
+      </row>
       <row>
         <col id="0" translatable="yes">Automatic</col>
       </row>
diff --git a/properties/tests/conf/tls-inline.ovpn b/properties/tests/conf/tls-inline.ovpn
index 1db6a8c..f0fe472 100644
--- a/properties/tests/conf/tls-inline.ovpn
+++ b/properties/tests/conf/tls-inline.ovpn
@@ -152,6 +152,6 @@ rYw1t2eucHvGjH8PnTh0aJPJaI67jmNbSI4CnHNcRgZ+1ow1GS+RAK7kotS+dZz9
 remote-cert-tls server
 tls-remote "/CN=myvpn.company.com"
 
-compress
+compress lz4-v2
 verb 3
 
diff --git a/properties/tests/test-import-export.c b/properties/tests/test-import-export.c
index 09d2483..52944e0 100644
--- a/properties/tests/test-import-export.c
+++ b/properties/tests/test-import-export.c
@@ -473,7 +473,7 @@ test_tls_inline_import (void)
        _check_item (s_vpn, NM_OPENVPN_KEY_DEV, "tun");
        _check_item (s_vpn, NM_OPENVPN_KEY_PROTO_TCP, NULL);
        _check_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, NULL);
-       _check_item (s_vpn, NM_OPENVPN_KEY_COMPRESS, "yes");
+       _check_item (s_vpn, NM_OPENVPN_KEY_COMPRESS, "lz4-v2");
        _check_item (s_vpn, NM_OPENVPN_KEY_FLOAT, "yes");
        _check_item (s_vpn, NM_OPENVPN_KEY_RENEG_SECONDS, NULL);
        _check_item (s_vpn, NM_OPENVPN_KEY_REMOTE, "173.8.149.245:1194");
diff --git a/shared/utils.c b/shared/utils.c
index 10c1f38..3ade7d8 100644
--- a/shared/utils.c
+++ b/shared/utils.c
@@ -120,6 +120,8 @@ nmovpn_compression_from_options (const char *comp_lzo, const char *compress)
                return NMOVPN_COMP_LZO;
        if (nm_streq0 (compress, "lz4"))
                return NMOVPN_COMP_LZ4;
+       if (nm_streq0 (compress, "lz4-v2"))
+               return NMOVPN_COMP_LZ4_V2;
        if (nm_streq0 (compress, "yes"))
                return NMOVPN_COMP_AUTO;
 
@@ -150,6 +152,9 @@ nmovpn_compression_to_options (NMOvpnComp comp,
        case NMOVPN_COMP_LZ4:
                NM_SET_OUT (compress, "lz4");
                break;
+       case NMOVPN_COMP_LZ4_V2:
+               NM_SET_OUT (compress, "lz4-v2");
+               break;
        case NMOVPN_COMP_AUTO:
                NM_SET_OUT (compress, "yes");
                break;
diff --git a/shared/utils.h b/shared/utils.h
index 78ef7d6..d109b0e 100644
--- a/shared/utils.h
+++ b/shared/utils.h
@@ -89,6 +89,7 @@ typedef enum {
        NMOVPN_COMP_DISABLED,             /* no option */
        NMOVPN_COMP_LZO,                  /* "--compress lzo" or "--comp-lzo yes" */
        NMOVPN_COMP_LZ4,                  /* "--compress lz4" */
+       NMOVPN_COMP_LZ4_V2,               /* "--compress lz4-v2" */
        NMOVPN_COMP_AUTO,                 /* "--compress" */
        NMOVPN_COMP_LEGACY_LZO_DISABLED,  /* "--comp-lzo no" */
        NMOVPN_COMP_LEGACY_LZO_ADAPTIVE,  /* "--comp-lzo [adaptive]" */
diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index 10c3a61..ceda366 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -1516,12 +1516,15 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
                        args_add_strv (args, "--comp-lzo", "yes");
                break;
        case NMOVPN_COMP_LZ4:
+       case NMOVPN_COMP_LZ4_V2:
        case NMOVPN_COMP_AUTO:
                if (openvpn_binary_version != OPENVPN_BINARY_VERSION_2_4_OR_NEWER)
                        _LOGW ("\"compress\" option supported only by OpenVPN >= 2.4");
 
                if (comp == NMOVPN_COMP_LZ4)
                        args_add_strv (args, "--compress", "lz4");
+               else if (comp == NMOVPN_COMP_LZ4_V2)
+                       args_add_strv (args, "--compress", "lz4-v2");
                else
                        args_add_strv (args, "--compress");
                break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]