diff --git a/src/NetworkManagerUtils.c b/src/NetworkManagerUtils.c index a3d264ac20..f869034cfe 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 d103c2b722..521998b896 100644 --- a/src/tests/test-general.c +++ b/src/tests/test-general.c @@ -367,6 +367,41 @@ test_connection_match_ip6_method_ignore (void) g_object_unref (copy); } +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) { @@ -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);