]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: restart DHCP server on carrier gain
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 18 May 2021 07:12:40 +0000 (16:12 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 7 Jun 2021 21:33:27 +0000 (06:33 +0900)
src/network/networkd-dhcp-server.c
src/network/networkd-link.c

index 8d88464271faf602f0b1b3291b4c8f7da0ac5e84..e4af517c20350161388f7798a04f3d95585969d4 100644 (file)
@@ -445,13 +445,11 @@ static int dhcp4_server_configure(Link *link) {
                         return log_link_error_errno(link, r, "Failed to set DHCPv4 static lease for DHCP server: %m");
         }
 
-        if (!sd_dhcp_server_is_running(link->dhcp_server)) {
-                r = sd_dhcp_server_start(link->dhcp_server);
-                if (r < 0)
-                        return log_link_error_errno(link, r, "Could not start DHCPv4 server instance: %m");
+        r = sd_dhcp_server_start(link->dhcp_server);
+        if (r < 0)
+                return log_link_error_errno(link, r, "Could not start DHCPv4 server instance: %m");
 
-                log_link_debug(link, "Offering DHCPv4 leases");
-        }
+        log_link_debug(link, "Offering DHCPv4 leases");
 
         return 1;
 }
index 9aa69bdc732e608304db6d205491571e9b9b7ed2..6f2148501f959f6e10d26a8707973c2b71b52c72 100644 (file)
@@ -1209,6 +1209,12 @@ static int link_acquire_ipv4_conf(Link *link) {
                         return log_link_warning_errno(link, r, "Could not acquire IPv4 link-local address: %m");
         }
 
+        if (link->dhcp_server) {
+                r = sd_dhcp_server_start(link->dhcp_server);
+                if (r < 0)
+                        return log_link_warning_errno(link, r, "Could not start DHCP server: %m");
+        }
+
         return 0;
 }