mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2025-12-29 23:10:18 +01:00
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>
This commit is contained in:
parent
9ed96e15eb
commit
065a3240fb
1 changed files with 10 additions and 10 deletions
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue