BIND 10 trac3151, updated. b5f8586097eb7bb1961fce2c767a71f534923d2b [3151] Addressed review comments.
BIND 10 source code commits
bind10-changes at lists.isc.org
Thu Sep 26 19:01:01 UTC 2013
The branch, trac3151 has been updated
via b5f8586097eb7bb1961fce2c767a71f534923d2b (commit)
from f67708b12cc011dcaa6a6352792b42f154527bec (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 b5f8586097eb7bb1961fce2c767a71f534923d2b
Author: Thomas Markwalder <tmark at isc.org>
Date: Thu Sep 26 14:57:16 2013 -0400
[3151] Addressed review comments.
Added additional unit tests, a starter section to
the user's guide for b10-dhcp6 prefix delegation
configuration and various cleanup.
-----------------------------------------------------------------------
Summary of changes:
doc/guide/bind10-guide.xml | 21 ++++++
src/bin/dhcp6/config_parser.cc | 15 +++++
src/bin/dhcp6/tests/config_parser_unittest.cc | 80 ++++++++++++++++++++++-
src/bin/dhcp6/tests/test_data_files_config.h.in | 8 ++-
4 files changed, 122 insertions(+), 2 deletions(-)
-----------------------------------------------------------------------
diff --git a/doc/guide/bind10-guide.xml b/doc/guide/bind10-guide.xml
index 6c538cd..83c50b6 100644
--- a/doc/guide/bind10-guide.xml
+++ b/doc/guide/bind10-guide.xml
@@ -4725,6 +4725,27 @@ Dhcp6/subnet6/ list
</para>
</section>
+ <section>
+<!-- @todo: add real meat to the prefix delegation config this is just place holder stuff -->
+ <title>Subnet and Prefix Delegation Pools</title>
+ <para>
+ Subnets may also be configured to delegate address prefixes....
+ A subnet may have one or more prefix delegation pools. Each pool has
+ a prefixed address, which is specified as a prefix and a prefix length,
+ as well as a delegated prefix length. A sample configuration is shown
+ below:
+ <screen>
+> <userinput>config add Dhcp6/subnet6</userinput>
+> <userinput>config set Dhcp6/subnet6[0]/subnet "2001:db8:1::/64"</userinput>
+> <userinput>config show Dhcp6/subnet6[0]</userinput>
+> <userinput>config add Dhcp6/subnet6[0]/pd-pools</userinput>
+> <userinput>config set Dhcp6/subnet6[0]/pd-pools[0]/prefix "2001:db8:1::"</userinput>
+> <userinput>config set Dhcp6/subnet6[0]/pd-pools[0]/prefix-len 64</userinput>
+> <userinput>config set Dhcp6/subnet6[0]/pd-pools[0]/delegated-len 96</userinput>
+> <userinput>config commit</userinput></screen>
+ </para>
+ </section>
+
<section id="dhcp6-std-options">
<title>Standard DHCPv6 options</title>
<para>
diff --git a/src/bin/dhcp6/config_parser.cc b/src/bin/dhcp6/config_parser.cc
index a31f73f..bc2e02c 100644
--- a/src/bin/dhcp6/config_parser.cc
+++ b/src/bin/dhcp6/config_parser.cc
@@ -166,6 +166,21 @@ protected:
}
};
+/// @brief Parser for IPv6 prefix delegation definitions.
+///
+/// This class handles prefix delegation pool definitions for IPv6 subnets
+/// Pool6 objects are created and stored in the given PoolStorage container.
+///
+/// PdPool defintions currently support three elements: prefix, prefix-len,
+/// and delegated-len, as shown in the example JSON text below:
+///
+/// {{{
+///
+/// {
+/// "prefix": "2001:db8:1::",
+/// "prefix-len": 64,
+/// "delegated-len": 128
+/// }
class PdPoolParser : public DhcpConfigParser {
public:
diff --git a/src/bin/dhcp6/tests/config_parser_unittest.cc b/src/bin/dhcp6/tests/config_parser_unittest.cc
index beed683..acfc270 100644
--- a/src/bin/dhcp6/tests/config_parser_unittest.cc
+++ b/src/bin/dhcp6/tests/config_parser_unittest.cc
@@ -22,6 +22,7 @@
#include <dhcp/option_int.h>
#include <dhcp6/config_parser.h>
#include <dhcp6/dhcp6_srv.h>
+#include <dhcpsrv/addr_utilities.h>
#include <dhcpsrv/cfgmgr.h>
#include <dhcpsrv/subnet.h>
#include <hooks/hooks_manager.h>
@@ -694,6 +695,8 @@ TEST_F(Dhcp6ParserTest, poolOutOfSubnet) {
// Goal of this test is to verify if pools can be defined
// using prefix/length notation. There is no separate test for min-max
// notation as it was tested in several previous tests.
+// Note this test also verifies that subnets can be configured without
+// prefix delegation pools.
TEST_F(Dhcp6ParserTest, poolPrefixLen) {
ConstElementPtr x;
@@ -775,9 +778,18 @@ TEST_F(Dhcp6ParserTest, pdPoolBasics) {
ASSERT_TRUE(p6);
EXPECT_EQ("2001:db8:1::", p6->getFirstAddress().toText());
EXPECT_EQ(128, p6->getLength());
+
+ // prefix-len is not directly accessible after pool construction, so
+ // verify that it was interpreted correctly by checking the last address
+ // value.
+ isc::asiolink::IOAddress prefixAddress("2001:db8:1::");
+ EXPECT_EQ(lastAddrInPrefix(prefixAddress, 64).toText(),
+ p6->getLastAddress().toText());
}
// Goal of this test is verify that a list of PD pools can be configured.
+// It also verifies that a subnet may be configured with both regular pools
+// and pd pools.
TEST_F(Dhcp6ParserTest, pdPoolList) {
ConstElementPtr x;
@@ -794,6 +806,7 @@ TEST_F(Dhcp6ParserTest, pdPoolList) {
"\"rebind-timer\": 2000, "
"\"renew-timer\": 1000, "
"\"subnet6\": [ { "
+ " \"pool\": [ \"2001:db8:1:04::/80\" ],"
" \"subnet\": \"2001:db8:1::/40\","
" \"pd-pools\": ["
" { \"prefix\": \"2001:db8:1:01::\", "
@@ -829,8 +842,12 @@ TEST_F(Dhcp6ParserTest, pdPoolList) {
instance().getSubnet6(IOAddress("2001:db8:1::5"));
ASSERT_TRUE(subnet);
- // Fetch the collection of PD pools. It should have 3 entries.
+ // Fetch the collection of NA pools. It should have 1 entry.
PoolCollection pc;
+ ASSERT_NO_THROW(pc = subnet->getPools(Lease::TYPE_NA));
+ EXPECT_EQ(1, pc.size());
+
+ // Fetch the collection of PD pools. It should have 3 entries.
ASSERT_NO_THROW(pc = subnet->getPools(Lease::TYPE_PD));
EXPECT_EQ(3, pc.size());
@@ -844,6 +861,67 @@ TEST_F(Dhcp6ParserTest, pdPoolList) {
}
}
+// Goal of this test is to verify the a whole prefix can be delegated and that
+// a whole subnet can be delegated.
+TEST_F(Dhcp6ParserTest, subnetAndPrefixDelegated) {
+
+ ConstElementPtr x;
+
+ // Define a single valid pd pool.
+ string config =
+ "{ \"interfaces\": [ \"*\" ],"
+ "\"preferred-lifetime\": 3000,"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"subnet6\": [ { "
+ " \"subnet\": \"2001:db8:1::/64\","
+ " \"pd-pools\": ["
+ " { \"prefix\": \"2001:db8:1::\", "
+ " \"prefix-len\": 64, "
+ " \"delegated-len\": 64"
+ " } ],"
+ "\"valid-lifetime\": 4000 }"
+ "] }";
+
+ // Convert the JSON string into Elements.
+ ElementPtr json;
+ ASSERT_NO_THROW(json = Element::fromJSON(config));
+
+ // Verify that DHCP6 configuration processing succeeds.
+ // Returned value must be non-empty ConstElementPtr to config result.
+ // rcode should be 0 which indicates successful configuration processing.
+ EXPECT_NO_THROW(x = configureDhcp6Server(srv_, json));
+ ASSERT_TRUE(x);
+ comment_ = parseAnswer(rcode_, x);
+ EXPECT_EQ(0, rcode_);
+
+ // Test that we can retrieve the subnet.
+ Subnet6Ptr subnet = CfgMgr::
+ instance().getSubnet6(IOAddress("2001:db8:1::5"));
+
+ ASSERT_TRUE(subnet);
+
+ // Fetch the collection of PD pools. It should have 1 entry.
+ PoolCollection pc;
+ ASSERT_NO_THROW(pc = subnet->getPools(Lease::TYPE_PD));
+ EXPECT_EQ(1, pc.size());
+
+ // Get a pointer to the pd pool instance, and verify its contents.
+ Pool6Ptr p6;
+ ASSERT_NO_THROW(p6 = boost::dynamic_pointer_cast<Pool6>(pc[0]));
+ ASSERT_TRUE(p6);
+ EXPECT_EQ("2001:db8:1::", p6->getFirstAddress().toText());
+ EXPECT_EQ(64, p6->getLength());
+
+ // prefix-len is not directly accessible after pool construction, so
+ // verify that it was interpreted correctly by checking the last address
+ // value.
+ isc::asiolink::IOAddress prefixAddress("2001:db8:1::");
+ EXPECT_EQ(lastAddrInPrefix(prefixAddress, 64).toText(),
+ p6->getLastAddress().toText());
+}
+
+
// Goal of this test is check for proper handling of invalid prefix delegation
// pool configuration. It uses an array of invalid configurations to check
// a variety of configuration errors.
diff --git a/src/bin/dhcp6/tests/test_data_files_config.h.in b/src/bin/dhcp6/tests/test_data_files_config.h.in
index edcc2ac..8b09164 100644
--- a/src/bin/dhcp6/tests/test_data_files_config.h.in
+++ b/src/bin/dhcp6/tests/test_data_files_config.h.in
@@ -1,4 +1,4 @@
-// Copyright (C) 2009 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013 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
@@ -14,4 +14,10 @@
/// @brief Path to DHCP6 source dir so tests against the dhcp6.spec file
/// can find it reliably.
+
+#ifndef TEST_DATA_FILES_CONFIG_H
+#define TEST_DATA_FILES_CONFIG_H
+
#define DHCP6_SRC_DIR "@abs_top_srcdir@/src/bin/dhcp6"
+
+#endif
More information about the bind10-changes
mailing list