route-manager: add argument @ignore_kernel_routes to route_sync()

Will be used later, no behavioral change yet.

(cherry picked from commit 347555795f)
This commit is contained in:
Thomas Haller 2015-06-24 11:21:43 +02:00
parent a698b70d0f
commit 8532b83f46
5 changed files with 23 additions and 18 deletions

View file

@ -284,7 +284,7 @@ nm_ip4_config_commit (const NMIP4Config *config, int ifindex, guint32 default_ro
g_array_append_vals (routes, route, 1);
}
success = nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes);
success = nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes, TRUE);
g_array_unref (routes);
if (!success)
return FALSE;

View file

@ -398,7 +398,7 @@ nm_ip6_config_commit (const NMIP6Config *config, int ifindex)
g_array_append_vals (routes, route, 1);
}
success = nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes);
success = nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes, TRUE);
g_array_unref (routes);
}

View file

@ -345,7 +345,7 @@ _sort_indexes_cmp (guint *a, guint *b)
/*********************************************************************************************/
static gboolean
_vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const GArray *known_routes)
_vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const GArray *known_routes, gboolean ignore_kernel_routes)
{
NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE (self);
GArray *plat_routes;
@ -362,7 +362,10 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const
nm_platform_process_events (priv->platform);
ipx_routes = vtable->vt->is_ip4 ? &priv->ip4_routes : &priv->ip6_routes;
plat_routes = vtable->vt->route_get_all (priv->platform, ifindex, NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT);
plat_routes = vtable->vt->route_get_all (priv->platform, ifindex,
ignore_kernel_routes
? NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT
: NM_PLATFORM_GET_ROUTE_FLAGS_WITH_NON_DEFAULT | NM_PLATFORM_GET_ROUTE_FLAGS_WITH_RTPROT_KERNEL);
plat_routes_idx = _route_index_create (vtable, plat_routes);
known_routes_idx = _route_index_create (vtable, known_routes);
@ -590,6 +593,7 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const
* nm_route_manager_ip4_route_sync:
* @ifindex: Interface index
* @known_routes: List of routes
* @ignore_kernel_routes: if %TRUE, ignore kernel routes.
*
* A convenience function to synchronize routes for a specific interface
* with the least possible disturbance. It simply removes routes that are
@ -600,15 +604,16 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const
* Returns: %TRUE on success.
*/
gboolean
nm_route_manager_ip4_route_sync (NMRouteManager *self, int ifindex, const GArray *known_routes)
nm_route_manager_ip4_route_sync (NMRouteManager *self, int ifindex, const GArray *known_routes, gboolean ignore_kernel_routes)
{
return _vx_route_sync (&vtable_v4, self, ifindex, known_routes);
return _vx_route_sync (&vtable_v4, self, ifindex, known_routes, ignore_kernel_routes);
}
/**
* nm_route_manager_ip6_route_sync:
* @ifindex: Interface index
* @known_routes: List of routes
* @ignore_kernel_routes: if %TRUE, ignore kernel routes.
*
* A convenience function to synchronize routes for a specific interface
* with the least possible disturbance. It simply removes routes that are
@ -619,16 +624,16 @@ nm_route_manager_ip4_route_sync (NMRouteManager *self, int ifindex, const GArray
* Returns: %TRUE on success.
*/
gboolean
nm_route_manager_ip6_route_sync (NMRouteManager *self, int ifindex, const GArray *known_routes)
nm_route_manager_ip6_route_sync (NMRouteManager *self, int ifindex, const GArray *known_routes, gboolean ignore_kernel_routes)
{
return _vx_route_sync (&vtable_v6, self, ifindex, known_routes);
return _vx_route_sync (&vtable_v6, self, ifindex, known_routes, ignore_kernel_routes);
}
gboolean
nm_route_manager_route_flush (NMRouteManager *self, int ifindex)
{
return nm_route_manager_ip4_route_sync (self, ifindex, NULL)
&& nm_route_manager_ip6_route_sync (self, ifindex, NULL);
return nm_route_manager_ip4_route_sync (self, ifindex, NULL, TRUE)
&& nm_route_manager_ip6_route_sync (self, ifindex, NULL, TRUE);
}
/*********************************************************************************************/

View file

@ -42,8 +42,8 @@ typedef struct {
GType nm_route_manager_get_type (void);
gboolean nm_route_manager_ip4_route_sync (NMRouteManager *self, int ifindex, const GArray *known_routes);
gboolean nm_route_manager_ip6_route_sync (NMRouteManager *self, int ifindex, const GArray *known_routes);
gboolean nm_route_manager_ip4_route_sync (NMRouteManager *self, int ifindex, const GArray *known_routes, gboolean ignore_kernel_routes);
gboolean nm_route_manager_ip6_route_sync (NMRouteManager *self, int ifindex, const GArray *known_routes, gboolean ignore_kernel_routes);
gboolean nm_route_manager_route_flush (NMRouteManager *self, int ifindex);
NMRouteManager *nm_route_manager_get (void);

View file

@ -61,7 +61,7 @@ setup_dev0_ip4 (int ifindex, guint mss_of_first_route, guint32 metric_of_second_
route.mss = 0;
g_array_append_val (routes, route);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes, TRUE);
g_array_free (routes, TRUE);
}
@ -107,7 +107,7 @@ setup_dev1_ip4 (int ifindex)
route.metric = 22;
g_array_append_val (routes, route);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes, TRUE);
g_array_free (routes, TRUE);
}
@ -134,7 +134,7 @@ update_dev0_ip4 (int ifindex)
route.metric = 21;
g_array_append_val (routes, route);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes);
nm_route_manager_ip4_route_sync (nm_route_manager_get (), ifindex, routes, TRUE);
g_array_free (routes, TRUE);
}
@ -346,7 +346,7 @@ setup_dev0_ip6 (int ifindex)
0);
g_array_append_val (routes, *route);
nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes);
nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes, TRUE);
g_array_free (routes, TRUE);
}
@ -403,7 +403,7 @@ setup_dev1_ip6 (int ifindex)
0);
g_array_append_val (routes, *route);
nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes);
nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes, TRUE);
g_array_free (routes, TRUE);
}
@ -450,7 +450,7 @@ update_dev0_ip6 (int ifindex)
0);
g_array_append_val (routes, *route);
nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes);
nm_route_manager_ip6_route_sync (nm_route_manager_get (), ifindex, routes, TRUE);
g_array_free (routes, TRUE);
}