From: Marcin Siodelski Date: Tue, 7 Oct 2014 14:07:48 +0000 (+0200) Subject: [3367] Set 0 ciaddr for DHCPOFFER and DHCPNAK. X-Git-Tag: trac3162a_base~8^2~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=8b58be9b2fe8eecaa346d1861f1b77bcf3caa403;p=thirdparty%2Fkea.git [3367] Set 0 ciaddr for DHCPOFFER and DHCPNAK. --- diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc index 6d2d3a7c65..7da29c032a 100644 --- a/src/bin/dhcp4/dhcp4_srv.cc +++ b/src/bin/dhcp4/dhcp4_srv.cc @@ -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