BIND 10 trac3242, updated. 4f3dc5a36ac27e91e785eb94c9de1b4798477940 [3242] DHCPv4 server selects subnet for direct client using iface IP addr.
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Jan 31 18:43:25 UTC 2014
The branch, trac3242 has been updated
via 4f3dc5a36ac27e91e785eb94c9de1b4798477940 (commit)
via abb2b61c859ff5b584a1ec75203e2e4d6914457a (commit)
via f4548b2768162c8748665d190e288bc87327dde1 (commit)
from f1fabbe371b1905707e19e564443327dbb94114f (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 4f3dc5a36ac27e91e785eb94c9de1b4798477940
Author: Marcin Siodelski <marcin at isc.org>
Date: Fri Jan 31 19:43:07 2014 +0100
[3242] DHCPv4 server selects subnet for direct client using iface IP addr.
commit abb2b61c859ff5b584a1ec75203e2e4d6914457a
Author: Marcin Siodelski <marcin at isc.org>
Date: Fri Jan 31 19:29:08 2014 +0100
[3242] Removed unused constant pointing to file carrying server id.
commit f4548b2768162c8748665d190e288bc87327dde1
Author: Marcin Siodelski <marcin at isc.org>
Date: Fri Jan 31 14:10:44 2014 +0100
[3242] Implement function which returns subnet for the interface.
This function replaces the one that checked whether there is a subnet for
an interface and returns boolean value.
-----------------------------------------------------------------------
Summary of changes:
src/bin/dhcp4/dhcp4_srv.cc | 9 +-
src/bin/dhcp4/tests/Makefile.am | 2 +
src/bin/dhcp4/tests/dhcp4_test_utils.cc | 9 -
src/bin/dhcp4/tests/dhcp4_test_utils.h | 1 -
src/bin/dhcp4/tests/direct_client_unittest.cc | 237 +++++++++++++++++++++++++
src/lib/dhcpsrv/cfgmgr.cc | 30 ++--
src/lib/dhcpsrv/cfgmgr.h | 16 +-
src/lib/dhcpsrv/tests/cfgmgr_unittest.cc | 33 +++-
8 files changed, 292 insertions(+), 45 deletions(-)
create mode 100644 src/bin/dhcp4/tests/direct_client_unittest.cc
-----------------------------------------------------------------------
diff --git a/src/bin/dhcp4/dhcp4_srv.cc b/src/bin/dhcp4/dhcp4_srv.cc
index 5fc5598..c337655 100644
--- a/src/bin/dhcp4/dhcp4_srv.cc
+++ b/src/bin/dhcp4/dhcp4_srv.cc
@@ -1511,12 +1511,13 @@ Dhcpv4Srv::selectSubnet(const Pkt4Ptr& question) {
subnet = CfgMgr::instance().getSubnet4(relay);
} else {
- // No: Use client's address to select subnet
- subnet = CfgMgr::instance().getSubnet4(question->getRemoteAddr());
+ // No: the message has been received from a directly connected client.
+ // The IPv4 address assigned to the interface on which this message
+ // has been received, will be used to determine the subnet suitable for
+ // a client.
+ subnet = CfgMgr::instance().getSubnet4(question->getIface());
}
- /// @todo Implement getSubnet4(interface-name)
-
// Let's execute all callouts registered for subnet4_select
if (HooksManager::calloutsPresent(hook_index_subnet4_select_)) {
CalloutHandlePtr callout_handle = getCalloutHandle(question);
diff --git a/src/bin/dhcp4/tests/Makefile.am b/src/bin/dhcp4/tests/Makefile.am
index c72b8b0..8a0867b 100644
--- a/src/bin/dhcp4/tests/Makefile.am
+++ b/src/bin/dhcp4/tests/Makefile.am
@@ -79,6 +79,7 @@ dhcp4_unittests_SOURCES += dhcp4_test_utils.h
dhcp4_unittests_SOURCES += dhcp4_unittests.cc
dhcp4_unittests_SOURCES += dhcp4_srv_unittest.cc
dhcp4_unittests_SOURCES += dhcp4_test_utils.cc dhcp4_test_utils.h
+dhcp4_unittests_SOURCES += direct_client_unittest.cc
dhcp4_unittests_SOURCES += wireshark.cc
dhcp4_unittests_SOURCES += ctrl_dhcp4_srv_unittest.cc
dhcp4_unittests_SOURCES += config_parser_unittest.cc
@@ -94,6 +95,7 @@ dhcp4_unittests_LDADD += $(top_builddir)/src/lib/asiolink/libb10-asiolink.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/cc/libb10-cc.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/config/libb10-cfgclient.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/libb10-dhcp++.la
+dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp/tests/libdhcptest.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcp_ddns/libb10-dhcp_ddns.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/dhcpsrv/libb10-dhcpsrv.la
dhcp4_unittests_LDADD += $(top_builddir)/src/lib/exceptions/libb10-exceptions.la
diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.cc b/src/bin/dhcp4/tests/dhcp4_test_utils.cc
index e983e7b..8944b29 100644
--- a/src/bin/dhcp4/tests/dhcp4_test_utils.cc
+++ b/src/bin/dhcp4/tests/dhcp4_test_utils.cc
@@ -34,9 +34,6 @@ namespace isc {
namespace dhcp {
namespace test {
-/// dummy server-id file location
-static const char* SRVID_FILE = "server-id-test.txt";
-
Dhcpv4SrvTest::Dhcpv4SrvTest()
:rcode_(-1) {
subnet_ = Subnet4Ptr(new Subnet4(IOAddress("192.0.2.0"), 24, 1000,
@@ -52,9 +49,6 @@ Dhcpv4SrvTest::Dhcpv4SrvTest()
Option4AddrLstPtr opt_routers(new Option4AddrLst(DHO_ROUTERS));
opt_routers->setAddress(IOAddress("192.0.2.2"));
subnet_->addOption(opt_routers, false, "dhcp4");
-
- // it's ok if that fails. There should not be such a file anyway
- unlink(SRVID_FILE);
}
Dhcpv4SrvTest::~Dhcpv4SrvTest() {
@@ -387,9 +381,6 @@ void Dhcpv4SrvTest::TearDown() {
CfgMgr::instance().deleteSubnets4();
- // Let's clean up if there is such a file.
- unlink(SRVID_FILE);
-
// Close all open sockets.
IfaceMgr::instance().closeSockets();
diff --git a/src/bin/dhcp4/tests/dhcp4_test_utils.h b/src/bin/dhcp4/tests/dhcp4_test_utils.h
index 8a22117..903b8dc 100644
--- a/src/bin/dhcp4/tests/dhcp4_test_utils.h
+++ b/src/bin/dhcp4/tests/dhcp4_test_utils.h
@@ -416,7 +416,6 @@ public:
///
/// See fake_received_ field for description
void fakeReceive(const Pkt4Ptr& pkt) {
- pkt->setIface("eth0");
fake_received_.push_back(pkt);
}
diff --git a/src/bin/dhcp4/tests/direct_client_unittest.cc b/src/bin/dhcp4/tests/direct_client_unittest.cc
new file mode 100644
index 0000000..bc2a42e
--- /dev/null
+++ b/src/bin/dhcp4/tests/direct_client_unittest.cc
@@ -0,0 +1,237 @@
+// Copyright (C) 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
+// copyright notice and this permission notice appear in all copies.
+//
+// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+// AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+// PERFORMANCE OF THIS SOFTWARE.
+
+#include <cc/data.h>
+#include <dhcp/iface_mgr.h>
+#include <dhcp/pkt4.h>
+#include <dhcp/tests/iface_mgr_test_config.h>
+#include <dhcpsrv/cfgmgr.h>
+#include <dhcpsrv/subnet.h>
+#include <dhcp4/config_parser.h>
+#include <dhcp4/tests/dhcp4_test_utils.h>
+#include <gtest/gtest.h>
+#include <string>
+
+using namespace isc;
+using namespace isc::asiolink;
+using namespace isc::data;
+using namespace isc::dhcp;
+using namespace isc::dhcp::test;
+
+namespace {
+
+/// @brief Test fixture class for testing message processing from directly
+/// connected clients.
+///
+/// This class provides mechanisms for testing processing of DHCPv4 messages
+/// from directly connected clients.
+class DirectClientTest : public Dhcpv4SrvTest {
+public:
+ /// @brief Constructor.
+ ///
+ /// Initializes DHCPv4 server object used by various tests.
+ DirectClientTest();
+
+ /// @brief Configures the server with one subnet.
+ ///
+ /// This creates new configuration for the DHCPv4 with one subnet having
+ /// a specified prefix.
+ ///
+ /// The subnet parameters (such as options, timers etc.) are aribitrarily
+ /// selected. The subnet and pool mask is always /24.
+ ///
+ /// @param prefix Prefix for a subnet.
+ void configureSubnet(const std::string& prefix);
+
+ /// @brief Configures the server with two subnets.
+ ///
+ /// This function configures DHCPv4 server with two different subnets.
+ /// The subnet parameters (such as options, timers etc.) are aribitrarily
+ /// selected. The subnet and pool mask is /24.
+ ///
+ /// @param prefix1 Prefix of the first subnet to be configured.
+ /// @param prefix2 Prefix of the second subnet to be configured.
+ void configureTwoSubnets(const std::string& prefix1,
+ const std::string& prefix2);
+
+ /// @brief Creates simple message from a client.
+ ///
+ /// This function creates a DHCPv4 message having a specified type
+ /// (e.g. Discover, Request) and sets the interface property of this
+ /// message. The interface property indicates on which interface
+ /// interface a message has been received. The interface is used by
+ /// the DHCPv4 server to determine the subnet from which the address
+ /// should be allocated for the client.
+ ///
+ /// @param msg_type Type of the message to be created.
+ /// @param iface Name of the interface on which the message has been
+ /// "received" by the server.
+ ///
+ /// @return Generated message.
+ Pkt4Ptr createClientMessage(const uint16_t msg_type,
+ const std::string& iface);
+
+ /// @brief Runs DHCPv4 configuration from the JSON string.
+ ///
+ /// @param config String holding server configuration in JSON format.
+ void configure(const std::string& config);
+
+ /// @brief Server object to be unit tested.
+ NakedDhcpv4Srv srv_;
+
+};
+
+DirectClientTest::DirectClientTest()
+ : srv_(0) {
+}
+
+void
+DirectClientTest::configureSubnet(const std::string& prefix) {
+ std::ostringstream config;
+ config << "{ \"interfaces\": [ \"*\" ],"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"option-data\": [ ],"
+ "\"subnet4\": [ { "
+ " \"pool\": [ \"" << prefix << "/24\" ],"
+ " \"subnet\": \"" << prefix << "/24\", "
+ " \"rebind-timer\": 2000, "
+ " \"renew-timer\": 1000, "
+ " \"valid-lifetime\": 4000"
+ "} ],"
+ "\"valid-lifetime\": 4000 }";
+
+ configure(config.str());
+
+}
+
+void
+DirectClientTest::configureTwoSubnets(const std::string& prefix1,
+ const std::string& prefix2) {
+ std::ostringstream config;
+ config << "{ \"interfaces\": [ \"*\" ],"
+ "\"rebind-timer\": 2000, "
+ "\"renew-timer\": 1000, "
+ "\"option-data\": [ ],"
+ "\"subnet4\": [ { "
+ " \"pool\": [ \"" << prefix1 << "/24\" ],"
+ " \"subnet\": \"" << prefix1 << "/24\", "
+ " \"rebind-timer\": 2000, "
+ " \"renew-timer\": 1000, "
+ " \"valid-lifetime\": 4000"
+ " },"
+ "{ "
+ " \"pool\": [ \"" << prefix2 << "/24\" ],"
+ " \"subnet\": \"" << prefix2 << "/24\", "
+ " \"rebind-timer\": 2000, "
+ " \"renew-timer\": 1000, "
+ " \"valid-lifetime\": 4000"
+ "} ],"
+ "\"valid-lifetime\": 4000 }";
+
+ configure(config.str());
+}
+
+Pkt4Ptr
+DirectClientTest:: createClientMessage(const uint16_t msg_type,
+ const std::string& iface) {
+ // Create a source packet.
+ Pkt4Ptr msg = Pkt4Ptr(new Pkt4(msg_type, 1234));
+ msg->setRemoteAddr(IOAddress("255.255.255.255"));
+ msg->addOption(generateClientId());
+ msg->setIface(iface);
+ // Create on-wire format of this packet as it has been sent by the client.
+ msg->pack();
+
+ // Create copy of this packet by parsing its wire data. Make sure that the
+ // local and remote address are set like it was a message sent from the
+ // directly connected client.
+ Pkt4Ptr received;
+ createPacketFromBuffer(msg, received);
+ received->setIface(iface);
+ received->setLocalAddr(IOAddress("255.255.255.255"));
+ received->setRemoteAddr(IOAddress("0.0.0.0"));
+
+ return (received);
+}
+
+void
+DirectClientTest::configure(const std::string& config) {
+ ElementPtr json = Element::fromJSON(config);
+ ConstElementPtr status;
+
+ // Configure the server and make sure the config is accepted
+ EXPECT_NO_THROW(status = configureDhcp4Server(srv_, json));
+ ASSERT_TRUE(status);
+ int rcode;
+ ConstElementPtr comment = config::parseAnswer(rcode, status);
+ ASSERT_EQ(0, rcode);
+}
+
+// This test checks that the message from directly connected client
+// is processed and that client is offered IPv4 address from the subnet which
+// is suitable for the local interface on which the client's message is
+// received. This test uses two subnets, with two active interfaces which IP
+// addresses belong to these subnets. The address offered to the client
+// which message has been sent over eth0 should belong to a different
+// subnet than the address offered for the client sending its message
+// via eth1.
+TEST_F(DirectClientTest, twoSubnets) {
+ // Configure IfaceMgr with fake interfaces lo, eth0 and eth1.
+ IfaceMgrTestConfig iface_config(true);
+ // After creating interfaces we have to open sockets as it is required
+ // by the message processing code.
+ ASSERT_NO_THROW(IfaceMgr::instance().openSockets4());
+ // Add two subnets: address on eth0 belongs to the second subnet,
+ // address on eth1 belongs to the first subnet.
+ ASSERT_NO_FATAL_FAILURE(configureTwoSubnets("192.0.2.0", "10.0.0.0"));
+ // Create Discover and simulate reception of this message through eth0.
+ Pkt4Ptr dis = createClientMessage(DHCPDISCOVER, "eth0");
+ srv_.fakeReceive(dis);
+ // Create Request and simulate reception of this message through eth1.
+ Pkt4Ptr req = createClientMessage(DHCPREQUEST, "eth1");
+ srv_.fakeReceive(req);
+
+ // Process clients' messages.
+ srv_.run();
+
+ // Check that the server did send reposonses.
+ ASSERT_EQ(2, srv_.fake_sent_.size());
+
+ // Make sure that we received a responses.
+ Pkt4Ptr response = srv_.fake_sent_.front();
+ ASSERT_TRUE(response);
+ srv_.fake_sent_.pop_front();
+
+ // Client should get an Offer (not a NAK).
+ ASSERT_EQ(DHCPOFFER, response->getType());
+ // Check that the offered address belongs to the suitable subnet.
+ Subnet4Ptr subnet = CfgMgr::instance().getSubnet4(response->getYiaddr());
+ ASSERT_TRUE(subnet);
+ EXPECT_EQ("10.0.0.0", subnet->get().first.toText());
+
+ // A client that sent Request over the other interface should get Ack.
+ response = srv_.fake_sent_.front();
+ ASSERT_TRUE(response);
+
+ // Client should get an Ack (not a NAK).
+ ASSERT_EQ(DHCPACK, response->getType());
+ // Check that the offered address belongs to the suitable subnet.
+ subnet = CfgMgr::instance().getSubnet4(response->getYiaddr());
+ ASSERT_TRUE(subnet);
+ EXPECT_EQ("192.0.2.0", subnet->get().first.toText());
+
+}
+
+}
diff --git a/src/lib/dhcpsrv/cfgmgr.cc b/src/lib/dhcpsrv/cfgmgr.cc
index 60d02e5..b8e3629 100644
--- a/src/lib/dhcpsrv/cfgmgr.cc
+++ b/src/lib/dhcpsrv/cfgmgr.cc
@@ -208,9 +208,9 @@ void CfgMgr::addSubnet6(const Subnet6Ptr& subnet) {
}
Subnet4Ptr
-CfgMgr::getSubnet4(const isc::asiolink::IOAddress& hint) {
+CfgMgr::getSubnet4(const isc::asiolink::IOAddress& hint) const {
- // If there's only one subnet configured, let's just use it
+ /* // If there's only one subnet configured, let's just use it
// The idea is to keep small deployments easy. In a small network - one
// router that also runs DHCPv6 server. Users specifies a single pool and
// expects it to just work. Without this, the server would complain that it
@@ -223,10 +223,10 @@ CfgMgr::getSubnet4(const isc::asiolink::IOAddress& hint) {
DHCPSRV_CFGMGR_ONLY_SUBNET4)
.arg(subnets4_[0]->toText()).arg(hint.toText());
return (subnets4_[0]);
- }
+ }*/
// If there is more than one, we need to choose the proper one
- for (Subnet4Collection::iterator subnet = subnets4_.begin();
+ for (Subnet4Collection::const_iterator subnet = subnets4_.begin();
subnet != subnets4_.end(); ++subnet) {
if ((*subnet)->inRange(hint)) {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE,
@@ -242,22 +242,20 @@ CfgMgr::getSubnet4(const isc::asiolink::IOAddress& hint) {
return (Subnet4Ptr());
}
-bool
-CfgMgr::belongsToSubnet4(const std::string& iface_name) const {
+Subnet4Ptr
+CfgMgr::getSubnet4(const std::string& iface_name) const {
Iface* iface = IfaceMgr::instance().getIface(iface_name);
+ // This should never happen in the real life. Hence we throw an exception.
if (iface == NULL) {
- isc_throw(isc::BadValue, "interface " << iface_name << " doesn't exist");
+ isc_throw(isc::BadValue, "interface " << iface_name <<
+ " doesn't exist and therefore it is impossible"
+ " to find a suitable subnet for its IPv4 address");
}
IOAddress addr("::1");
- if (iface->getAddress4(addr)) {
- for (Subnet4Collection::const_iterator subnet = subnets4_.begin();
- subnet != subnets4_.end(); ++subnet) {
- if ((*subnet)->inRange(addr)) {
- return (true);
- }
- }
- }
- return (false);
+ // If IPv4 address assigned to the interface exists, find a suitable
+ // subnet for it, else return NULL pointer to indicate that no subnet
+ // could be found.
+ return (iface->getAddress4(addr) ? getSubnet4(addr) : Subnet4Ptr());
}
void CfgMgr::addSubnet4(const Subnet4Ptr& subnet) {
diff --git a/src/lib/dhcpsrv/cfgmgr.h b/src/lib/dhcpsrv/cfgmgr.h
index f22a994..610e4b1 100644
--- a/src/lib/dhcpsrv/cfgmgr.h
+++ b/src/lib/dhcpsrv/cfgmgr.h
@@ -219,7 +219,7 @@ public:
/// to choose a different subnet. Server code has to offer a list
/// of possible choices (i.e. all subnets).
/// @return a pointer to const Subnet6 collection
- const Subnet4Collection* getSubnets4() {
+ const Subnet4Collection* getSubnets4() const {
return (&subnets4_);
}
@@ -244,19 +244,19 @@ public:
/// @param hint an address that belongs to a searched subnet
///
/// @return a subnet object
- Subnet4Ptr getSubnet4(const isc::asiolink::IOAddress& hint);
+ Subnet4Ptr getSubnet4(const isc::asiolink::IOAddress& hint) const;
- /// @brief Checks that the IP address assigned to an interface belongs to
- /// any subnet.
+ /// @brief Returns a subnet for the specified local interface.
///
/// This function checks that the IP address assigned to the specified
- /// interface belongs to any IPv4 subnet configured.
+ /// interface belongs to any IPv4 subnet configured, and returns this
+ /// subnet.
///
/// @param iface Short name of the interface which is being checked.
///
- /// @return Boolean value which indicates that the IP address belons to any
- /// subnet (if true), false otherwise.
- bool belongsToSubnet4(const std::string& iface) const;
+ /// @return Pointer to the subnet matching interface specified or NULL
+ /// pointer if IPv4 address on the interface doesn't match any subnet.
+ Subnet4Ptr getSubnet4(const std::string& iface) const;
/// @brief adds a subnet4
void addSubnet4(const Subnet4Ptr& subnet);
diff --git a/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc b/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
index ac34f2e..a6223f7 100644
--- a/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
+++ b/src/lib/dhcpsrv/tests/cfgmgr_unittest.cc
@@ -713,23 +713,42 @@ TEST_F(CfgMgrTest, d2ClientConfig) {
// This test verfies that CfgMgr correctly determines that the address of the
// interface belongs to existing IPv4 subnet.
-TEST_F(CfgMgrTest, belongsToSubnet4) {
+TEST_F(CfgMgrTest, getSubnet4ForInterface) {
IfaceMgrTestConfig config(true);
- ASSERT_FALSE(CfgMgr::instance().belongsToSubnet4("eth0"));
- ASSERT_FALSE(CfgMgr::instance().belongsToSubnet4("eth1"));
+ // Initially, there are no subnets configured, so none of the IPv4
+ // addresses assigned to eth0 and eth1 can match with any subnet.
+ ASSERT_FALSE(CfgMgr::instance().getSubnet4("eth0"));
+ ASSERT_FALSE(CfgMgr::instance().getSubnet4("eth1"));
+ // Configure first subnet which address on eth0 corresponds to.
Subnet4Ptr subnet1(new Subnet4(IOAddress("10.0.0.1"), 24, 1, 2, 3));
CfgMgr::instance().addSubnet4(subnet1);
- EXPECT_TRUE(CfgMgr::instance().belongsToSubnet4("eth0"));
- EXPECT_FALSE(CfgMgr::instance().belongsToSubnet4("eth1"));
+ // The address on eth0 should match the existing subnet.
+ Subnet4Ptr subnet1_ret;
+ subnet1_ret = CfgMgr::instance().getSubnet4("eth0");
+ ASSERT_TRUE(subnet1_ret);
+ EXPECT_EQ(subnet1->get().first, subnet1_ret->get().first);
+ // There should still be no match for eth1.
+ EXPECT_FALSE(CfgMgr::instance().getSubnet4("eth1"));
+ // Configure a second subnet.
Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.1"), 24, 1, 2, 3));
CfgMgr::instance().addSubnet4(subnet2);
- EXPECT_TRUE(CfgMgr::instance().belongsToSubnet4("eth0"));
- EXPECT_TRUE(CfgMgr::instance().belongsToSubnet4("eth1"));
+ // There should be match between eth0 and subnet1 and between eth1 and
+ // subnet 2.
+ subnet1_ret = CfgMgr::instance().getSubnet4("eth0");
+ ASSERT_TRUE(subnet1_ret);
+ EXPECT_EQ(subnet1->get().first, subnet1_ret->get().first);
+ Subnet4Ptr subnet2_ret = CfgMgr::instance().getSubnet4("eth1");
+ ASSERT_TRUE(subnet2_ret);
+ EXPECT_EQ(subnet2->get().first, subnet2_ret->get().first);
+
+ // This function throws an exception if the name of the interface is wrong.
+ EXPECT_THROW(CfgMgr::instance().getSubnet4("bogus-interface"),
+ isc::BadValue);
}
More information about the bind10-changes
mailing list