]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: dhcp4: reset counter only when the lease address is new
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 27 Aug 2020 21:54:11 +0000 (06:54 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 4 Sep 2020 00:05:45 +0000 (09:05 +0900)
src/network/networkd-dhcp4.c

index 771001f84d46da198f32069fdd4abdaf98e58be1..4a4ccd3dd0ccc9fd5031db391bf9d2ce08cbe075 100644 (file)
@@ -656,6 +656,7 @@ static int configure_dhcpv4_duplicate_address_detection(Link *link) {
 
 static int dhcp4_start_acd(Link *link) {
         union in_addr_union addr;
+        struct in_addr old;
         int r;
 
         if (!link->network->dhcp_send_decline)
@@ -672,6 +673,10 @@ static int dhcp4_start_acd(Link *link) {
         if (r < 0)
                 return r;
 
+        r = sd_ipv4acd_get_address(link->network->dhcp_acd, &old);
+        if (r < 0)
+                return r;
+
         r = sd_ipv4acd_set_address(link->network->dhcp_acd, &addr.in);
         if (r < 0)
                 return r;
@@ -687,7 +692,7 @@ static int dhcp4_start_acd(Link *link) {
                 log_link_debug(link, "Starting IPv4ACD client. Probing DHCPv4 address %s", strna(pretty));
         }
 
-        r = sd_ipv4acd_start(link->network->dhcp_acd, true);
+        r = sd_ipv4acd_start(link->network->dhcp_acd, !in4_addr_equal(&addr.in, &old));
         if (r < 0)
                 return r;