|
@@ -283,7 +283,6 @@ public:
|
|
|
|
|
|
void clear() {
|
|
|
CfgMgr::instance().setVerbose(false);
|
|
|
- CfgMgr::instance().deleteSubnets6();
|
|
|
CfgMgr::instance().clear();
|
|
|
}
|
|
|
|
|
@@ -304,307 +303,6 @@ TEST_F(CfgMgrTest, configuration) {
|
|
|
EXPECT_TRUE(configuration->getLoggingInfo().empty());
|
|
|
}
|
|
|
|
|
|
-// This test verifies if the configuration manager is able to hold v6 subnets
|
|
|
-// with their relay address information and return proper subnets, based on
|
|
|
-// those addresses.
|
|
|
-TEST_F(CfgMgrTest, subnet6RelayOverride) {
|
|
|
- CfgMgr& cfg_mgr = CfgMgr::instance();
|
|
|
-
|
|
|
- // Let's configure 3 subnets
|
|
|
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:db8:1::"), 48, 1, 2, 3, 4));
|
|
|
- Subnet6Ptr subnet2(new Subnet6(IOAddress("2001:db8:2::"), 48, 1, 2, 3, 4));
|
|
|
- Subnet6Ptr subnet3(new Subnet6(IOAddress("2001:db8:3::"), 48, 1, 2, 3, 4));
|
|
|
-
|
|
|
- cfg_mgr.addSubnet6(subnet1);
|
|
|
- cfg_mgr.addSubnet6(subnet2);
|
|
|
- cfg_mgr.addSubnet6(subnet3);
|
|
|
-
|
|
|
- // Check that without relay-info specified, subnets are not selected
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2001:db8:ff::1"), classify_, true));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2001:db8:ff::2"), classify_, true));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2001:db8:ff::3"), classify_, true));
|
|
|
-
|
|
|
- // Now specify relay info
|
|
|
- subnet1->setRelayInfo(IOAddress("2001:db8:ff::1"));
|
|
|
- subnet2->setRelayInfo(IOAddress("2001:db8:ff::2"));
|
|
|
- subnet3->setRelayInfo(IOAddress("2001:db8:ff::3"));
|
|
|
-
|
|
|
- // And try again. This time relay-info is there and should match.
|
|
|
- EXPECT_EQ(subnet1, cfg_mgr.getSubnet6(IOAddress("2001:db8:ff::1"), classify_, true));
|
|
|
- EXPECT_EQ(subnet2, cfg_mgr.getSubnet6(IOAddress("2001:db8:ff::2"), classify_, true));
|
|
|
- EXPECT_EQ(subnet3, cfg_mgr.getSubnet6(IOAddress("2001:db8:ff::3"), classify_, true));
|
|
|
-
|
|
|
- // Finally, check that the relay works only if hint provided is relay address
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2001:db8:ff::1"), classify_, false));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2001:db8:ff::2"), classify_, false));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2001:db8:ff::3"), classify_, false));
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
-// This test verifies if the configuration manager is able to hold and return
|
|
|
-// valid leases
|
|
|
-TEST_F(CfgMgrTest, classifySubnet6) {
|
|
|
- CfgMgr& cfg_mgr = CfgMgr::instance();
|
|
|
-
|
|
|
- // Let's configure 3 subnets
|
|
|
- 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));
|
|
|
-
|
|
|
- cfg_mgr.addSubnet6(subnet1);
|
|
|
- cfg_mgr.addSubnet6(subnet2);
|
|
|
- cfg_mgr.addSubnet6(subnet3);
|
|
|
-
|
|
|
- // Let's sanity check that we can use that configuration.
|
|
|
- EXPECT_EQ(subnet1, cfg_mgr.getSubnet6(IOAddress("2000::123"), classify_));
|
|
|
- EXPECT_EQ(subnet2, cfg_mgr.getSubnet6(IOAddress("3000::345"), classify_));
|
|
|
- EXPECT_EQ(subnet3, cfg_mgr.getSubnet6(IOAddress("4000::567"), classify_));
|
|
|
-
|
|
|
- // Client now belongs to bar class.
|
|
|
- classify_.insert("bar");
|
|
|
-
|
|
|
- // There are no class restrictions defined, so everything should work
|
|
|
- // as before
|
|
|
- EXPECT_EQ(subnet1, cfg_mgr.getSubnet6(IOAddress("2000::123"), classify_));
|
|
|
- EXPECT_EQ(subnet2, cfg_mgr.getSubnet6(IOAddress("3000::345"), classify_));
|
|
|
- EXPECT_EQ(subnet3, cfg_mgr.getSubnet6(IOAddress("4000::567"), classify_));
|
|
|
-
|
|
|
- // Now let's add client class restrictions.
|
|
|
- subnet1->allowClientClass("foo"); // Serve here only clients from foo class
|
|
|
- subnet2->allowClientClass("bar"); // Serve here only clients from bar class
|
|
|
- subnet3->allowClientClass("baz"); // Serve here only clients from baz class
|
|
|
-
|
|
|
- // The same check as above should result in client being served only in
|
|
|
- // bar class, i.e. subnet2
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2000::123"), classify_));
|
|
|
- EXPECT_EQ(subnet2, cfg_mgr.getSubnet6(IOAddress("3000::345"), classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("4000::567"), classify_));
|
|
|
-
|
|
|
- // Now let's check that client with wrong class is not supported
|
|
|
- classify_.clear();
|
|
|
- classify_.insert("some_other_class");
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2000::123"), classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("3000::345"), classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("4000::567"), classify_));
|
|
|
-
|
|
|
- // Finally, let's check that client without any classes is not supported
|
|
|
- classify_.clear();
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2000::123"), classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("3000::345"), classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("4000::567"), classify_));
|
|
|
-}
|
|
|
-
|
|
|
-// This test verifies if the configuration manager is able to hold, select
|
|
|
-// and return valid subnets, based on interface names along with client
|
|
|
-// classification.
|
|
|
-TEST_F(CfgMgrTest, classifySubnet6Interface) {
|
|
|
- CfgMgr& cfg_mgr = CfgMgr::instance();
|
|
|
-
|
|
|
- // Let's have an odd configuration: 3 shared subnets available on the
|
|
|
- // same direct link.
|
|
|
- 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));
|
|
|
- subnet1->setIface("foo");
|
|
|
- subnet2->setIface("foo");
|
|
|
- subnet3->setIface("foo");
|
|
|
- cfg_mgr.addSubnet6(subnet1);
|
|
|
- cfg_mgr.addSubnet6(subnet2);
|
|
|
- cfg_mgr.addSubnet6(subnet3);
|
|
|
-
|
|
|
-
|
|
|
- // Regular client should get the first subnet, because it meets all
|
|
|
- // criteria (matching interface name, no class restrictions.
|
|
|
- EXPECT_EQ(subnet1, cfg_mgr.getSubnet6("foo", classify_));
|
|
|
-
|
|
|
- // Now let's add class requirements for subnet1
|
|
|
- subnet1->allowClientClass("alpha");
|
|
|
-
|
|
|
- // Client should now get the subnet2, because he no longer meets
|
|
|
- // requirements for subnet1 (belongs to wrong class)
|
|
|
- EXPECT_EQ(subnet2, cfg_mgr.getSubnet6("foo", classify_));
|
|
|
-
|
|
|
- // Now let's add (not matching) classes to the other two subnets
|
|
|
- subnet2->allowClientClass("beta");
|
|
|
- subnet3->allowClientClass("gamma");
|
|
|
-
|
|
|
- // No subnets are suitable, so nothing will be selected
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6("foo", classify_));
|
|
|
-
|
|
|
- // Ok, let's add the client to gamme class, so he'll get a subnet
|
|
|
- classify_.insert("gamma");
|
|
|
- EXPECT_EQ(subnet3, cfg_mgr.getSubnet6("foo", classify_));
|
|
|
-}
|
|
|
-
|
|
|
-// This test verifies if the configuration manager is able to hold, select
|
|
|
-// and return valid subnets, based on interface-id option inserted by relay,
|
|
|
-// along with client classification.
|
|
|
-TEST_F(CfgMgrTest, classifySubnet6InterfaceId) {
|
|
|
- CfgMgr& cfg_mgr = CfgMgr::instance();
|
|
|
-
|
|
|
- // Let's have an odd configuration: 3 shared subnets available via the
|
|
|
- // same remote relay with the same interface-id.
|
|
|
- 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));
|
|
|
- OptionPtr ifaceid = generateInterfaceId("relay1.eth0");
|
|
|
- subnet1->setInterfaceId(ifaceid);
|
|
|
- subnet2->setInterfaceId(ifaceid);
|
|
|
- subnet3->setInterfaceId(ifaceid);
|
|
|
- cfg_mgr.addSubnet6(subnet1);
|
|
|
- cfg_mgr.addSubnet6(subnet2);
|
|
|
- cfg_mgr.addSubnet6(subnet3);
|
|
|
-
|
|
|
- // Regular client should get the first subnet, because it meets all
|
|
|
- // criteria (matching interface name, no class restrictions.
|
|
|
- EXPECT_EQ(subnet1, cfg_mgr.getSubnet6(ifaceid, classify_));
|
|
|
-
|
|
|
- // Now let's add class requirements for subnet1
|
|
|
- subnet1->allowClientClass("alpha");
|
|
|
-
|
|
|
- // Client should now get the subnet2, because he no longer meets
|
|
|
- // requirements for subnet1 (belongs to wrong class)
|
|
|
- EXPECT_EQ(subnet2, cfg_mgr.getSubnet6(ifaceid, classify_));
|
|
|
-
|
|
|
- // Now let's add (not matching) classes to the other two subnets
|
|
|
- subnet2->allowClientClass("beta");
|
|
|
- subnet3->allowClientClass("gamma");
|
|
|
-
|
|
|
- // No subnets are suitable, so nothing will be selected
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(ifaceid, classify_));
|
|
|
-
|
|
|
- // Ok, let's add the client to gamme class, so he'll get a subnet
|
|
|
- classify_.insert("gamma");
|
|
|
- EXPECT_EQ(subnet3, cfg_mgr.getSubnet6(ifaceid, classify_));
|
|
|
-}
|
|
|
-
|
|
|
-// This test verifies if the configuration manager is able to hold and return
|
|
|
-// valid leases
|
|
|
-TEST_F(CfgMgrTest, subnet6) {
|
|
|
- CfgMgr& cfg_mgr = CfgMgr::instance();
|
|
|
-
|
|
|
- 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));
|
|
|
-
|
|
|
- // There shouldn't be any subnet configured at this stage
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2000::1"), classify_));
|
|
|
-
|
|
|
- cfg_mgr.addSubnet6(subnet1);
|
|
|
-
|
|
|
- // Now we have only one subnet, any request will be served from it
|
|
|
- EXPECT_EQ(subnet1, cfg_mgr.getSubnet6(IOAddress("2000::1"), classify_));
|
|
|
-
|
|
|
- // We used to allow getting a sole subnet if there was only one subnet
|
|
|
- // configured. That is no longer true. The code should not return
|
|
|
- // a subnet.
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("fe80::dead:beef"), classify_));
|
|
|
-
|
|
|
- cfg_mgr.addSubnet6(subnet2);
|
|
|
- cfg_mgr.addSubnet6(subnet3);
|
|
|
-
|
|
|
- EXPECT_EQ(subnet3, cfg_mgr.getSubnet6(IOAddress("4000::123"), classify_));
|
|
|
- EXPECT_EQ(subnet2, cfg_mgr.getSubnet6(IOAddress("3000::dead:beef"),
|
|
|
- classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("5000::1"), classify_));
|
|
|
-
|
|
|
- // Check that deletion of the subnets works.
|
|
|
- cfg_mgr.deleteSubnets6();
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("2000::123"), classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("3000::123"), classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("4000::123"), classify_));
|
|
|
-}
|
|
|
-
|
|
|
-// This test verifies if the configuration manager is able to hold, select
|
|
|
-// and return valid subnets, based on interface names.
|
|
|
-TEST_F(CfgMgrTest, subnet6Interface) {
|
|
|
- CfgMgr& cfg_mgr = CfgMgr::instance();
|
|
|
-
|
|
|
- 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));
|
|
|
- subnet1->setIface("foo");
|
|
|
- subnet2->setIface("bar");
|
|
|
- subnet3->setIface("foobar");
|
|
|
-
|
|
|
- // There shouldn't be any subnet configured at this stage
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6("foo", classify_));
|
|
|
-
|
|
|
- cfg_mgr.addSubnet6(subnet1);
|
|
|
-
|
|
|
- // Now we have only one subnet, any request will be served from it
|
|
|
- EXPECT_EQ(subnet1, cfg_mgr.getSubnet6("foo", classify_));
|
|
|
-
|
|
|
- // Check that the interface name is checked even when there is
|
|
|
- // only one subnet defined.
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6("bar", classify_));
|
|
|
-
|
|
|
- // We used to allow getting a sole subnet if there was only one subnet
|
|
|
- // configured. That is no longer true. The code should not return
|
|
|
- // a subnet.
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(IOAddress("fe80::dead:beef"), classify_));
|
|
|
-
|
|
|
- cfg_mgr.addSubnet6(subnet2);
|
|
|
- cfg_mgr.addSubnet6(subnet3);
|
|
|
-
|
|
|
- EXPECT_EQ(subnet3, cfg_mgr.getSubnet6("foobar", classify_));
|
|
|
- EXPECT_EQ(subnet2, cfg_mgr.getSubnet6("bar", classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6("xyzzy", classify_)); // no such interface
|
|
|
-
|
|
|
- // Check that deletion of the subnets works.
|
|
|
- cfg_mgr.deleteSubnets6();
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6("foo", classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6("bar", classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6("foobar", classify_));
|
|
|
-}
|
|
|
-
|
|
|
-// This test verifies if the configuration manager is able to hold, select
|
|
|
-// and return valid leases, based on interface-id option values
|
|
|
-TEST_F(CfgMgrTest, subnet6InterfaceId) {
|
|
|
- CfgMgr& cfg_mgr = CfgMgr::instance();
|
|
|
-
|
|
|
- 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));
|
|
|
-
|
|
|
- // interface-id options used in subnets 1,2, and 3
|
|
|
- OptionPtr ifaceid1 = generateInterfaceId("relay1.eth0");
|
|
|
- OptionPtr ifaceid2 = generateInterfaceId("VL32");
|
|
|
- // That's a strange interface-id, but this is a real life example
|
|
|
- OptionPtr ifaceid3 = generateInterfaceId("ISAM144|299|ipv6|nt:vp:1:110");
|
|
|
-
|
|
|
- // bogus interface-id
|
|
|
- OptionPtr ifaceid_bogus = generateInterfaceId("non-existent");
|
|
|
-
|
|
|
- subnet1->setInterfaceId(ifaceid1);
|
|
|
- subnet2->setInterfaceId(ifaceid2);
|
|
|
- subnet3->setInterfaceId(ifaceid3);
|
|
|
-
|
|
|
- // There shouldn't be any subnet configured at this stage
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(ifaceid1, classify_));
|
|
|
-
|
|
|
- cfg_mgr.addSubnet6(subnet1);
|
|
|
-
|
|
|
- // 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(ifaceid1, classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(ifaceid2, classify_));
|
|
|
-
|
|
|
- cfg_mgr.addSubnet6(subnet2);
|
|
|
- cfg_mgr.addSubnet6(subnet3);
|
|
|
-
|
|
|
- EXPECT_EQ(subnet3, cfg_mgr.getSubnet6(ifaceid3, classify_));
|
|
|
- EXPECT_EQ(subnet2, cfg_mgr.getSubnet6(ifaceid2, classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(ifaceid_bogus, classify_));
|
|
|
-
|
|
|
- // Check that deletion of the subnets works.
|
|
|
- cfg_mgr.deleteSubnets6();
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(ifaceid1, classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(ifaceid2, classify_));
|
|
|
- EXPECT_FALSE(cfg_mgr.getSubnet6(ifaceid3, classify_));
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
// This test verifies that new DHCPv4 option spaces can be added to
|
|
|
// the configuration manager and that duplicated option space is
|
|
|
// rejected.
|
|
@@ -731,26 +429,6 @@ TEST_F(CfgMgrTest, d2ClientConfig) {
|
|
|
EXPECT_NE(*original_config, *updated_config);
|
|
|
}
|
|
|
|
|
|
-// Checks that detection of duplicated subnet IDs works as expected. It should
|
|
|
-// not be possible to add two IPv6 subnets holding the same ID to the config
|
|
|
-// manager.
|
|
|
-TEST_F(CfgMgrTest, subnet6Duplication) {
|
|
|
- CfgMgr& cfg_mgr = CfgMgr::instance();
|
|
|
-
|
|
|
- Subnet6Ptr subnet1(new Subnet6(IOAddress("2001:db8:1::"), 64, 1, 2, 3,
|
|
|
- 4, 123));
|
|
|
- Subnet6Ptr subnet2(new Subnet6(IOAddress("2001:db8:2::"), 64, 1, 2, 3,
|
|
|
- 4, 124));
|
|
|
- Subnet6Ptr subnet3(new Subnet6(IOAddress("2001:db8:3::"), 64, 1, 2, 3,
|
|
|
- 4, 123));
|
|
|
-
|
|
|
- ASSERT_NO_THROW(cfg_mgr.addSubnet6(subnet1));
|
|
|
- EXPECT_NO_THROW(cfg_mgr.addSubnet6(subnet2));
|
|
|
- // Subnet 3 has the same ID as subnet 1. It shouldn't be able to add it.
|
|
|
- EXPECT_THROW(cfg_mgr.addSubnet6(subnet3), isc::dhcp::DuplicateSubnetID);
|
|
|
-}
|
|
|
-
|
|
|
-
|
|
|
// This test verifies that the configuration staging, commit and rollback works
|
|
|
// as expected.
|
|
|
TEST_F(CfgMgrTest, staging) {
|