summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bin/dhcp6/dhcp6_srv.cc8
-rw-r--r--src/bin/dhcp6/tests/dhcp6_srv_unittest.cc5
-rw-r--r--src/bin/dhcp6/tests/dhcp6_test_utils.cc66
-rw-r--r--src/bin/dhcp6/tests/dhcp6_test_utils.h34
-rw-r--r--src/lib/dhcpsrv/alloc_engine.h7
5 files changed, 73 insertions, 47 deletions
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index f55af9a6c8..036ba3035a 100644
--- a/src/bin/dhcp6/dhcp6_srv.cc
+++ b/src/bin/dhcp6/dhcp6_srv.cc
@@ -1686,6 +1686,10 @@ Dhcpv6Srv::extendIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid,
}
}
+ // Set up T1, T2 timers
+ ia_rsp->setT1(subnet->getT1());
+ ia_rsp->setT2(subnet->getT2());
+
// There is a subnet selected. Let's pick the lease.
Lease6Ptr lease =
LeaseMgrFactory::instance().getLease6(Lease::TYPE_PD,
@@ -1768,8 +1772,8 @@ Dhcpv6Srv::extendIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid,
}
(void)invalid_prefix;
-#if 0
bool skip = false;
+#if 0
// Execute all callouts registered for packet6_send
// Get the callouts specific for the processed message and execute them.
int hook_point = query->getType() == DHCPV6_RENEW ?
@@ -1796,6 +1800,7 @@ Dhcpv6Srv::extendIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid,
// Remember hook's instruction whether we want to skip update or not
skip = callout_handle->getSkip();
}
+#endif
if (!skip) {
// If the prefix specified by the client is wrong, we don't want to
@@ -1816,7 +1821,6 @@ Dhcpv6Srv::extendIA_PD(const Subnet6Ptr& subnet, const DuidPtr& duid,
// fields of returned Lease6Ptr, the actual updateLease6() is no-op.
*lease = old_data;
}
-#endif
return (ia_rsp);
}
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index fe13985e72..8efc923dc0 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -150,7 +150,8 @@ TEST_F(NakedDhcpv6SrvTest, RenewNoSubnet) {
Pkt6Ptr reply = srv.processRenew(req);
// check that we get the right NAK
- checkNakResponse (reply, DHCPV6_REPLY, 1234, STATUS_NoBinding);
+ checkNakResponse (reply, DHCPV6_REPLY, 1234, STATUS_NoBinding,
+ 0, 0);
}
// This test verifies that incoming RELEASE can be handled properly, even when
@@ -185,7 +186,7 @@ TEST_F(NakedDhcpv6SrvTest, ReleaseNoSubnet) {
Pkt6Ptr reply = srv.processRelease(req);
// check that we get the right NAK
- checkNakResponse (reply, DHCPV6_REPLY, 1234, STATUS_NoBinding);
+ checkNakResponse (reply, DHCPV6_REPLY, 1234, STATUS_NoBinding, 0, 0);
}
// Test verifies that the Dhcpv6_srv class can be instantiated. It checks a mode
diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.cc b/src/bin/dhcp6/tests/dhcp6_test_utils.cc
index a6ef85960c..eec0886e37 100644
--- a/src/bin/dhcp6/tests/dhcp6_test_utils.cc
+++ b/src/bin/dhcp6/tests/dhcp6_test_utils.cc
@@ -285,10 +285,10 @@ Dhcpv6SrvTest::testRenewBasic(Lease::Type type, const std::string& existing_addr
}
// Check that T1, T2, preferred, valid and cltt were really updated
- EXPECT_EQ(l->t1_, subnet_->getT1());
- EXPECT_EQ(l->t2_, subnet_->getT2());
- EXPECT_EQ(l->preferred_lft_, subnet_->getPreferred());
- EXPECT_EQ(l->valid_lft_, subnet_->getValid());
+ EXPECT_EQ(subnet_->getT1(), l->t1_);
+ EXPECT_EQ(subnet_->getT2(), l->t2_);
+ EXPECT_EQ(subnet_->getPreferred(), l->preferred_lft_);
+ EXPECT_EQ(subnet_->getValid(), l->valid_lft_);
// Checking for CLTT is a bit tricky if we want to avoid off by 1 errors
int32_t cltt = static_cast<int32_t>(l->cltt_);
@@ -457,7 +457,7 @@ Dhcpv6SrvTest::testReleaseBasic(Lease::Type type, const IOAddress& existing,
// Check that IA_NA was returned and that there's an address included
boost::shared_ptr<Option6IA> ia = boost::dynamic_pointer_cast<Option6IA>(tmp);
- checkIA_NAStatusCode(ia, STATUS_Success, subnet_->getT1(), subnet_->getT2());
+ checkIA_NAStatusCode(ia, STATUS_Success, 0, 0);
checkMsgStatusCode(reply, STATUS_Success);
// There should be no address returned in RELEASE (see RFC3315, 18.2.6)
@@ -528,7 +528,7 @@ Dhcpv6SrvTest::testReleaseReject(Lease::Type type, const IOAddress& addr) {
// Check that IA_NA/IA_PD was returned and that there's status code in it
boost::shared_ptr<Option6IA> ia = boost::dynamic_pointer_cast<Option6IA>(tmp);
ASSERT_TRUE(ia);
- checkIA_NAStatusCode(ia, STATUS_NoBinding, subnet_->getT1(), subnet_->getT2());
+ checkIA_NAStatusCode(ia, STATUS_NoBinding, 0, 0);
checkMsgStatusCode(reply, STATUS_NoBinding);
// Check that the lease is not there
@@ -556,7 +556,7 @@ Dhcpv6SrvTest::testReleaseReject(Lease::Type type, const IOAddress& addr) {
// Check that IA_?? was returned and that there's proper status code
ia = boost::dynamic_pointer_cast<Option6IA>(tmp);
ASSERT_TRUE(ia);
- checkIA_NAStatusCode(ia, STATUS_NoBinding);
+ checkIA_NAStatusCode(ia, STATUS_NoBinding, 0, 0);
checkMsgStatusCode(reply, STATUS_NoBinding);
// Check that the lease is still there
@@ -580,7 +580,7 @@ Dhcpv6SrvTest::testReleaseReject(Lease::Type type, const IOAddress& addr) {
// Check that IA_?? was returned and that there's proper status code
ia = boost::dynamic_pointer_cast<Option6IA>(tmp);
ASSERT_TRUE(ia);
- checkIA_NAStatusCode(ia, STATUS_NoBinding);
+ checkIA_NAStatusCode(ia, STATUS_NoBinding, 0, 0);
checkMsgStatusCode(reply, STATUS_NoBinding);
// Check that the lease is still there
@@ -651,6 +651,56 @@ Dhcpv6SrvTest::compareOptions(const isc::dhcp::OptionPtr& option1,
return (!memcmp(buf1.getData(), buf2.getData(), buf1.getLength()));
}
+void
+NakedDhcpv6SrvTest::checkIA_NAStatusCode(
+ const boost::shared_ptr<isc::dhcp::Option6IA>& ia,
+ uint16_t expected_status_code, uint32_t expected_t1, uint32_t expected_t2)
+{
+ // Make sure there is no address assigned. Depending on the situation,
+ // the server will either not return the address at all and sometimes
+ // it will return it with zeroed lifetimes.
+ dhcp::OptionCollection options = ia->getOptions();
+ for (isc::dhcp::OptionCollection::iterator opt = options.begin();
+ opt != options.end(); ++opt) {
+ if (opt->second->getType() != D6O_IAADDR) {
+ continue;
+ }
+
+ dhcp::Option6IAAddrPtr addr =
+ boost::dynamic_pointer_cast<isc::dhcp::Option6IAAddr>(opt->second);
+ ASSERT_TRUE(addr);
+
+ EXPECT_EQ(0, addr->getPreferred());
+ EXPECT_EQ(0, addr->getValid());
+ }
+
+ // T1, T2 should NOT be zeroed. draft-ietf-dhc-dhcpv6-stateful-issues-10,
+ // section 4.4.6 says says that T1,T2 should be consistent along all
+ // provided IA options.
+ EXPECT_EQ(expected_t1, ia->getT1());
+ EXPECT_EQ(expected_t2, ia->getT2());
+
+ isc::dhcp::OptionCustomPtr status =
+ boost::dynamic_pointer_cast<isc::dhcp::OptionCustom>
+ (ia->getOption(D6O_STATUS_CODE));
+
+ // It is ok to not include status success as this is the default
+ // behavior
+ if (expected_status_code == STATUS_Success && !status) {
+ return;
+ }
+
+ EXPECT_TRUE(status);
+
+ if (status) {
+ // We don't have dedicated class for status code, so let's
+ // just interpret first 2 bytes as status. Remainder of the
+ // status code option content is just a text explanation
+ // what went wrong.
+ EXPECT_EQ(static_cast<uint16_t>(expected_status_code),
+ status->readInteger<uint16_t>(0));
+ }
+}
}; // end of isc::test namespace
}; // end of isc namespace
diff --git a/src/bin/dhcp6/tests/dhcp6_test_utils.h b/src/bin/dhcp6/tests/dhcp6_test_utils.h
index 072cad39cc..6d758383d1 100644
--- a/src/bin/dhcp6/tests/dhcp6_test_utils.h
+++ b/src/bin/dhcp6/tests/dhcp6_test_utils.h
@@ -27,6 +27,7 @@
#include <dhcp/option6_iaprefix.h>
#include <dhcp/option_int_array.h>
#include <dhcp/option_custom.h>
+#include <dhcp/option.h>
#include <dhcp/iface_mgr.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/lease_mgr.h>
@@ -241,38 +242,7 @@ public:
void checkIA_NAStatusCode
(const boost::shared_ptr<isc::dhcp::Option6IA>& ia,
uint16_t expected_status_code, uint32_t expected_t1,
- uint32_t expected_t2)
- {
- // Make sure there is no address assigned.
- EXPECT_FALSE(ia->getOption(D6O_IAADDR));
-
- // T1, T2 should NOT be zeroed. draft-ietf-dhc-dhcpv6-stateful-issues-10,
- // section 4.4.6 says says that T1,T2 should be consistent along all
- // provided IA options.
- EXPECT_EQ(expected_t1, ia->getT1());
- EXPECT_EQ(expected_t2, ia->getT2());
-
- isc::dhcp::OptionCustomPtr status =
- boost::dynamic_pointer_cast<isc::dhcp::OptionCustom>
- (ia->getOption(D6O_STATUS_CODE));
-
- // It is ok to not include status success as this is the default
- // behavior
- if (expected_status_code == STATUS_Success && !status) {
- return;
- }
-
- EXPECT_TRUE(status);
-
- if (status) {
- // We don't have dedicated class for status code, so let's
- // just interpret first 2 bytes as status. Remainder of the
- // status code option content is just a text explanation
- // what went wrong.
- EXPECT_EQ(static_cast<uint16_t>(expected_status_code),
- status->readInteger<uint16_t>(0));
- }
- }
+ uint32_t expected_t2);
void checkMsgStatusCode(const isc::dhcp::Pkt6Ptr& msg,
uint16_t expected_status)
diff --git a/src/lib/dhcpsrv/alloc_engine.h b/src/lib/dhcpsrv/alloc_engine.h
index 91a1d05cb4..e86c3ad5a8 100644
--- a/src/lib/dhcpsrv/alloc_engine.h
+++ b/src/lib/dhcpsrv/alloc_engine.h
@@ -400,7 +400,8 @@ protected:
ClientContext6()
: subnet_(), duid_(), iaid_(0), type_(Lease::TYPE_NA), hwaddr_(),
hints_(), fwd_dns_update_(false), rev_dns_update_(false), hostname_(""),
- callout_handle_(), fake_allocation_(false), old_leases_(), host_() {
+ callout_handle_(), fake_allocation_(false), old_leases_(), host_(),
+ query_(), ia_rsp_() {
}
/// @brief Constructor with parameters.
@@ -430,8 +431,8 @@ protected:
fake_allocation):
subnet_(subnet), duid_(duid), iaid_(iaid), type_(type), hwaddr_(),
hints()_, fwd_dns_update_(fwd_dns), rev_dns_update_(rev_dns),
- hostname_(hostname), fake_allocation_(fake_allocation), old_leases_(),
- host_() {
+ hostname_(hostname), fake_allocation_(fake_allocation),
+ old_leases_(), host_(), query_(), ia_rsp_() {
static asiolink::IOAddress any("::");