]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sd-dhcp-server: do not assign an address from pool when a static lease for the client...
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 27 Jan 2022 18:50:16 +0000 (03:50 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 1 Feb 2022 02:56:22 +0000 (11:56 +0900)
src/libsystemd-network/sd-dhcp-server.c

index 820bec888ebc892cf9b444aa9125443700a629e0..ddcd6910e90f2e88afe7c655f181b989474bb8ad 100644 (file)
@@ -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;