default-route-manager: fix syncing routes to consider non-synced routes

We already protected route-metrics that are configured as default-routes
in platform. For most cases, that list is identical to our internal list
of non-synced routes.
But if for some reason that is not the case, we must also protect the
metric of routs that we currently track as "non-synced".

(cherry picked from commit 6849050ad9)
This commit is contained in:
Thomas Haller 2015-06-18 17:45:01 +02:00
parent 7be6d96440
commit 27edd58bd4

View file

@ -411,6 +411,30 @@ _get_assumed_interface_metrics (const VTableIP *vtable, NMDefaultRouteManager *s
g_hash_table_add (result, GUINT_TO_POINTER (vtable->vt->metric_normalize (route->metric)));
}
/* also add all non-synced metrics from our entries list. We might have there some metrics that
* we track as non-synced but that are no longer part of platform routes. Anyway, for now
* we still want to treat them as assumed. */
for (i = 0; i < entries->len; i++) {
gboolean ifindex_has_synced_entry = FALSE;
Entry *e_i = g_ptr_array_index (entries, i);
if (e_i->synced)
continue;
for (j = 0; j < entries->len; j++) {
Entry *e_j = g_ptr_array_index (entries, j);
if ( j != i
&& (e_j->synced && e_j->route.rx.ifindex == e_i->route.rx.ifindex)) {
ifindex_has_synced_entry = TRUE;
break;
}
}
if (!ifindex_has_synced_entry)
g_hash_table_add (result, GUINT_TO_POINTER (vtable->vt->metric_normalize (e_i->route.rx.metric)));
}
return result;
}