From: Mads Kiilerich <mads@kiilerich.com>

Introduce partial support for import of "compress lzo" as alias for "comp-lzo yes".



diff -Naur NetworkManager-openvpn-1.8.2/properties/import-export.c NetworkManager-openvpn-1.8.2-compress/properties/import-export.c
--- NetworkManager-openvpn-1.8.2/properties/import-export.c	2018-03-07 19:09:12.000000000 +0100
+++ NetworkManager-openvpn-1.8.2-compress/properties/import-export.c	2018-04-20 01:26:41.791956042 +0200
@@ -995,6 +995,19 @@
 			continue;
 		}
 
+		if (NM_IN_STRSET (params[0], NMV_OVPN_TAG_COMPRESS)) {
+			if (!args_params_check_nargs_n (params, 1, &line_error))
+				goto handle_line_error;
+			/* Valid parameters are "lzo", "lz4" and empty, but so far we only support lzo as
+			 * input alias for "comp-lzo yes". */
+			if (!nm_streq (params[1], "lzo")) {
+				line_error = args_params_error_message_invalid_arg (params, 1);
+				goto handle_line_error;
+			}
+			setting_vpn_add_data_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, "yes");
+			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 -Naur NetworkManager-openvpn-1.8.2/properties/tests/conf/compress.ovpn NetworkManager-openvpn-1.8.2-compress/properties/tests/conf/compress.ovpn
--- NetworkManager-openvpn-1.8.2/properties/tests/conf/compress.ovpn	1970-01-01 01:00:00.000000000 +0100
+++ NetworkManager-openvpn-1.8.2-compress/properties/tests/conf/compress.ovpn	2018-04-20 01:47:31.223049555 +0200
@@ -0,0 +1,5 @@
+remote 10.11.12.13
+dev tun
+ifconfig 10.8.0.2 10.8.0.1
+secret static.key 1
+compress lzo
diff -Naur NetworkManager-openvpn-1.8.2/properties/tests/test-import-export.c NetworkManager-openvpn-1.8.2-compress/properties/tests/test-import-export.c
--- NetworkManager-openvpn-1.8.2/properties/tests/test-import-export.c	2018-02-22 19:08:14.000000000 +0100
+++ NetworkManager-openvpn-1.8.2-compress/properties/tests/test-import-export.c	2018-04-20 01:33:00.697810820 +0200
@@ -1082,6 +1082,29 @@
 	g_object_unref (connection);
 }
 
+static void
+test_compress_import (gconstpointer test_data)
+{
+	_CREATE_PLUGIN (plugin);
+	NMConnection *connection;
+	NMSettingVpn *s_vpn;
+	const char *file, *expected_val;
+
+	nmtst_test_data_unpack (test_data, &file, &expected_val);
+
+	connection = get_basic_connection (plugin, SRCDIR, file);
+	g_assert (connection);
+
+	/* VPN setting */
+	s_vpn = nm_connection_get_setting_vpn (connection);
+	g_assert (s_vpn);
+
+	/* Data items */
+	_check_item (s_vpn, NM_OPENVPN_KEY_COMP_LZO, "yes");
+
+	g_object_unref (connection);
+}
+
 /*****************************************************************************/
 
 static void
@@ -1255,6 +1278,8 @@
 	_add_test_func_simple (test_route_import);
 	_add_test_func ("route-export", test_export_compare, "route.ovpn", "route.ovpntest");
 
+	_add_test_func ("compress-import", test_compress_import, "compress.ovpn", "yes");
+
 	_add_test_func_simple (test_args_parse_line);
 
 	result = g_test_run ();
diff -Naur NetworkManager-openvpn-1.8.2/shared/utils.h NetworkManager-openvpn-1.8.2-compress/shared/utils.h
--- NetworkManager-openvpn-1.8.2/shared/utils.h	2018-03-07 19:09:12.000000000 +0100
+++ NetworkManager-openvpn-1.8.2-compress/shared/utils.h	2018-04-20 01:20:20.962091548 +0200
@@ -30,6 +30,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_DEV                "dev"
 #define NMV_OVPN_TAG_DEV_TYPE           "dev-type"
