Blame SOURCES/rh1083196-ipv6-method-ignore-auto.patch

708502
From fbdf8857c32e016005f19ad1e0be0bddc902a6ed Mon Sep 17 00:00:00 2001
708502
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
708502
Date: Thu, 29 May 2014 16:36:24 +0200
708502
Subject: [PATCH 1/2] core: take over connections with IPv6 method 'ignore'
708502
 for 'auto' (rh #1083196)
708502
MIME-Version: 1.0
708502
Content-Type: text/plain; charset=UTF-8
708502
Content-Transfer-Encoding: 8bit
708502
708502
If we had a connection with IPv6.method = ignore, we simply ignored IPv6. So
708502
we should assume this connection even if there is an SLAAC address on the
708502
interface.
708502
708502
https://bugzilla.redhat.com/show_bug.cgi?id=1083196
708502
708502
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
708502
---
708502
 src/NetworkManagerUtils.c |  7 ++++---
708502
 src/tests/test-general.c  | 36 ++++++++++++++++++++++++++++++++++++
708502
 2 files changed, 40 insertions(+), 3 deletions(-)
708502
708502
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
708502
index a3d264a..f869034 100644
708502
--- a/src/NetworkManagerUtils.c
708502
+++ b/src/NetworkManagerUtils.c
708502
@@ -707,11 +707,12 @@ check_ip6_method (NMConnection *orig,
708502
 		allow = TRUE;
708502
 	}
708502
 
708502
-	/* If the original connection method is 'link-local' and the candidate method
708502
-	 * is 'ignore' we can take the connection, because NM didn't simply take care
708502
+	/* If the generated connection method is 'link-local' or 'auto' and the candidate
708502
+	 * method is 'ignore' we can take the connection, because NM didn't simply take care
708502
 	 * of IPv6.
708502
 	 */
708502
-	if (   strcmp (orig_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0
708502
+	if (  (   strcmp (orig_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_LINK_LOCAL) == 0
708502
+	       || strcmp (orig_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_AUTO) == 0)
708502
 	    && strcmp (candidate_ip6_method, NM_SETTING_IP6_CONFIG_METHOD_IGNORE) == 0) {
708502
 		allow = TRUE;
708502
 	}
708502
diff --git a/src/tests/test-general.c b/src/tests/test-general.c
708502
index d103c2b..521998b 100644
708502
--- a/src/tests/test-general.c
708502
+++ b/src/tests/test-general.c
708502
@@ -368,6 +368,41 @@ test_connection_match_ip6_method_ignore (void)
708502
 }
708502
 
708502
 static void
708502
+test_connection_match_ip6_method_ignore_auto (void)
708502
+{
708502
+	NMConnection *orig, *copy, *matched;
708502
+	GSList *connections = NULL;
708502
+	NMSettingIP6Config *s_ip6;
708502
+
708502
+	orig = _match_connection_new ();
708502
+	copy = nm_connection_duplicate (orig);
708502
+	connections = g_slist_append (connections, copy);
708502
+
708502
+	/* Check that if the generated connection is IPv6 method=auto, and the
708502
+	 * candidate is method=ignore, that the candidate is matched.
708502
+	 */
708502
+	s_ip6 = nm_connection_get_setting_ip6_config (orig);
708502
+	g_assert (s_ip6);
708502
+	g_object_set (G_OBJECT (s_ip6),
708502
+	              NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_AUTO,
708502
+	              NULL);
708502
+
708502
+	s_ip6 = nm_connection_get_setting_ip6_config (copy);
708502
+	g_assert (s_ip6);
708502
+	g_object_set (G_OBJECT (s_ip6),
708502
+	              NM_SETTING_IP6_CONFIG_METHOD, NM_SETTING_IP6_CONFIG_METHOD_IGNORE,
708502
+	              NULL);
708502
+
708502
+	matched = nm_utils_match_connection (connections, orig, TRUE, NULL, NULL);
708502
+	g_assert (matched == copy);
708502
+
708502
+	g_slist_free (connections);
708502
+	g_object_unref (orig);
708502
+	g_object_unref (copy);
708502
+}
708502
+
708502
+
708502
+static void
708502
 test_connection_match_ip4_method (void)
708502
 {
708502
 	NMConnection *orig, *copy, *matched;
708502
@@ -568,6 +603,7 @@ main (int argc, char **argv)
708502
 	g_test_add_func ("/general/connection-match/basic", test_connection_match_basic);
708502
 	g_test_add_func ("/general/connection-match/ip6-method", test_connection_match_ip6_method);
708502
 	g_test_add_func ("/general/connection-match/ip6-method-ignore", test_connection_match_ip6_method_ignore);
708502
+	g_test_add_func ("/general/connection-match/ip6-method-ignore-auto", test_connection_match_ip6_method_ignore_auto);
708502
 	g_test_add_func ("/general/connection-match/ip4-method", test_connection_match_ip4_method);
708502
 	g_test_add_func ("/general/connection-match/con-interface-name", test_connection_match_interface_name);
708502
 	g_test_add_func ("/general/connection-match/wired", test_connection_match_wired);
708502
-- 
708502
1.7.11.7
708502
708502
708502
From a7fa1aed1b9ca46a2c02a39ad023ad7c1cf88baf Mon Sep 17 00:00:00 2001
708502
From: =?UTF-8?q?Ji=C5=99=C3=AD=20Klime=C5=A1?= <jklimes@redhat.com>
708502
Date: Fri, 30 May 2014 09:06:24 +0200
708502
Subject: [PATCH 2/2] trivial: clarify comments in test-general.c and
708502
 NetworkManagerUtils.c
708502
MIME-Version: 1.0
708502
Content-Type: text/plain; charset=UTF-8
708502
Content-Transfer-Encoding: 8bit
708502
708502
708502
Signed-off-by: Jiří Klimeš <jklimes@redhat.com>
708502
---
708502
 src/NetworkManagerUtils.c |  6 +++---
708502
 src/tests/test-general.c  | 10 +++++-----
708502
 2 files changed, 8 insertions(+), 8 deletions(-)
708502
708502
diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c
708502
index f869034..4df429a 100644
708502
--- a/src/NetworkManagerUtils.c
708502
+++ b/src/NetworkManagerUtils.c
708502
@@ -691,7 +691,7 @@ check_ip6_method (NMConnection *orig,
708502
 	if (!props)
708502
 		return TRUE;
708502
 
708502
-	/* If the original connection is 'link-local' and the candidate is both 'auto'
708502
+	/* If the generated connection is 'link-local' and the candidate is both 'auto'
708502
 	 * and may-fail=TRUE, then the candidate is OK to use.  may-fail is included
708502
 	 * in the decision because if the candidate is 'auto' but may-fail=FALSE, then
708502
 	 * the connection could not possibly have been previously activated on the
708502
@@ -741,7 +741,7 @@ check_ip4_method (NMConnection *orig,
708502
 	if (!props)
708502
 		return TRUE;
708502
 
708502
-	/* If the original connection is 'disabled' (device had no IP addresses)
708502
+	/* If the generated connection is 'disabled' (device had no IP addresses)
708502
 	 * but it has no carrier, that most likely means that IP addressing could
708502
 	 * not complete and thus no IP addresses were assigned.  In that case, allow
708502
 	 * matching to the "auto" method.
708502
@@ -777,7 +777,7 @@ check_connection_interface_name (NMConnection *orig,
708502
 	if (!props)
708502
 		return TRUE;
708502
 
708502
-	/* If one of the interface name is NULL, we accept that connection */
708502
+	/* If one of the interface names is NULL, we accept that connection */
708502
 	s_con_orig = nm_connection_get_setting_connection (orig);
708502
 	s_con_cand = nm_connection_get_setting_connection (candidate);
708502
 	orig_ifname = nm_setting_connection_get_interface_name (s_con_orig);
708502
diff --git a/src/tests/test-general.c b/src/tests/test-general.c
708502
index 521998b..11c03f0 100644
708502
--- a/src/tests/test-general.c
708502
+++ b/src/tests/test-general.c
708502
@@ -308,7 +308,7 @@ test_connection_match_ip6_method (void)
708502
 	copy = nm_connection_duplicate (orig);
708502
 	connections = g_slist_append (connections, copy);
708502
 
708502
-	/* Check that if the original connection is IPv6 method=link-local, and the
708502
+	/* Check that if the generated connection is IPv6 method=link-local, and the
708502
 	 * candidate is both method=auto and may-faily=true, that the candidate is
708502
 	 * matched.
708502
 	 */
708502
@@ -344,7 +344,7 @@ test_connection_match_ip6_method_ignore (void)
708502
 	copy = nm_connection_duplicate (orig);
708502
 	connections = g_slist_append (connections, copy);
708502
 
708502
-	/* Check that if the original connection is IPv6 method=link-local, and the
708502
+	/* Check that if the generated connection is IPv6 method=link-local, and the
708502
 	 * candidate is method=ignore, that the candidate is matched.
708502
 	 */
708502
 	s_ip6 = nm_connection_get_setting_ip6_config (orig);
708502
@@ -413,7 +413,7 @@ test_connection_match_ip4_method (void)
708502
 	copy = nm_connection_duplicate (orig);
708502
 	connections = g_slist_append (connections, copy);
708502
 
708502
-	/* Check that if the original connection is IPv4 method=disabled, and the
708502
+	/* Check that if the generated connection is IPv4 method=disabled, and the
708502
 	 * candidate is both method=auto and may-faily=true, and the device has no
708502
 	 * carrier that the candidate is matched.
708502
 	 */
708502
@@ -453,8 +453,8 @@ test_connection_match_interface_name (void)
708502
 	copy = nm_connection_duplicate (orig);
708502
 	connections = g_slist_append (connections, copy);
708502
 
708502
-	/* Check that if the original connection is IPv6 method=link-local, and the
708502
-	 * candidate is method=ignore, that the candidate is matched.
708502
+	/* Check that if the generated connection has an interface name and the
708502
+	 * candidate's interface name is NULL, that the candidate is matched.
708502
 	 */
708502
 	s_con = nm_connection_get_setting_connection (orig);
708502
 	g_assert (s_con);
708502
-- 
708502
1.7.11.7
708502