]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/ndisc: restore the original preference and priority before checking if existi...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 11 Nov 2024 17:11:12 +0000 (02:11 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 12 Nov 2024 09:08:25 +0000 (18:08 +0900)
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.

src/network/networkd-ndisc.c

index 0833cd37734bae434cadbd606d5d65f36eb71c9f..3871618e5f54eb72074696f9ad4a8b01628ce28f 100644 (file)
@@ -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.");