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