]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/route: unconditionally call route_setup_timer() for managed routes
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 9 Jan 2024 04:36:22 +0000 (13:36 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 12 Jan 2024 00:46:09 +0000 (09:46 +0900)
For foreign routes, we do not set lifetime, as it is foreign.
So, this should not change any behavior. Preparation for later commits.

src/network/networkd-route.c

index 4e7a12ce1cfb5f1ce5547180d6600ad8c9e9fa2a..78774f60ed8219c829033ecb5386ef92b9c94f6d 100644 (file)
@@ -1534,7 +1534,7 @@ static int process_route_one(
 
         _cleanup_(route_freep) Route *tmp = in;
         Route *route = NULL;
-        bool update_dhcp4;
+        bool is_new = false, update_dhcp4;
         int r;
 
         assert(manager);
@@ -1549,32 +1549,35 @@ static int process_route_one(
 
         switch (type) {
         case RTM_NEWROUTE:
-                if (route) {
-                        route->flags = tmp->flags;
-                        route_enter_configured(route);
-                        log_route_debug(route, "Received remembered", link, manager);
-
-                        r = route_setup_timer(route, cacheinfo);
-                        if (r < 0)
-                                log_link_warning_errno(link, r, "Failed to configure expiration timer for route, ignoring: %m");
-                        if (r > 0)
-                                log_route_debug(route, "Configured expiration timer for", link, manager);
-
-                } else if (!manager->manage_foreign_routes) {
-                        route_enter_configured(tmp);
-                        log_route_debug(tmp, "Ignoring received", link, manager);
+                if (!route) {
+                        if (!manager->manage_foreign_routes) {
+                                route_enter_configured(tmp);
+                                log_route_debug(tmp, "Ignoring received", link, manager);
+                                return 0;
+                        }
 
-                } else {
-                        /* A route appeared that we did not request */
-                        route_enter_configured(tmp);
-                        log_route_debug(tmp, "Received new", link, manager);
+                        /* If we do not know the route, then save it. */
                         r = route_add(manager, link, tmp);
                         if (r < 0) {
                                 log_link_warning_errno(link, r, "Failed to remember foreign route, ignoring: %m");
                                 return 0;
                         }
-                        TAKE_PTR(tmp);
-                }
+
+                        route = TAKE_PTR(tmp);
+                        is_new = true;
+
+                } else
+                        /* Update remembered route with the received notification. */
+                        route->flags = tmp->flags;
+
+                route_enter_configured(route);
+                log_route_debug(route, is_new ? "Received new" : "Received remembered", link, manager);
+
+                r = route_setup_timer(route, cacheinfo);
+                if (r < 0)
+                        log_link_warning_errno(link, r, "Failed to configure expiration timer for route, ignoring: %m");
+                if (r > 0)
+                        log_route_debug(route, "Configured expiration timer for", link, manager);
 
                 break;