From ab486ef4ebc98f4902fdf1233675841b67ab572a Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Tue, 18 May 2021 16:12:40 +0900 Subject: [PATCH] network: restart DHCP server on carrier gain --- src/network/networkd-dhcp-server.c | 10 ++++------ src/network/networkd-link.c | 6 ++++++ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/network/networkd-dhcp-server.c b/src/network/networkd-dhcp-server.c index 8d88464271f..e4af517c203 100644 --- a/src/network/networkd-dhcp-server.c +++ b/src/network/networkd-dhcp-server.c @@ -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; } diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c index 9aa69bdc732..6f2148501f9 100644 --- a/src/network/networkd-link.c +++ b/src/network/networkd-link.c @@ -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; }