]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network/nexthop: drop dependent routes on removal
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 16 Jan 2024 03:01:50 +0000 (12:01 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 25 Jan 2024 07:43:44 +0000 (16:43 +0900)
If a nexthop is removed, dependent routes are silently removed by the kernel.
Hence, networkd may be confused that routes that depends on the nexthop still
exist, and may fail to configure other routes or so.

This is the one for routes of 3cbbe8635a16f096a3b0eff993f7681401535605.

src/network/networkd-nexthop.c

index 67eba509d3364e3eccbb501c5fcf705063baaad9..07a971a0e9265b71e37c7ac56fe0d31643be5cb2 100644 (file)
@@ -12,6 +12,7 @@
 #include "networkd-network.h"
 #include "networkd-nexthop.h"
 #include "networkd-queue.h"
+#include "networkd-route.h"
 #include "networkd-route-util.h"
 #include "parse-util.h"
 #include "set.h"
@@ -489,7 +490,7 @@ static int nexthop_remove_dependents(NextHop *nexthop, Manager *manager) {
         assert(nexthop);
         assert(manager);
 
-        /* If a nexthop is removed, the kernel silently removes nexthops that depend on the
+        /* If a nexthop is removed, the kernel silently removes nexthops and routes that depend on the
          * removed nexthop. Let's remove them for safety (though, they are already removed in the kernel,
          * hence that should fail), and forget them. */
 
@@ -503,6 +504,10 @@ static int nexthop_remove_dependents(NextHop *nexthop, Manager *manager) {
                 RET_GATHER(r, nexthop_remove(nh, manager));
         }
 
+        Route *route;
+        SET_FOREACH(route, nexthop->routes)
+                RET_GATHER(r, route_remove(route, manager));
+
         return r;
 }