BIND 10 trac3295_2, updated. 05755b228e2dee87eca0deb10a913bce60edf135 [3295] Generate NCR for the first address handed to the client.
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Jan 27 09:11:03 UTC 2014
The branch, trac3295_2 has been updated
via 05755b228e2dee87eca0deb10a913bce60edf135 (commit)
via 17480c30c5f959e2ccda004819979bcd503bdc94 (commit)
from 74cd52de51b075db9cffac32b48fa8e614d4460e (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 05755b228e2dee87eca0deb10a913bce60edf135
Author: Marcin Siodelski <marcin at isc.org>
Date: Fri Jan 24 14:04:03 2014 +0100
[3295] Generate NCR for the first address handed to the client.
commit 17480c30c5f959e2ccda004819979bcd503bdc94
Author: Marcin Siodelski <marcin at isc.org>
Date: Fri Jan 24 13:54:06 2014 +0100
[3295] Added a unit test which checks NCR generation for expired leases.
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp6/dhcp6_srv.cc | 10 ++++-
src/bin/dhcp6/tests/fqdn_unittest.cc | 69 ++++++++++++++++++++++++++++++++++
src/lib/dhcpsrv/alloc_engine.cc | 5 +++
3 files changed, 82 insertions(+), 2 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index 490cce7..4663f30 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -1087,8 +1087,8 @@ Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer) {
OptionCollection answer_ias = answer->getOptions(D6O_IA_NA);
for (OptionCollection::const_iterator answer_ia =
answer_ias.begin(); answer_ia != answer_ias.end(); ++answer_ia) {
- // @todo IA_NA may contain multiple addresses. We should process
- // each address individually. Currently we get only one.
+ /// @todo IA_NA may contain multiple addresses. We should process
+ /// each address individually. Currently we get only one.
Option6IAAddrPtr iaaddr = boost::static_pointer_cast<
Option6IAAddr>(answer_ia->second->getOption(D6O_IAADDR));
// We need an address to create a name-to-address mapping.
@@ -1114,6 +1114,12 @@ Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer) {
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL,
DHCP6_DDNS_CREATE_ADD_NAME_CHANGE_REQUEST).arg(ncr.toText());
+
+ /// @todo Currently we create NCR with the first IPv6 address that
+ /// is carried in one of the IA_NAs. In the future, the NCR API should
+ /// be extended to map multiple IPv6 addresses to a single FQDN.
+ /// In such case, this return statement will be removed.
+ return;
}
}
diff --git a/src/bin/dhcp6/tests/fqdn_unittest.cc b/src/bin/dhcp6/tests/fqdn_unittest.cc
index fe22338..bba8fc0 100644
--- a/src/bin/dhcp6/tests/fqdn_unittest.cc
+++ b/src/bin/dhcp6/tests/fqdn_unittest.cc
@@ -772,4 +772,73 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestWithoutFqdn) {
0, 4000);
}
+// Checks that when the server reuses expired lease, the NameChangeRequest
+// is generated to remove the DNS mapping for the expired lease and second
+// NameChangeRequest to add a DNS mapping for a new lease.
+TEST_F(FqdnDhcpv6SrvTest, processRequestReuseExpiredLease) {
+ // This address will be used throughout the test.
+ IOAddress addr("2001:db8:1:1::dead:beef");
+ // We are going to configure a subnet with a pool that consists of
+ // exactly one address. This address will be handed out to the
+ // client, will get expired and then be reused.
+ CfgMgr::instance().deleteSubnets6();
+ subnet_ = Subnet6Ptr(new Subnet6(IOAddress("2001:db8:1:1::"), 56, 1, 2,
+ 3, 4));
+ pool_ = Pool6Ptr(new Pool6(Lease::TYPE_NA, addr, addr));
+ subnet_->addPool(pool_);
+ CfgMgr::instance().addSubnet6(subnet_);
+
+ // Allocate a lease.
+ NakedDhcpv6Srv srv(0);
+ testProcessMessage(DHCPV6_REQUEST, "myhost.example.com", srv);
+ // Test that the appropriate NameChangeRequest has been generated.
+ ASSERT_EQ(1, srv.name_change_reqs_.size());
+ verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ "2001:db8:1:1::dead:beef",
+ "000201415AA33D1187D148275136FA30300478"
+ "FAAAA3EBD29826B5C907B2C9268A6F52",
+ 0, 4);
+ // Get the lease acquired and modify it. In particular, expire it.
+ Lease6Ptr lease =
+ LeaseMgrFactory::instance().getLease6(Lease::TYPE_NA, addr);
+ ASSERT_TRUE(lease);
+ // One of the following: IAID, DUID or subnet identifier has to be changed
+ // because otherwise the allocation engine will treat the lease as
+ // being renewed by the same client. If we at least change subnet identifier
+ // the lease will be treated as expired lease to be reused.
+ ++lease->subnet_id_;
+
+ // Move the cllt back in time and make sure that the lease got expired.
+ lease->cltt_ = time(NULL) - 10;
+ lease->valid_lft_ = 5;
+ ASSERT_TRUE(lease->expired());
+ // Change the hostname so as the name change request for removing existing
+ // DNS mapping is generated.
+ lease->hostname_ = "otherhost.example.com.";
+ // Update the lease in the lease database.
+ LeaseMgrFactory::instance().updateLease6(lease);
+
+ // Simulate another lease acquisition. Since, our pool consists of
+ // exactly one address and this address is used by the lease in the
+ // lease database, it is guaranteed that the allocation engine will
+ // reuse this lease.
+ testProcessMessage(DHCPV6_REQUEST, "myhost.example.com.", srv);
+ ASSERT_EQ(2, srv.name_change_reqs_.size());
+ // The first name change request generated, should remove a DNS
+ // mapping for an expired lease.
+ verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_REMOVE, true, true,
+ "2001:db8:1:1::dead:beef",
+ "000201D422AA463306223D269B6CB7AFE7AAD2"
+ "65FCEA97F93623019B2E0D14E5323D5A",
+ 0, 5);
+ // The second name change request should add a DNS mapping for
+ // a new lease.
+ verifyNameChangeRequest(srv, isc::dhcp_ddns::CHG_ADD, true, true,
+ "2001:db8:1:1::dead:beef",
+ "000201415AA33D1187D148275136FA30300478"
+ "FAAAA3EBD29826B5C907B2C9268A6F52",
+ 0, 4);
+
+}
+
} // end of anonymous namespace
diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc
index 180eae9..a154cc6 100644
--- a/src/lib/dhcpsrv/alloc_engine.cc
+++ b/src/lib/dhcpsrv/alloc_engine.cc
@@ -442,6 +442,11 @@ AllocEngine::allocateLeases6(const Subnet6Ptr& subnet, const DuidPtr& duid,
// allocation attempts.
} else {
if (existing->expired()) {
+ // Copy an existing, expired lease so as it can be returned
+ // to the caller.
+ Lease6Ptr old_lease(new Lease6(*lease));
+ old_leases.push_back(old_lease);
+
existing = reuseExpiredLease(existing, subnet, duid, iaid,
prefix_len, fwd_dns_update,
rev_dns_update, hostname,
More information about the bind10-changes
mailing list