]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[3367] Set 0 ciaddr for DHCPOFFER and DHCPNAK.
authorMarcin Siodelski <marcin@isc.org>
Tue, 7 Oct 2014 14:07:48 +0000 (16:07 +0200)
committerMarcin Siodelski <marcin@isc.org>
Tue, 7 Oct 2014 14:07:48 +0000 (16:07 +0200)
src/bin/dhcp4/dhcp4_srv.cc

index 6d2d3a7c6545bec4d2acd32fae187904b7f17e76..7da29c032aa5923508030d9b8ff91d5a10f77a08 100644 (file)
@@ -507,6 +507,9 @@ Dhcpv4Srv::copyDefaultFields(const Pkt4Ptr& question, Pkt4Ptr& answer) {
     answer->setCiaddr(question->getCiaddr());
 
     answer->setSiaddr(IOAddress("0.0.0.0")); // explicitly set this to 0
+    // ciaddr is always 0, except for the Renew/Rebind state when it may
+    // be set to the ciaddr sent by the client.
+    answer->setCiaddr(IOAddress("0.0.0.0"));
     answer->setHops(question->getHops());
 
     // copy MAC address
@@ -1050,6 +1053,18 @@ Dhcpv4Srv::assignLease(const Pkt4Ptr& question, Pkt4Ptr& answer) {
 
         answer->setYiaddr(lease->addr_);
 
+        /// @todo The server should check what ciaddr the client has supplied
+        /// in ciaddr. Currently the ciaddr is ignored except for the subnet
+        /// selection. If the client supplied an invalid address, the server
+        /// will also return an invalid address here.
+        if (!fake_allocation) {
+            // If this is a renewing client it will set a ciaddr which the
+            // server may include in the response. If this is a new allocation
+            // the client will set ciaddr to 0 and this will also be propagated
+            // to the server's answer.
+            answer->setCiaddr(question->getCiaddr());
+        }
+
         // If there has been Client FQDN or Hostname option sent, but the
         // hostname is empty, it means that server is responsible for
         // generating the entire hostname for the client. The example of the