]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: dhcp4: return earlier on failure
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 8 Sep 2021 04:39:22 +0000 (13:39 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 14 Sep 2021 06:21:10 +0000 (15:21 +0900)
src/network/networkd-dhcp4.c

index d7c063267f34293ced69756b844f2ad1165263e9..31af7be71e22f0cba83abd040c96e0e96d86ace5 100644 (file)
@@ -135,6 +135,26 @@ static int dhcp4_after_route_configure(Request *req, void *object) {
         return 0;
 }
 
+static int dhcp4_retry(Link *link) {
+        int r;
+
+        assert(link);
+
+        r = dhcp4_remove_all(link);
+        if (r < 0)
+                return r;
+
+        r = link_request_static_nexthops(link, true);
+        if (r < 0)
+                return r;
+
+        r = link_request_static_routes(link, true);
+        if (r < 0)
+                return r;
+
+        return dhcp4_request_address_and_routes(link, false);
+}
+
 static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
         int r;
 
@@ -165,19 +185,7 @@ static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *li
                 link->dhcp4_route_failed = false;
                 link->dhcp4_route_retrying = true;
 
-                r = dhcp4_remove_all(link);
-                if (r < 0)
-                        link_enter_failed(link);
-
-                r = link_request_static_nexthops(link, true);
-                if (r < 0)
-                        link_enter_failed(link);
-
-                r = link_request_static_routes(link, true);
-                if (r < 0)
-                        link_enter_failed(link);
-
-                r = dhcp4_request_address_and_routes(link, false);
+                r = dhcp4_retry(link);
                 if (r < 0)
                         link_enter_failed(link);