BIND 10 trac2414, updated. ae8d436d86973d85dbf512ca39167b41dcdb6a7c [2414] dhcp6_srv tests now use defines from dhcp/duid.h
BIND 10 source code commits
bind10-changes at lists.isc.org
Tue Oct 30 17:57:34 UTC 2012
The branch, trac2414 has been updated
via ae8d436d86973d85dbf512ca39167b41dcdb6a7c (commit)
via ecaa3bfbcea80a640778d8f0629e7976d87bde92 (commit)
from bd3faa6a3d1d5628509b725ecb61ef91ee3c2bb0 (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 ae8d436d86973d85dbf512ca39167b41dcdb6a7c
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Tue Oct 30 18:56:19 2012 +0100
[2414] dhcp6_srv tests now use defines from dhcp/duid.h
commit ecaa3bfbcea80a640778d8f0629e7976d87bde92
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Tue Oct 30 18:31:41 2012 +0100
[2414] CfgMgr now returns a subnet if a client is local.
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp6/tests/dhcp6_srv_unittest.cc | 11 ++++++-----
src/lib/dhcp/cfgmgr.cc | 2 +-
src/lib/dhcp/tests/cfgmgr_unittest.cc | 23 +++++++++++++++++------
3 files changed, 24 insertions(+), 12 deletions(-)
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 2028706..457be1c 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -21,6 +21,7 @@
#include <gtest/gtest.h>
#include <dhcp/dhcp6.h>
+#include <dhcp/duid.h>
#include <dhcp/option6_ia.h>
#include <dhcp6/dhcp6_srv.h>
#include <util/buffer.h>
@@ -79,7 +80,7 @@ TEST_F(Dhcpv6SrvTest, DUID) {
boost::scoped_ptr<Dhcpv6Srv> srv;
ASSERT_NO_THROW( {
- srv.reset(new Dhcpv6Srv(DHCP6_SERVER_PORT + 10000));
+ srv.reset(new Dhcpv6Srv(0));
});
OptionPtr srvid = srv->getServerID();
@@ -101,7 +102,7 @@ TEST_F(Dhcpv6SrvTest, DUID) {
uint16_t duid_type = data.readUint16();
cout << "Duid-type=" << duid_type << endl;
switch(duid_type) {
- case DUID_LLT: {
+ case DUID::DUID_LLT: {
// DUID must contain at least 6 bytes long MAC
// + 8 bytes of fixed header
EXPECT_GE(14, len);
@@ -125,7 +126,7 @@ TEST_F(Dhcpv6SrvTest, DUID) {
EXPECT_TRUE(mac != zeros);
break;
}
- case DUID_EN: {
+ case DUID::DUID_EN: {
// there's not much we can check. Just simple
// check if it is not all zeros
vector<uint8_t> content(len-2);
@@ -133,7 +134,7 @@ TEST_F(Dhcpv6SrvTest, DUID) {
EXPECT_FALSE(isRangeZero(content.begin(), content.end()));
break;
}
- case DUID_LL: {
+ case DUID::DUID_LL: {
// not supported yet
cout << "Test not implemented for DUID-LL." << endl;
@@ -143,7 +144,7 @@ TEST_F(Dhcpv6SrvTest, DUID) {
// and keep it despite hardware changes.
break;
}
- case DUID_UUID: // not supported yet
+ case DUID::DUID_UUID: // not supported yet
default:
ADD_FAILURE() << "Not supported duid type=" << duid_type << endl;
break;
diff --git a/src/lib/dhcp/cfgmgr.cc b/src/lib/dhcp/cfgmgr.cc
index d06544c..5b40a2d 100644
--- a/src/lib/dhcp/cfgmgr.cc
+++ b/src/lib/dhcp/cfgmgr.cc
@@ -41,7 +41,7 @@ CfgMgr::getSubnet6(const isc::asiolink::IOAddress& hint) {
// configuration. Such requirement makes sense in IPv4, but not in IPv6.
// The server does not need to have a global address (using just link-local
// is ok for DHCPv6 server) from the pool it serves.
- if (subnets6_.size() == 1) {
+ if ( (subnets6_.size() == 1) && hint.getAddress().to_v6().is_link_local()) {
return (subnets6_[0]);
}
diff --git a/src/lib/dhcp/tests/cfgmgr_unittest.cc b/src/lib/dhcp/tests/cfgmgr_unittest.cc
index 9c3e367..fc330ea 100644
--- a/src/lib/dhcp/tests/cfgmgr_unittest.cc
+++ b/src/lib/dhcp/tests/cfgmgr_unittest.cc
@@ -32,13 +32,22 @@ using boost::scoped_ptr;
namespace {
+class CfgMgrTest : public ::testing::Test {
+public:
+ CfgMgrTest() {
+ }
+
+ ~CfgMgrTest() {
+ CfgMgr::instance().deleteSubnets6();
+ }
+};
+
+
// This test verifies if the configuration manager is able to hold and return
// valid leases
-TEST(CfgMgrTest, subnet4) {
+TEST_F(CfgMgrTest, subnet4) {
CfgMgr& cfg_mgr = CfgMgr::instance();
- ASSERT_TRUE(&cfg_mgr != 0);
-
Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3));
Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3));
Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3));
@@ -66,11 +75,9 @@ TEST(CfgMgrTest, subnet4) {
// This test verifies if the configuration manager is able to hold and return
// valid leases
-TEST(CfgMgrTest, subnet6) {
+TEST_F(CfgMgrTest, subnet6) {
CfgMgr& cfg_mgr = CfgMgr::instance();
- ASSERT_TRUE(&cfg_mgr != 0);
-
Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"), 48, 1, 2, 3, 4));
Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"), 48, 1, 2, 3, 4));
Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"), 48, 1, 2, 3, 4));
@@ -83,6 +90,10 @@ TEST(CfgMgrTest, subnet6) {
// Now we have only one subnet, any request will be served from it
EXPECT_EQ(subnet1, cfg_mgr.getSubnet6(IOAddress("2000::1")));
+ // If we have only a single subnet and the request came from a local
+ // address, let's use that subnet
+ EXPECT_EQ(subnet1, cfg_mgr.getSubnet6(IOAddress("fe80::dead:beef")));
+
cfg_mgr.addSubnet6(subnet2);
cfg_mgr.addSubnet6(subnet3);
More information about the bind10-changes
mailing list