Commit dd8b2fdc authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3564] Fix failing unit tests after the updates to the allocation engine.

parent 64569e06
......@@ -957,14 +957,17 @@ Dhcpv4Srv::assignLease(const Pkt4Ptr& question, Pkt4Ptr& answer) {
OptionCustomPtr opt_serverid = boost::dynamic_pointer_cast<
// Try to get the Requested IP Address option and use the address as a hint
// for the allocation engine. If the server doesn't already have a lease
// for this client it will try to allocate the one requested.
// Check if the client has sent a requested IP address option or
// ciaddr.
OptionCustomPtr opt_requested_address = boost::dynamic_pointer_cast<
IOAddress hint("");
if (opt_requested_address) {
hint = opt_requested_address->readAddress();
} else if (question->getCiaddr() != IOAddress("")) {
hint = question->getCiaddr();
HWAddrPtr hwaddr = question->getHWAddr();
......@@ -283,10 +283,11 @@ void Dhcpv4SrvTest::checkAddressParams(const Pkt4Ptr& rsp,
void Dhcpv4SrvTest::checkResponse(const Pkt4Ptr& rsp, uint8_t expected_message_type,
void Dhcpv4SrvTest::checkResponse(const Pkt4Ptr& rsp, int expected_message_type,
uint32_t expected_transid) {
EXPECT_EQ(expected_message_type, rsp->getType());
EXPECT_EQ(expected_transid, rsp->getTransid());
......@@ -307,7 +307,7 @@ public:
/// @param rsp response packet to be validated
/// @param expected_message_type expected message type
/// @param expected_transid expected transaction-id
void checkResponse(const Pkt4Ptr& rsp, uint8_t expected_message_type,
void checkResponse(const Pkt4Ptr& rsp, int expected_message_type,
uint32_t expected_transid);
/// @brief Checks if the lease sent to client is present in the database
......@@ -1027,8 +1027,17 @@ AllocEngine::reallocateClientLease(Lease4Ptr& lease,
// Save the old lease, before renewal.
ctx.old_lease_.reset(new Lease4(*lease));
/// The client's address will need to be modified in case if:
/// - There is a reservation for the client (likely new one) and
/// the currently used address is different.
/// - Client requested some IP address and the requested address
/// is different than the currently used one. Note that if this
/// is a DHCPDISCOVER the requested IP address is ignored when
/// it doesn't match the one in use.
if ((ctx.host_ && (ctx.host_->getIPv4Reservation() != lease->addr_)) ||
(lease->addr_ != ctx.requested_address_)) {
(!ctx.fake_allocation_ &&
(ctx.requested_address_ != IOAddress("")) &&
(lease->addr_ != ctx.requested_address_))) {
lease = replaceClientLease(lease, ctx);
return (lease);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment