]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: introduce link_drop_routes()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Oct 2020 00:40:31 +0000 (09:40 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 6 Oct 2020 17:44:42 +0000 (02:44 +0900)
src/network/networkd-link.c
src/network/networkd-route.c
src/network/networkd-route.h

index b9053ad65936520b351536334a2764560298110c..dea1e723c3c271101e61824ea152f4ea553873bb 100644 (file)
@@ -2637,7 +2637,6 @@ static int remove_static_address_handler(sd_netlink *rtnl, sd_netlink_message *m
 
 static int link_drop_config(Link *link) {
         Address *address, *pool_address;
-        Route *route;
         int r;
 
         SET_FOREACH(address, link->addresses) {
@@ -2664,15 +2663,9 @@ static int link_drop_config(Link *link) {
         if (r < 0)
                 return r;
 
-        SET_FOREACH(route, link->routes) {
-                /* do not touch routes managed by the kernel */
-                if (route->protocol == RTPROT_KERNEL)
-                        continue;
-
-                r = route_remove(route, link, NULL);
-                if (r < 0)
-                        return r;
-        }
+        r = link_drop_routes(link);
+        if (r < 0)
+                return r;
 
         ndisc_flush(link);
 
index d7ec9097b393fa089b8b00a15eddcc1e6cb76ecb..87006a6c447f30267a8e748ae2819fec100e0934 100644 (file)
@@ -566,6 +566,25 @@ int link_drop_foreign_routes(Link *link) {
         return r;
 }
 
+int link_drop_routes(Link *link) {
+        Route *route;
+        int k, r = 0;
+
+        assert(link);
+
+        SET_FOREACH(route, link->routes) {
+                /* do not touch routes managed by the kernel */
+                if (route->protocol == RTPROT_KERNEL)
+                        continue;
+
+                k = route_remove(route, link, NULL);
+                if (k < 0 && r >= 0)
+                        r = k;
+        }
+
+        return r;
+}
+
 int route_expire_handler(sd_event_source *s, uint64_t usec, void *userdata) {
         Route *route = userdata;
         int r;
index d362298294629e2356e069b90a7a200ef4f05eac..d5760a96a6f6e26f924d443991f72714793142f9 100644 (file)
@@ -72,6 +72,7 @@ int route_configure(Route *route, Link *link, link_netlink_message_handler_t cal
 int route_remove(Route *route, Link *link, link_netlink_message_handler_t callback);
 
 int link_set_routes(Link *link);
+int link_drop_routes(Link *link);
 int link_drop_foreign_routes(Link *link);
 
 int manager_rtnl_process_route(sd_netlink *rtnl, sd_netlink_message *message, Manager *m);