summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-link.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index 66bcb6bacf..aa23bfbc99 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -507,9 +507,14 @@ static int dhcp_lease_lost(Link *link) {
}
if (link->network->dhcp_hostname) {
- r = set_hostname(link->manager->bus, "");
- if (r < 0)
- log_error("Failed to reset transient hostname");
+ const char *hostname = NULL;
+
+ r = sd_dhcp_lease_get_hostname(link->dhcp_lease, &hostname);
+ if (r >= 0 && hostname) {
+ r = set_hostname(link->manager->bus, "");
+ if (r < 0)
+ log_error("Failed to reset transient hostname");
+ }
}
link->dhcp_lease = sd_dhcp_lease_unref(link->dhcp_lease);