summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2014-11-07 18:38:58 +0100
committerThomas Haller <thaller@redhat.com>2014-11-07 18:50:31 +0100
commit065a3240fb22b004cb0a92df7b6cf787be8a2eb1 (patch)
tree05f127c3683b6e01b0f140b790297cbbd0aef4b1
parent9ed96e15eb57865660ce39763696352f8d33d78c (diff)
downloadNetworkManager-065a3240fb22b004cb0a92df7b6cf787be8a2eb1.tar.gz
policy: fix get_best_device() to return only active devices from the list
This fixes an assertion during shutdown. NMManager:dispose() calls remove_device(), which eventually hit the assertion in nm_default_route_manager_ip4_get_best_device(). Remove the assertion, but also make sure that the function only returns devices from the provided list. It is counter intuitive, that the function might return devices that are not in the provided list. Signed-off-by: Thomas Haller <thaller@redhat.com>
-rw-r--r--src/nm-default-route-manager.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/nm-default-route-manager.c b/src/nm-default-route-manager.c
index 0bf37f0522..22a042a4af 100644
--- a/src/nm-default-route-manager.c
+++ b/src/nm-default-route-manager.c
@@ -669,12 +669,8 @@ nm_default_route_manager_ip6_connection_has_default_route (NMDefaultRouteManager
/***********************************************************************************/
-/** _ipx_get_best_device:
- * @vtable: the virtual table
- * @self: #NMDefaultRouteManager
- **/
static NMDevice *
-_ipx_get_best_device (const VTableIP *vtable, NMDefaultRouteManager *self)
+_ipx_get_best_device (const VTableIP *vtable, NMDefaultRouteManager *self, const GSList *devices)
{
NMDefaultRouteManagerPrivate *priv;
GPtrArray *entries;
@@ -682,6 +678,9 @@ _ipx_get_best_device (const VTableIP *vtable, NMDefaultRouteManager *self)
g_return_val_if_fail (NM_IS_DEFAULT_ROUTE_MANAGER (self), NULL);
+ if (!devices)
+ return NULL;
+
priv = NM_DEFAULT_ROUTE_MANAGER_GET_PRIVATE (self);
entries = vtable->get_entries (priv);
@@ -692,7 +691,9 @@ _ipx_get_best_device (const VTableIP *vtable, NMDefaultRouteManager *self)
continue;
g_assert (!entry->never_default);
- return entry->source.pointer;
+
+ if (g_slist_find ((GSList *) devices, entry->source.device))
+ return entry->source.pointer;
}
return NULL;
}
@@ -720,8 +721,7 @@ _ipx_get_best_activating_device (const VTableIP *vtable, NMDefaultRouteManager *
priv = NM_DEFAULT_ROUTE_MANAGER_GET_PRIVATE (self);
- best_activated_device = _ipx_get_best_device (vtable, self);
- g_return_val_if_fail (!best_activated_device || g_slist_find ((GSList *) devices, best_activated_device), NULL);
+ best_activated_device = _ipx_get_best_device (vtable, self, devices);
for (iter = devices; iter; iter = g_slist_next (iter)) {
NMDevice *device = NM_DEVICE (iter->data);
@@ -771,7 +771,7 @@ NMDevice *
nm_default_route_manager_ip4_get_best_device (NMDefaultRouteManager *self, const GSList *devices, gboolean fully_activated, NMDevice *preferred_device)
{
if (fully_activated)
- return _ipx_get_best_device (&vtable_ip4, self);
+ return _ipx_get_best_device (&vtable_ip4, self, devices);
else
return _ipx_get_best_activating_device (&vtable_ip4, self, devices, preferred_device);
}
@@ -780,7 +780,7 @@ NMDevice *
nm_default_route_manager_ip6_get_best_device (NMDefaultRouteManager *self, const GSList *devices, gboolean fully_activated, NMDevice *preferred_device)
{
if (fully_activated)
- return _ipx_get_best_device (&vtable_ip6, self);
+ return _ipx_get_best_device (&vtable_ip6, self, devices);
else
return _ipx_get_best_activating_device (&vtable_ip6, self, devices, preferred_device);
}