From 9c492c6fc40e7224073811f34ab22a5ba11caeef Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Tue, 24 Jan 2023 14:56:47 +0100 Subject: [PATCH 1/3] Revert "l3cfg: do not add dependent routes for non-default routes" We must trust l3cfg when generating dependent onlink routes for all kind of routes not default routes only. This was done by "nm_platform_ip_route_sync()" so there is not change in behaviour at all. "nm_platform_ip_route_sync()" could be needed for other situation where l3cfg cannot add the dependent onlink routes, so we are not removing that logic. This reverts commit 6b4123db1ce7aff16254976f7bc558b2fe4a9b69. --- src/core/nm-l3-config-data.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index 53896839f7..d7ffe126d3 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -2569,8 +2569,7 @@ nm_l3_config_data_add_dependent_onlink_routes(NML3ConfigData *self, int addr_fam if (nm_ip_addr_is_null(addr_family, p_gateway)) continue; - if (!NM_PLATFORM_IP_ROUTE_IS_DEFAULT(route_src) - || _data_get_direct_route_for_host( + if (_data_get_direct_route_for_host( self, addr_family, p_gateway, From cbf70b4dca4ff520ab33c1b944f95fc52eae52e1 Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Tue, 24 Jan 2023 15:41:50 +0100 Subject: [PATCH 2/3] Revert "nm-netns: add onlink routes for ECMP routes" ECMP IPv4 route nexthops requires an onlink route but we should trust l3cfg when generating and managing such routes. This reverts commit 737cb5d424e397901a5ad979907a084f770dd8d4. --- src/core/nm-netns.c | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/src/core/nm-netns.c b/src/core/nm-netns.c index b5c150c0f3..ca9f66c056 100644 --- a/src/core/nm-netns.c +++ b/src/core/nm-netns.c @@ -780,8 +780,6 @@ _netns_ip_route_ecmp_update_mh(NMNetns *self, const NMPObject *obj = mhrts_add->pdata[i]; nm_auto_nmpobj const NMPObject *obj_old = NULL; gpointer unused; - const NMPlatformIP4Route *route_src; - guint j; if (g_hash_table_steal_extended(priv->ecmp_routes, obj, @@ -794,35 +792,6 @@ _netns_ip_route_ecmp_update_mh(NMNetns *self, if (!g_hash_table_add(priv->ecmp_routes, (gpointer) nmp_object_ref(obj))) nm_assert_not_reached(); - /* for each nexthop we need to configure the onlink route for the gateway */ - route_src = NMP_OBJECT_CAST_IP4_ROUTE(obj); - for (j = 0; j < route_src->n_nexthops; j++) { - NMPObject *new_onlink_obj; - NMPlatformIP4Route *new_onlink_route; - in_addr_t gateway; - int ifindex; - - new_onlink_obj = nmp_object_clone(obj, TRUE); - new_onlink_route = NMP_OBJECT_CAST_IP4_ROUTE(new_onlink_obj); - if (j == 0) { - gateway = route_src->gateway; - ifindex = route_src->ifindex; - } else { - gateway = obj->_ip4_route.extra_nexthops[j - 1].gateway; - ifindex = obj->_ip4_route.extra_nexthops[j - 1].ifindex; - } - - new_onlink_route->network = gateway; - new_onlink_route->plen = 32; - new_onlink_route->gateway = 0; - new_onlink_route->ifindex = ifindex; - new_onlink_route->weight = 0; - new_onlink_route->n_nexthops = 0; - - /* we configure the onlink route and l3cfg will take the ownership and remove it if not needed */ - nm_platform_ip_route_add(priv->platform, NMP_NLM_FLAG_APPEND, new_onlink_obj); - } - nm_platform_ip_route_add(priv->platform, NMP_NLM_FLAG_APPEND, obj); } } From f187e63fa8607f09e8a93a1df27d7b1ff639ffe3 Mon Sep 17 00:00:00 2001 From: Fernando Fernandez Mancera Date: Tue, 24 Jan 2023 15:07:04 +0100 Subject: [PATCH 3/3] l3-config-data: do not check route table to get direct routes Kernel enforces that all route nexthop are reachable but it doesn't care if the drect route to the nexthop is in a different route table. --- src/core/nm-l3-config-data.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/core/nm-l3-config-data.c b/src/core/nm-l3-config-data.c index d7ffe126d3..1c8200c248 100644 --- a/src/core/nm-l3-config-data.c +++ b/src/core/nm-l3-config-data.c @@ -2408,10 +2408,7 @@ nm_l3_config_data_cmp_full(const NML3ConfigData *a, /*****************************************************************************/ static const NMPObject * -_data_get_direct_route_for_host(const NML3ConfigData *self, - int addr_family, - gconstpointer host, - guint32 route_table) +_data_get_direct_route_for_host(const NML3ConfigData *self, int addr_family, gconstpointer host) { const int IS_IPv4 = NM_IS_IPv4(addr_family); const NMPObject *best_route_obj = NULL; @@ -2439,9 +2436,6 @@ _data_get_direct_route_for_host(const NML3ConfigData *self, if (best_route && best_route->rx.plen > item->rx.plen) continue; - if (nm_platform_route_table_uncoerce(item->rx.table_coerced, TRUE) != route_table) - continue; - if (!nm_ip_addr_same_prefix(addr_family, host, item->rx.network_ptr, item->rx.plen)) continue; @@ -2569,11 +2563,7 @@ nm_l3_config_data_add_dependent_onlink_routes(NML3ConfigData *self, int addr_fam if (nm_ip_addr_is_null(addr_family, p_gateway)) continue; - if (_data_get_direct_route_for_host( - self, - addr_family, - p_gateway, - nm_platform_route_table_uncoerce(route_src->rx.table_coerced, TRUE))) + if (_data_get_direct_route_for_host(self, addr_family, p_gateway)) continue; new_route = nmp_object_clone(obj_src, FALSE);