From 674b224bc17f1e70366d57bf6ab49ae33c1e4a5a Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Thu, 13 Apr 2017 22:10:20 +0200 Subject: [PATCH] route-manager: normalize host part of tracked routes in _vx_route_sync() The input list of routes is allowed to contain non-normalized routes, that is, routes which host part is non-zero. Such routes are rejected by kernel, but NM should transparently allow them (by normalizing the host part). The ID comparison function route_id_cmp() already properly ignored the (possibly non-zero) host part. However, in the internal list we also should make sure not to track such routes. We achive that by normalizing the host part to zero. Note that below we check whether the tracked route is idential to the route configured at platform. If we don't normalize the host part, the comparison will always indicate that the route is not yet configured, and thus we will re-sync the route every time. (cherry picked from commit 5c54b7a31e401d48568cc50827bca3c4043da20c) --- src/nm-route-manager.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/nm-route-manager.c b/src/nm-route-manager.c index 4a7ef7144..d97d868af 100644 --- a/src/nm-route-manager.c +++ b/src/nm-route-manager.c @@ -536,6 +536,8 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const memcpy (cur_ipx_route, cur_known_route, vtable->vt->sizeof_route); cur_ipx_route->rx.ifindex = ifindex; cur_ipx_route->rx.metric = vtable->vt->metric_normalize (cur_ipx_route->rx.metric); + nm_utils_ipx_address_clear_host_address (vtable->vt->addr_family, cur_ipx_route->rx.network_ptr, + cur_ipx_route->rx.network_ptr, cur_ipx_route->rx.plen); ipx_routes_changed = TRUE; _LOGt (vtable->vt->addr_family, "%3d: STATE: update #%u - %s", ifindex, i_ipx_routes, vtable->vt->route_to_string (cur_ipx_route, NULL, 0)); @@ -631,6 +633,8 @@ _vx_route_sync (const VTableIP *vtable, NMRouteManager *self, int ifindex, const ipx_route = VTABLE_ROUTE_INDEX (vtable, ipx_routes->entries, ipx_routes->entries->len - 1); ipx_route->rx.ifindex = ifindex; ipx_route->rx.metric = vtable->vt->metric_normalize (ipx_route->rx.metric); + nm_utils_ipx_address_clear_host_address (vtable->vt->addr_family, ipx_route->rx.network_ptr, + ipx_route->rx.network_ptr, ipx_route->rx.plen); g_array_index (ipx_routes->effective_metrics_reverse, gint64, j++) = -1;