Commit c41e35db authored by Patrik Flykt's avatar Patrik Flykt Committed by Slava Monich

connection: Use the sorted service list to find the default gateway

The service list is always sorted and thus the service that should have
the default gateway is first in the list. The first service in the list
is the one with the largest 'order' value and the gateway 'order'
variables all contain the same value as the respective service 'order'
parent 5f0e7067
......@@ -558,25 +558,13 @@ static void unset_default_gateway(struct gateway_data *data,
static struct gateway_data *find_default_gateway(void)
struct gateway_data *found = NULL;
unsigned int order = 0;
GHashTableIter iter;
gpointer value, key;
g_hash_table_iter_init(&iter, gateway_hash);
while (g_hash_table_iter_next(&iter, &key, &value)) {
struct gateway_data *data = value;
if (!found || data->order > order) {
found = data;
order = data->order;
struct connman_service *service;
DBG("default %p order %d", found, order);
service = __connman_service_get_default();
if (!service)
return NULL;
return found;
return g_hash_table_lookup(gateway_hash, service);
static bool choose_default_gateway(struct gateway_data *data,
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment