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.

(cherry picked from commit a83622f7d0)
This commit is contained in:
Thomas Haller 2020-07-08 17:18:37 +02:00 committed by Antonio Cardace
parent cc412891d0
commit e407cf6ca4
No known key found for this signature in database
GPG key ID: 6BF80ABD43E377D3

View file

@ -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);