Commit 629c9c5a authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3295] Implemented lease function which checks FQDN for equality.

Also, moved lease unit tests to a dedicated test file.
parent e9193122
......@@ -911,17 +911,14 @@ Dhcpv4Srv::createNameChangeRequests(const Lease4Ptr& lease,
// removal request for non-existent hostname.
// - A server has performed reverse, forward or both updates.
// - FQDN data between the new and old lease do not match.
if ((lease->hostname_ != old_lease->hostname_) ||
(lease->fqdn_fwd_ != old_lease->fqdn_fwd_) ||
(lease->fqdn_rev_ != old_lease->fqdn_rev_)) {
if (!lease->hasIdenticalFqdn(*old_lease)) {
queueNameChangeRequest(isc::dhcp_ddns::CHG_REMOVE,
old_lease);
// If FQDN data from both leases match, there is no need to update.
} else if ((lease->hostname_ == old_lease->hostname_) &&
(lease->fqdn_fwd_ == old_lease->fqdn_fwd_) &&
(lease->fqdn_rev_ == old_lease->fqdn_rev_)) {
} else if (lease->hasIdenticalFqdn(*old_lease)) {
return;
}
}
......
......@@ -1324,9 +1324,7 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
// that were set. If they aren't, we will have to remove existing
// DNS records and update the lease with the new settings.
if (!fake_allocation && old_lease &&
((lease->hostname_ != old_lease->hostname_) ||
(lease->fqdn_fwd_ != old_lease->fqdn_fwd_) ||
(lease->fqdn_rev_ != old_lease->fqdn_rev_))) {
!lease->hasIdenticalFqdn(*old_lease)) {
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL,
DHCP6_DDNS_LEASE_ASSIGN_FQDN_CHANGE)
.arg(old_lease->toText())
......
// Copyright (C) 2012-2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2012-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -56,6 +56,13 @@ bool Lease::expired() const {
return (expire_time < time(NULL));
}
bool
Lease::hasIdenticalFqdn(const Lease& other) const {
return (hostname_ == other.hostname_ &&
fqdn_fwd_ == other.fqdn_fwd_ &&
fqdn_rev_ == other.fqdn_rev_);
}
Lease4::Lease4(const Lease4& other)
: Lease(other.addr_, other.t1_, other.t2_, other.valid_lft_,
other.subnet_id_, other.cltt_, other.fqdn_fwd_,
......
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2014 Internet Systems Consortium, Inc. ("ISC")
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
......@@ -141,6 +141,14 @@ struct Lease {
/// @return true if the lease is expired
bool expired() const;
/// @brief Returns true if the other lease has equal FQDN data.
///
/// @param other Lease which FQDN data is to be compared with our lease.
///
/// @return Boolean value which indicates whether FQDN data of the other
/// lease is equal to the FQDN data of our lease (true) or not (false).
bool hasIdenticalFqdn(const Lease& other) const;
};
/// @brief Structure that holds a lease for IPv4 address
......
This diff is collapsed.
This diff is collapsed.
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