File lz4.diff of Package NetworkManager-openvpn

diff --git a/properties/import-export.c b/properties/import-export.c
index 5507ab8..4f1db6f 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -1018,6 +1018,28 @@ do_import (const char *path, const char *contents, gsize contents_len, GError **
 			continue;
 		}
 
+		if (NM_IN_STRSET (params[0], NMV_OVPN_TAG_COMPRESS)) {
+			const char *v, *cv;
+
+			if (!args_params_check_nargs_minmax (params, 0, 1, &line_error))
+				goto handle_line_error;
+
+			v = params[1] ?: "";
+
+			if (nm_streq(v, "lzo")) {
+				cv = "adaptive";
+			} else if (nm_streq(v, "lz4")) {
+				cv = "lz4";
+			} else if (nm_streq(v, "")) {
+				cv = "no-by-default";
+			} else {
+				line_error = g_strdup_printf (_("unsupported comppress argument"));
+				goto handle_line_error;
+			}
+			setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, cv);
+			continue;
+		}
+
 		if (NM_IN_STRSET (params[0], NMV_OVPN_TAG_FLOAT)) {
 			if (!args_params_check_nargs_n (params, 0, &line_error))
 				goto handle_line_error;
diff --git a/properties/nm-openvpn-editor.c b/properties/nm-openvpn-editor.c
index 5c409b4..7317c98 100644
--- a/properties/nm-openvpn-editor.c
+++ b/properties/nm-openvpn-editor.c
@@ -57,6 +57,7 @@ static GtkFileFilter *sk_file_chooser_filter_new (void);
 /*****************************************************************************/
 
 static const char *comp_lzo_values[] = {
+	"lz4",
 	"adaptive",
 	"yes",
 	"no-by-default",
@@ -71,6 +72,8 @@ comp_lzo_values_conf_coerce (const char *value_conf)
 		return "yes";
 	if (nm_streq (value_conf, "no-by-default"))
 		return "no-by-default";
+	if (nm_streq (value_conf, "lz4"))
+		return "lz4";
 	return "adaptive";
 }
 
@@ -83,6 +86,8 @@ comp_lzo_values_conf_to_display (const char *value_conf)
 		return "no";
 	if (nm_streq (value_conf, "adaptive"))
 		return "adaptive";
+	if (nm_streq (value_conf, "lz4"))
+		return "lz4";
 	g_return_val_if_reached ("adaptive");
 }
 
diff --git a/shared/utils.h b/shared/utils.h
index e3f30be..0d062ac 100644
--- a/shared/utils.h
+++ b/shared/utils.h
@@ -31,6 +31,7 @@
 #define NMV_OVPN_TAG_CIPHER             "cipher"
 #define NMV_OVPN_TAG_CLIENT             "client"
 #define NMV_OVPN_TAG_COMP_LZO           "comp-lzo"
+#define NMV_OVPN_TAG_COMPRESS           "compress"
 #define NMV_OVPN_TAG_CONNECT_TIMEOUT    "connect-timeout"
 #define NMV_OVPN_TAG_CRL_VERIFY         "crl-verify"
 #define NMV_OVPN_TAG_DEV                "dev"
diff --git a/src/nm-openvpn-service.c b/src/nm-openvpn-service.c
index 59b64eb..1d6a61e 100644
--- a/src/nm-openvpn-service.c
+++ b/src/nm-openvpn-service.c
@@ -1492,15 +1492,33 @@ nm_openvpn_start_openvpn_binary (NMOpenvpnPlugin *plugin,
 	 * We use instead a special value "no-by-default" to express "no".
 	 *
 	 * See bgo#769177
+	 *
+	 * OpenVPN 2.4 added a new flag --compress which can have three values:
+	 *  5) --compress
+	 *  6) --compress=lzo
+	 *  7) --compress=lz4
+	 * --comp-lzo has been deprecated. For the time beeing we solve this by adding
+	 * 'lz4' as a valid value for comp-lzo in our confi and if that is present we
+	 * give --compress-lz4 to openvpn.
+
 	 */
 	if (NM_IN_STRSET (tmp, "no")) {
 		/* means no --comp-lzo option. */
 		tmp = NULL;
-	} else if (NM_IN_STRSET (tmp, "no-by-default"))
+	} else if (NM_IN_STRSET (tmp, "no-by-default")) {
 		tmp = "no";
+	} else if (NM_IN_STRSET (tmp, "lz4"))
+		tmp = "lz4";
 
 	if (NM_IN_STRSET (tmp, "yes", "no", "adaptive"))
 		args_add_strv (args, "--comp-lzo", tmp);
+	if (NM_IN_STRSET (tmp, "lz4")) {
+		if (openvpn_binary_detect_version_cached (openvpn_binary, &openvpn_binary_version) != OPENVPN_BINARY_VERSION_2_4_OR_NEWER) {
+			_LOGW ("lz4 compression requires openvpn 2.4 or later");
+		} else {
+			args_add_strv (args, "--compress", tmp);
+		}
+	}
 
 	tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_FLOAT);
 	if (nm_streq0 (tmp, "yes"))
openSUSE Build Service is sponsored by