route-manager: add routine to query route shadowing for a link

If a route is shadowed by another route to the same network it's a good
indication we're multihoming and want to disable the Strict RP filtering.
This commit is contained in:
Lubomir Rintel 2017-03-16 13:55:14 +00:00
parent 8d4570d28d
commit 75faf5bb77
2 changed files with 28 additions and 0 deletions

View file

@ -967,6 +967,33 @@ nm_route_manager_route_flush (NMRouteManager *self, int ifindex)
return success;
}
/**
* nm_route_manager_ip4_routes_shadowed:
* @ifindex: Interface index
*
* Returns: %TRUE if some other link has a route to the same destination
* with a lower metric.
*/
gboolean
nm_route_manager_ip4_routes_shadowed (NMRouteManager *self, int ifindex)
{
NMRouteManagerPrivate *priv = NM_ROUTE_MANAGER_GET_PRIVATE (self);
RouteIndex *index = priv->ip4_routes.index;
const NMPlatformIP4Route *route;
guint i;
for (i = 1; i < index->len; i++) {
route = (const NMPlatformIP4Route *) index->entries[i];
if (route->ifindex != ifindex)
continue;
if (_v4_route_dest_cmp (route, (const NMPlatformIP4Route *) index->entries[i - 1]) == 0)
return TRUE;
}
return FALSE;
}
/*****************************************************************************/
static gboolean

View file

@ -38,6 +38,7 @@ gboolean nm_route_manager_ip4_route_sync (NMRouteManager *self, int ifindex, con
gboolean nm_route_manager_ip6_route_sync (NMRouteManager *self, int ifindex, const GArray *known_routes, gboolean ignore_kernel_routes, gboolean full_sync);
gboolean nm_route_manager_route_flush (NMRouteManager *self, int ifindex);
gboolean nm_route_manager_ip4_routes_shadowed (NMRouteManager *self, int ifindex);
void nm_route_manager_ip4_route_register_device_route_purge_list (NMRouteManager *self, GArray *device_route_purge_list);
NMRouteManager *nm_route_manager_get (void);