]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: dhcp4: re-request DHCP4 address and routes immediately
authorYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 17 May 2021 06:57:11 +0000 (15:57 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 19 May 2021 01:38:57 +0000 (10:38 +0900)
It is not necessary to wait for removal is finished, as network queue
already do the same thing.

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

index abb37a3d26ae8d3e516a4f2644b0da9f944e7bf1..261c6501ea8134937b9cc954e958b55cee9e5fac 100644 (file)
@@ -180,6 +180,10 @@ static int dhcp4_route_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *li
                 if (r < 0)
                         link_enter_failed(link);
 
+                r = dhcp4_request_address_and_routes(link, false);
+                if (r < 0)
+                        link_enter_failed(link);
+
                 return 1;
         }
 
@@ -712,48 +716,6 @@ static int dhcp_reset_hostname(Link *link) {
         return 0;
 }
 
-static int dhcp4_route_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
-        int r;
-
-        assert(link);
-        assert(link->dhcp4_remove_messages > 0);
-
-        link->dhcp4_remove_messages--;
-
-        r = link_route_remove_handler_internal(rtnl, m, link, "Failed to remove DHCPv4 route, ignoring");
-        if (r <= 0)
-                return r;
-
-        if (link->dhcp4_remove_messages == 0) {
-                r = dhcp4_request_address_and_routes(link, false);
-                if (r < 0)
-                        link_enter_failed(link);
-        }
-
-        return 1;
-}
-
-static int dhcp4_address_remove_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
-        int r;
-
-        assert(link);
-        assert(link->dhcp4_remove_messages > 0);
-
-        link->dhcp4_remove_messages--;
-
-        r = address_remove_handler_internal(rtnl, m, link, "Failed to remove DHCPv4 address, ignoring");
-        if (r <= 0)
-                return r;
-
-        if (link->dhcp4_remove_messages == 0) {
-                r = dhcp4_request_address_and_routes(link, false);
-                if (r < 0)
-                        link_enter_failed(link);
-        }
-
-        return 1;
-}
-
 static int dhcp4_remove_all(Link *link) {
         Route *route;
         int k, r = 0;
@@ -761,19 +723,15 @@ static int dhcp4_remove_all(Link *link) {
         assert(link);
 
         SET_FOREACH(route, link->dhcp_routes) {
-                k = route_remove(route, NULL, link, dhcp4_route_remove_handler);
+                k = route_remove(route, NULL, link, NULL);
                 if (k < 0)
                         r = k;
-                else
-                        link->dhcp4_remove_messages++;
         }
 
         if (link->dhcp_address) {
-                k = address_remove(link->dhcp_address, link, dhcp4_address_remove_handler);
+                k = address_remove(link->dhcp_address, link, NULL);
                 if (k < 0)
                         r = k;
-                else
-                        link->dhcp4_remove_messages++;
         }
 
         return r;
index fbc593f124ee0c8eb8ad8337472118e29a82ff50..4223bd351b751ebfed95fe9a67c877e85dca65f6 100644 (file)
@@ -111,7 +111,6 @@ typedef struct Link {
         char *lease_file;
         uint32_t original_mtu;
         unsigned dhcp4_messages;
-        unsigned dhcp4_remove_messages;
         sd_ipv4acd *dhcp_acd;
         bool dhcp4_route_failed:1;
         bool dhcp4_route_retrying:1;