ipconfig: Set default IPv6 method according to kernel IPv6 support
authorJukka Rissanen <jukka.rissanen@linux.intel.com>
Mon, 24 Sep 2012 11:44:31 +0000 (14:44 +0300)
committerPatrik Flykt <patrik.flykt@linux.intel.com>
Tue, 25 Sep 2012 13:55:33 +0000 (16:55 +0300)
If kernel does not support IPv6, then turn default ipconfig
method OFF. If kernel supports IPv6, then the default is AUTO
meaning that we try to send router solicitation messages.

src/ipconfig.c

index 4d8c569..0c88fa5 100644 (file)
@@ -89,6 +89,7 @@ struct connman_ipdevice {
 
 static GHashTable *ipdevice_hash = NULL;
 static GList *ipconfig_list = NULL;
+static connman_bool_t is_ipv6_supported = FALSE;
 
 struct connman_ipaddress *connman_ipaddress_alloc(int family)
 {
@@ -1266,7 +1267,11 @@ static struct connman_ipconfig *create_ipv6config(int index)
        ipv6config->index = index;
        ipv6config->enabled = FALSE;
        ipv6config->type = CONNMAN_IPCONFIG_TYPE_IPV6;
-       ipv6config->method = CONNMAN_IPCONFIG_METHOD_AUTO;
+
+       if (is_ipv6_supported == FALSE)
+               ipv6config->method = CONNMAN_IPCONFIG_METHOD_OFF;
+       else
+               ipv6config->method = CONNMAN_IPCONFIG_METHOD_AUTO;
 
        ipdevice = g_hash_table_lookup(ipdevice_hash, GINT_TO_POINTER(index));
        if (ipdevice != NULL)
@@ -1280,7 +1285,8 @@ static struct connman_ipconfig *create_ipv6config(int index)
 
        ipv6config->system = connman_ipaddress_alloc(AF_INET6);
 
-       DBG("ipconfig %p", ipv6config);
+       DBG("ipconfig %p method %s", ipv6config,
+               __connman_ipconfig_method2string(ipv6config->method));
 
        return ipv6config;
 }
@@ -2406,6 +2412,8 @@ int __connman_ipconfig_init(void)
        ipdevice_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal,
                                                        NULL, free_ipdevice);
 
+       is_ipv6_supported = connman_inet_is_ipv6_supported();
+
        return 0;
 }