From: Yu Watanabe Date: Thu, 27 Jan 2022 18:50:16 +0000 (+0900) Subject: sd-dhcp-server: do not assign an address from pool when a static lease for the client... X-Git-Tag: v251-rc1~396^2~10 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e2ba408084935fffa0c73007528de7babf9309c8;p=thirdparty%2Fsystemd.git sd-dhcp-server: do not assign an address from pool when a static lease for the client ID exists --- diff --git a/src/libsystemd-network/sd-dhcp-server.c b/src/libsystemd-network/sd-dhcp-server.c index 820bec888eb..ddcd6910e90 100644 --- a/src/libsystemd-network/sd-dhcp-server.c +++ b/src/libsystemd-network/sd-dhcp-server.c @@ -1091,9 +1091,13 @@ int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message, siz if (address == server->address) return 0; - /* verify that the requested address is from the pool, and either - owned by the current client or free */ - if (static_lease && static_lease->address == address) { + if (static_lease) { + /* Found a static lease for the client ID. */ + + if (static_lease->address != address) + /* The client requested an address which is different from the static lease. Refuse. */ + return server_send_nak_or_ignore(server, init_reboot, req); + _cleanup_(dhcp_lease_freep) DHCPLease *lease = NULL; usec_t time_now, expiration;