NetworkManager-openvpn: invalid IP6 config received!

local_offer
Category
IT

After an update of my packages, OpenVPN suddenly didn’t connect anymore and dropped an error:

invalid IP6 config received!

Apparently this happens because “OpenVPN 2.5.0 started to pass incomplete IPv6 configurations when the server is not fully configured for IPv6 but has some IPv6 directives.” (source)

Luckily, on Gentoo it’s quite easy to apply a patch to your packages. Indeed, after applying the commit that fixed the issue and rebuilding the package, I was able to connect again. Sweet!

In case you want to fix your package before the upcoming networkmanager-openvpn release, here is a copy of the commit as a diff file:

diff --git a/src/nm-openvpn-service-openvpn-helper.c b/src/nm-openvpn-service-openvpn-helper.c
index 1bcf517ada4f3bae3db3889096bedb174f91239a..d85906bbe82c680a73dd4ec3550c2b934a1a7314 100644
--- a/src/nm-openvpn-service-openvpn-helper.c
+++ b/src/nm-openvpn-service-openvpn-helper.c
@@ -453,6 +453,7 @@ main (int argc, char *argv[])
 	gboolean has_ip4_address = FALSE;
 	gboolean has_ip6_address = FALSE;
 	gchar *bus_name = NM_DBUS_SERVICE_OPENVPN;
+	gsize size;
 
 #if !GLIB_CHECK_VERSION (2, 35, 0)
 	g_type_init ();
@@ -761,12 +762,15 @@ main (int argc, char *argv[])
 
 	ip6config = g_variant_builder_end (&ip6builder);
 
-	if (g_variant_n_children (ip6config)) {
-		val = g_variant_new_boolean (TRUE);
-		g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_HAS_IP6, val);
-	} else {
+	size = g_variant_n_children (ip6config);
+	if (size == 0 || !has_ip6_address) {
+		if (size > 0)
+			_LOGW ("Ignoring IPv6 configuration without an address");
 		g_variant_unref (ip6config);
 		ip6config = NULL;
+	} else {
+		val = g_variant_new_boolean (TRUE);
+		g_variant_builder_add (&builder, "{sv}", NM_VPN_PLUGIN_CONFIG_HAS_IP6, val);
 	}
 
 	if (!ip4config && !ip6config)