diff options
author | Jukka Rissanen <jukka.rissanen@linux.intel.com> | 2012-03-14 17:28:57 +0200 |
---|---|---|
committer | Patrik Flykt <patrik.flykt@linux.intel.com> | 2012-03-19 13:09:10 +0200 |
commit | 2fafb4669a33f5c7700babdd55bfd2f0c26dde90 (patch) | |
tree | ef3a568d55b1f415d17f64c6197f3f257784a849 /src/connection.c | |
parent | 55152eb4345f483ff43a5dbb030dd86a66debaa2 (diff) | |
download | connman-2fafb4669a33f5c7700babdd55bfd2f0c26dde90.tar.gz connman-2fafb4669a33f5c7700babdd55bfd2f0c26dde90.tar.bz2 connman-2fafb4669a33f5c7700babdd55bfd2f0c26dde90.zip |
connection: Check all active gateways in update
There can be multiple active gateways in the system at the same
time so we must check them all when updating gateway info.
Diffstat (limited to 'src/connection.c')
-rw-r--r-- | src/connection.c | 51 |
1 files changed, 34 insertions, 17 deletions
diff --git a/src/connection.c b/src/connection.c index 4e7b0ab6..c7159fed 100644 --- a/src/connection.c +++ b/src/connection.c @@ -809,42 +809,59 @@ void __connman_connection_gateway_remove(struct connman_service *service, gboolean __connman_connection_update_gateway(void) { - struct gateway_data *active_gateway, *default_gateway; + struct gateway_data *default_gateway; gboolean updated = FALSE; + GHashTableIter iter; + gpointer value, key; if (gateway_hash == NULL) return updated; - active_gateway = find_active_gateway(); - update_order(); default_gateway = find_default_gateway(); - DBG("active %p default %p", active_gateway, default_gateway); + DBG("default %p", default_gateway); - if (active_gateway && active_gateway != default_gateway) { - updated = TRUE; + /* + * There can be multiple active gateways so we need to + * check them all. + */ + g_hash_table_iter_init(&iter, gateway_hash); - if (active_gateway->ipv4_gateway) - unset_default_gateway(active_gateway, - CONNMAN_IPCONFIG_TYPE_IPV4); + while (g_hash_table_iter_next(&iter, &key, &value) == TRUE) { + struct gateway_data *active_gateway = value; - if (active_gateway->ipv6_gateway) - unset_default_gateway(active_gateway, - CONNMAN_IPCONFIG_TYPE_IPV6); + if (active_gateway == default_gateway) + continue; + + if (active_gateway->ipv4_gateway != NULL && + active_gateway->ipv4_gateway->active == TRUE) { - if (default_gateway) { - if (default_gateway->ipv4_gateway) - set_default_gateway(default_gateway, + unset_default_gateway(active_gateway, CONNMAN_IPCONFIG_TYPE_IPV4); + updated = TRUE; + } + + if (active_gateway->ipv6_gateway != NULL && + active_gateway->ipv6_gateway->active == TRUE) { - if (default_gateway->ipv6_gateway) - set_default_gateway(default_gateway, + unset_default_gateway(active_gateway, CONNMAN_IPCONFIG_TYPE_IPV6); + updated = TRUE; } } + if (updated && default_gateway != NULL) { + if (default_gateway->ipv4_gateway) + set_default_gateway(default_gateway, + CONNMAN_IPCONFIG_TYPE_IPV4); + + if (default_gateway->ipv6_gateway) + set_default_gateway(default_gateway, + CONNMAN_IPCONFIG_TYPE_IPV6); + } + return updated; } |