]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: check earlier the existence of lifetime in lease
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 7 Jun 2019 05:22:13 +0000 (14:22 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 7 Jun 2019 07:22:00 +0000 (16:22 +0900)
src/network/networkd-dhcp4.c

index ed196c446a1380d463ae689f1d4a45946edadcdb..9f820c1f4062ac253abf2e2159450c3f74fd1395 100644 (file)
@@ -509,6 +509,12 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
 
         prefixlen = in4_addr_netmask_to_prefixlen(&netmask);
 
+        if (!FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP)) {
+                r = sd_dhcp_lease_get_lifetime(lease, &lifetime);
+                if (r < 0)
+                        return log_link_warning_errno(link, r, "DHCP error: no lifetime: %m");
+        }
+
         r = sd_dhcp_lease_get_router(lease, &router);
         if (r < 0 && r != -ENODATA)
                 return log_link_error_errno(link, r, "DHCP error: Could not get gateway: %m");
@@ -582,12 +588,6 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
                 }
         }
 
-        if (!FLAGS_SET(link->network->keep_configuration, KEEP_CONFIGURATION_DHCP)) {
-                r = sd_dhcp_lease_get_lifetime(link->dhcp_lease, &lifetime);
-                if (r < 0)
-                        return log_link_warning_errno(link, r, "DHCP error: no lifetime: %m");
-        }
-
         r = dhcp4_update_address(link, &address, &netmask, lifetime);
         if (r < 0) {
                 log_link_warning_errno(link, r, "Could not update IP address: %m");