From: Francis Dupont Date: Mon, 3 Jun 2019 20:06:53 +0000 (+0200) Subject: [419-subnet-prefix-subnet-parameter-ambiguity] Added unit tests and updated docs X-Git-Tag: Kea-1.6.0-beta2~128 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f260b51148b4f7584165e13fcf2320fdd5992a74;p=thirdparty%2Fkea.git [419-subnet-prefix-subnet-parameter-ambiguity] Added unit tests and updated docs --- diff --git a/doc/guide/dhcp4-srv.xml b/doc/guide/dhcp4-srv.xml index 5d65908d15..1e9b538482 100644 --- a/doc/guide/dhcp4-srv.xml +++ b/doc/guide/dhcp4-srv.xml @@ -1084,6 +1084,32 @@ temporarily override a list of interface names and listen on all interfaces. id --> +
+ IPv4 Subnet Prefix + + The subnet prefix is the second way to identify a subnet. It does not + need to have the address part to match the prefix length, for instance + this configuration is accepted: + + +"Dhcp4": { + "subnet4": [ + { + "subnet": "192.0.2.1/24", + ... + } + ] +} + + Even there is another subnet with the "192.0.2.0/24" prefix: only the + textual form of subnets are compared to avoid duplicates. + + + Abuse of this feature can lead to incorrect subnet selection + (see ). + +
+
Configuration of IPv4 Address Pools diff --git a/doc/guide/dhcp6-srv.xml b/doc/guide/dhcp6-srv.xml index e7dd879cc4..c17bd88591 100644 --- a/doc/guide/dhcp6-srv.xml +++ b/doc/guide/dhcp6-srv.xml @@ -829,6 +829,32 @@ temporarily override a list of interface names and listen on all interfaces. id -->
+
+ IPv6 Subnet Prefix + + The subnet prefix is the second way to identify a subnet. It does not + need to have the address part to match the prefix length, for instance + this configuration is accepted: + + +"Dhcp6": { + "subnet6": [ + { + "subnet": "2001:db8:1::1/64", + ... + } + ] +} + + Even there is another subnet with the "2001:db8:1::/64" prefix: + only the textual form of subnets are compared to avoid duplicates. + + + Abuse of this feature can lead to incorrect subnet selection + (see ). + +
+
Unicast Traffic Support diff --git a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc index c033f04d07..624c30d577 100644 --- a/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc @@ -910,11 +910,14 @@ TEST(CfgSubnets4Test, duplication) { Subnet4Ptr subnet1(new Subnet4(IOAddress("192.0.2.0"), 26, 1, 2, 3, 123)); Subnet4Ptr subnet2(new Subnet4(IOAddress("192.0.2.64"), 26, 1, 2, 3, 124)); Subnet4Ptr subnet3(new Subnet4(IOAddress("192.0.2.128"), 26, 1, 2, 3, 123)); + Subnet4Ptr subnet4(new Subnet4(IOAddress("192.0.2.1"), 26, 1, 2, 3, 125)); ASSERT_NO_THROW(cfg.add(subnet1)); EXPECT_NO_THROW(cfg.add(subnet2)); // Subnet 3 has the same ID as subnet 1. It shouldn't be able to add it. EXPECT_THROW(cfg.add(subnet3), isc::dhcp::DuplicateSubnetID); + // Subnet 4 has a similar but different subnet as subnet 1. + EXPECT_NO_THROW(cfg.add(subnet4)); } // This test checks if the IPv4 subnet can be selected based on the IPv6 address. diff --git a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc index a0b5c8f302..d442e06872 100644 --- a/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc +++ b/src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc @@ -588,11 +588,14 @@ TEST(CfgSubnets6Test, duplication) { Subnet6Ptr subnet1(new Subnet6(IOAddress("2000::"), 48, 1, 2, 3, 4, 123)); Subnet6Ptr subnet2(new Subnet6(IOAddress("3000::"), 48, 1, 2, 3, 4, 124)); Subnet6Ptr subnet3(new Subnet6(IOAddress("4000::"), 48, 1, 2, 3, 4, 123)); + Subnet6Ptr subnet4(new Subnet6(IOAddress("2000::1"), 48, 1, 2, 3, 4, 125)); ASSERT_NO_THROW(cfg.add(subnet1)); EXPECT_NO_THROW(cfg.add(subnet2)); // Subnet 3 has the same ID as subnet 1. It shouldn't be able to add it. EXPECT_THROW(cfg.add(subnet3), isc::dhcp::DuplicateSubnetID); + // Subnet 4 has a similar but different subnet as subnet 1. + EXPECT_NO_THROW(cfg.add(subnet4)); } // This test check if IPv6 subnets can be unparsed in a predictable way,