From: Yu Watanabe Date: Mon, 11 Nov 2024 17:11:12 +0000 (+0900) Subject: network/ndisc: restore the original preference and priority before checking if existi... X-Git-Tag: v257-rc2~25^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e2060bc124238581d48be159b4da44017f96a26d;p=thirdparty%2Fsystemd.git network/ndisc: restore the original preference and priority before checking if existing route can be updated Follow-up for 972f1d17ab461a51142a142609dd3ec50bae8440. This fixes the logic of removing unnecessary routes configured by the previously received RAs. Previously, we wrongly handled existing routes could be updated, and unexpected routes would be kept. --- diff --git a/src/network/networkd-ndisc.c b/src/network/networkd-ndisc.c index 0833cd37734..3871618e5f5 100644 --- a/src/network/networkd-ndisc.c +++ b/src/network/networkd-ndisc.c @@ -224,6 +224,9 @@ static int ndisc_request_route(Route *route, Link *link) { * and also an existing pending request, then the source may be updated by the request. So, * we first need to check the source of the requested route. */ if (route_get_request(link->manager, route, &req) >= 0) { + route->pref = pref_original; + ndisc_set_route_priority(link, route); + existing = ASSERT_PTR(req->userdata); if (!route_can_update(existing, route)) { if (existing->source == NETWORK_CONFIG_SOURCE_STATIC) { @@ -238,8 +241,14 @@ static int ndisc_request_route(Route *route, Link *link) { } } + route->pref = pref; + ndisc_set_route_priority(link, route); + /* Then, check if a conflicting route exists. */ if (route_get(link->manager, route, &existing) >= 0) { + route->pref = pref_original; + ndisc_set_route_priority(link, route); + if (!route_can_update(existing, route)) { if (existing->source == NETWORK_CONFIG_SOURCE_STATIC) { log_link_debug(link, "Found an existing route that conflicts with new route based on a received RA, ignoring request.");