]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: dhcp4: also release old lease in dhcp_lease_lost()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 16 Jul 2020 01:12:18 +0000 (10:12 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 16 Jul 2020 01:51:46 +0000 (10:51 +0900)
The lease lost may happen during renewing address. If it happens,
assertion hits in dhcp4_release_old_lease().

src/network/networkd-dhcp4.c
src/network/networkd-dhcp4.h
src/network/networkd-link.c

index bad7970e2ba3bea96536a3cbd41a0656f320537f..fd26be18fdb371c4c241250d3fc08061abaab962 100644 (file)
@@ -27,7 +27,7 @@ static int dhcp_remove_address(Link *link, sd_dhcp_lease *lease, const struct in
 static int dhcp4_update_address(Link *link, bool announce);
 static int dhcp4_remove_all(Link *link);
 
-void dhcp4_release_old_lease(Link *link) {
+static void dhcp4_release_old_lease(Link *link) {
         struct in_addr address = {}, address_old = {};
 
         assert(link);
@@ -793,6 +793,9 @@ static int dhcp_lease_lost(Link *link) {
 
         link->dhcp4_configured = false;
 
+        /* dhcp_lease_lost() may be called during renewing IP address. */
+        dhcp4_release_old_lease(link);
+
         r = dhcp4_remove_all(link);
         if (r < 0)
                 return r;
index 96ac696ce6ec53a027d03a79b2031acdf3d09c54..7a80897ffcdd6e9f0bca2fd85ccee313474712cd 100644 (file)
@@ -17,7 +17,6 @@ typedef enum DHCPClientIdentifier {
         _DHCP_CLIENT_ID_INVALID = -1,
 } DHCPClientIdentifier;
 
-void dhcp4_release_old_lease(Link *link);
 int dhcp4_configure(Link *link);
 int dhcp4_set_client_identifier(Link *link);
 int dhcp4_set_promote_secondaries(Link *link);
index 91ec95901164c39ad5133270b4e1b299c2f09395..2184a326e13360e44806f940fb7b9c1dd4ef6583 100644 (file)
@@ -800,8 +800,6 @@ int link_stop_clients(Link *link, bool may_keep_dhcp) {
         assert(link->manager);
         assert(link->manager->event);
 
-        dhcp4_release_old_lease(link);
-
         bool keep_dhcp = may_keep_dhcp &&
                          link->network &&
                          (link->manager->restarting ||