Commit 462456f2 authored by Thomas Haller's avatar Thomas Haller

policy: remove redundant remove_default_route() functions from NMDefaultRouteManager

When calling update_default_route(), NMDefaultRouteManager will look at the
source, and determine whether it has a default route or not. For example
for device sources, this means calling nm_device_get_ip4_default_route().

If the source indicates that it has no default route, the effect of
calling update_default_route() is the same as calling
remove_default_route() (hence, remove() can be replaced by update()).

If the source however still indicates a default route, the behavior
would be different. This case would be an undesired inconsistancy,
because source and NMDefaultRouteManager would disagree of whether
the source has a default route.
Source must always properly indicate whether it has a default route
or not, hence this situation does not arise.

Hence it is always better to call update().
Signed-off-by: Thomas Haller's avatarThomas Haller <thaller@redhat.com>
parent 393f213c
...@@ -6935,8 +6935,8 @@ _cleanup_generic_post (NMDevice *self, gboolean deconfigure) ...@@ -6935,8 +6935,8 @@ _cleanup_generic_post (NMDevice *self, gboolean deconfigure)
priv->default_route.v4_has = FALSE; priv->default_route.v4_has = FALSE;
priv->default_route.v6_has = FALSE; priv->default_route.v6_has = FALSE;
nm_default_route_manager_ip4_remove_default_route (nm_default_route_manager_get (), self); nm_default_route_manager_ip4_update_default_route (nm_default_route_manager_get (), self);
nm_default_route_manager_ip6_remove_default_route (nm_default_route_manager_get (), self); nm_default_route_manager_ip6_update_default_route (nm_default_route_manager_get (), self);
/* Clean up IP configs; this does not actually deconfigure the /* Clean up IP configs; this does not actually deconfigure the
* interface; the caller must flush routes and addresses explicitly. * interface; the caller must flush routes and addresses explicitly.
......
...@@ -589,35 +589,6 @@ nm_default_route_manager_ip6_update_default_route (NMDefaultRouteManager *self, ...@@ -589,35 +589,6 @@ nm_default_route_manager_ip6_update_default_route (NMDefaultRouteManager *self,
/***********************************************************************************/ /***********************************************************************************/
static void
_ipx_remove_default_route (const VTableIP *vtable, NMDefaultRouteManager *self, gpointer source)
{
NMDefaultRouteManagerPrivate *priv;
guint entry_idx;
g_return_if_fail (NM_IS_DEFAULT_ROUTE_MANAGER (self));
g_return_if_fail (NM_IS_DEVICE (source) || NM_IS_VPN_CONNECTION (source));
priv = NM_DEFAULT_ROUTE_MANAGER_GET_PRIVATE (self);
if (_entry_find_by_source (vtable->get_entries (priv), source, &entry_idx))
_entry_at_idx_remove (vtable, self, entry_idx);
}
void
nm_default_route_manager_ip4_remove_default_route (NMDefaultRouteManager *self, gpointer source)
{
_ipx_remove_default_route (&vtable_ip4, self, source);
}
void
nm_default_route_manager_ip6_remove_default_route (NMDefaultRouteManager *self, gpointer source)
{
_ipx_remove_default_route (&vtable_ip6, self, source);
}
/***********************************************************************************/
static gboolean static gboolean
_ipx_connection_has_default_route (const VTableIP *vtable, NMDefaultRouteManager *self, NMConnection *connection) _ipx_connection_has_default_route (const VTableIP *vtable, NMDefaultRouteManager *self, NMConnection *connection)
{ {
......
...@@ -51,9 +51,6 @@ NMDefaultRouteManager *nm_default_route_manager_get (void); ...@@ -51,9 +51,6 @@ NMDefaultRouteManager *nm_default_route_manager_get (void);
void nm_default_route_manager_ip4_update_default_route (NMDefaultRouteManager *manager, gpointer source); void nm_default_route_manager_ip4_update_default_route (NMDefaultRouteManager *manager, gpointer source);
void nm_default_route_manager_ip6_update_default_route (NMDefaultRouteManager *manager, gpointer source); void nm_default_route_manager_ip6_update_default_route (NMDefaultRouteManager *manager, gpointer source);
void nm_default_route_manager_ip4_remove_default_route (NMDefaultRouteManager *manager, gpointer source);
void nm_default_route_manager_ip6_remove_default_route (NMDefaultRouteManager *manager, gpointer source);
gboolean nm_default_route_manager_ip4_connection_has_default_route (NMDefaultRouteManager *manager, NMConnection *connection); gboolean nm_default_route_manager_ip4_connection_has_default_route (NMDefaultRouteManager *manager, NMConnection *connection);
gboolean nm_default_route_manager_ip6_connection_has_default_route (NMDefaultRouteManager *manager, NMConnection *connection); gboolean nm_default_route_manager_ip6_connection_has_default_route (NMDefaultRouteManager *manager, NMConnection *connection);
......
...@@ -237,9 +237,6 @@ vpn_cleanup (NMVpnConnection *connection, NMDevice *parent_dev) ...@@ -237,9 +237,6 @@ vpn_cleanup (NMVpnConnection *connection, NMDevice *parent_dev)
nm_platform_address_flush (priv->ip_ifindex); nm_platform_address_flush (priv->ip_ifindex);
} }
nm_default_route_manager_ip4_remove_default_route (nm_default_route_manager_get (), connection);
nm_default_route_manager_ip6_remove_default_route (nm_default_route_manager_get (), connection);
nm_device_set_vpn4_config (parent_dev, NULL); nm_device_set_vpn4_config (parent_dev, NULL);
nm_device_set_vpn6_config (parent_dev, NULL); nm_device_set_vpn6_config (parent_dev, NULL);
...@@ -327,10 +324,8 @@ _set_vpn_state (NMVpnConnection *connection, ...@@ -327,10 +324,8 @@ _set_vpn_state (NMVpnConnection *connection,
dispatcher_cleanup (connection); dispatcher_cleanup (connection);
if (vpn_state >= STATE_DISCONNECTED && vpn_state <= STATE_FAILED) { nm_default_route_manager_ip4_update_default_route (nm_default_route_manager_get (), connection);
nm_default_route_manager_ip4_remove_default_route (nm_default_route_manager_get (), connection); nm_default_route_manager_ip6_update_default_route (nm_default_route_manager_get (), connection);
nm_default_route_manager_ip6_remove_default_route (nm_default_route_manager_get (), connection);
}
/* The connection gets destroyed by the VPN manager when it enters the /* The connection gets destroyed by the VPN manager when it enters the
* disconnected/failed state, but we need to keep it around for a bit * disconnected/failed state, but we need to keep it around for a bit
......
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