network/address: acquire address from DHCP server lease file

If the DHCP server on an interface is configured with its server
address is null, then let's reuse the previous server address if
possible.

Otherwise, if networkd is restarted or the host is rebooted, then
possibly new subnet is picked, and clients that already have addresses
in the previous subnet cannot access the server.

Prompted by https://github.com/systemd/systemd/pull/30021#discussion_r1518478633.
This commit is contained in:
Yu Watanabe
2024-03-18 22:33:14 +09:00
parent 88123aa21c
commit 7a89aeb138
4 changed files with 54 additions and 1 deletions
+4
View File
@@ -1495,6 +1495,10 @@ static int address_acquire(Link *link, const Address *address, union in_addr_uni
assert(address);
assert(ret);
r = address_acquire_from_dhcp_server_leases_file(link, address, ret);
if (r != -ENOENT)
return r;
r = address_pool_acquire(link->manager, address->family, address->prefixlen, &a);
if (r < 0)
return r;