From a83622f7d000ce65590afa2391a0e5c26eaae21f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 8 Jul 2020 17:18:37 +0200 Subject: [PATCH] platform: skip metric-0 IPv6 routes in nm_platform_ip_route_sync() @routes are the list of routes we want to configure. This contains routes from DHCP and manual routes in the profile. It also contains externally present routes, including the metric=0 routes in the local table. Trying to add an IPv6 route with metric zero adds instead a route with metric 1024. Usually, we wouldn't do that, because that route was present externally, so it possibly is still present (in the platform cache) during sync and we skip the addition. However, there is a race where the external route might just disappear and we'd add a route with metric 1024. Avoid that. --- src/platform/nm-platform.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/platform/nm-platform.c b/src/platform/nm-platform.c index 08822b1cc2..e1d2abd6ed 100644 --- a/src/platform/nm-platform.c +++ b/src/platform/nm-platform.c @@ -4323,6 +4323,13 @@ nm_platform_ip_route_sync (NMPlatform *self, continue; } + if ( !IS_IPv4 + && NMP_OBJECT_CAST_IP6_ROUTE (conf_o)->metric == 0) { + /* User space cannot add routes with metric 0. However, kernel can, and we might track such + * routes in @route as they are present external. Skip them silently. */ + continue; + } + plat_entry = nm_platform_lookup_entry (self, NMP_CACHE_ID_TYPE_OBJECT_TYPE, conf_o);