summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLubomir Rintel <lkundrak@v3.sk>2017-03-16 13:55:14 +0000
committerLubomir Rintel <lkundrak@v3.sk>2017-03-22 12:21:39 +0100
commit75faf5bb77706267feb0438803c2b318130c9916 (patch)
treeaee1bc8b937212c25e2fe518c2b2178d564797ef
parent8d4570d28d1825d52de936b21d785c75b602394a (diff)
downloadNetworkManager-75faf5bb77706267feb0438803c2b318130c9916.tar.gz
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.
-rw-r--r--src/nm-route-manager.c27
-rw-r--r--src/nm-route-manager.h1
2 files changed, 28 insertions, 0 deletions
diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c
index a8778e2a7d..13cb032724 100644
--- a/src/nm-route-manager.c
+++ b/src/nm-route-manager.c
@@ -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
diff --git a/src/nm-route-manager.h b/src/nm-route-manager.h
index d12f025603..181d794ee5 100644
--- a/src/nm-route-manager.h
+++ b/src/nm-route-manager.h
@@ -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);