]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[419-subnet-prefix-subnet-parameter-ambiguity] Added unit tests and updated docs
authorFrancis Dupont <fdupont@isc.org>
Mon, 3 Jun 2019 20:06:53 +0000 (22:06 +0200)
committerFrancis Dupont <fdupont@isc.org>
Thu, 4 Jul 2019 14:52:15 +0000 (10:52 -0400)
doc/guide/dhcp4-srv.xml
doc/guide/dhcp6-srv.xml
src/lib/dhcpsrv/tests/cfg_subnets4_unittest.cc
src/lib/dhcpsrv/tests/cfg_subnets6_unittest.cc

index 5d65908d150830202d6d6db0544114b1c6a223f2..1e9b5384823436a31f60df3176efbc16fbe6a1ac 100644 (file)
@@ -1084,6 +1084,32 @@ temporarily override a list of interface names and listen on all interfaces.
       id -->
 </section>
 
+<section xml:id="ipv4-subnet-prefix">
+  <title>IPv4 Subnet Prefix</title>
+  <para>
+    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:
+
+    <screen>
+"Dhcp4": {
+    "subnet4": [
+        {
+            <userinput>"subnet": "192.0.2.1/24"</userinput>,
+            ...
+        }
+    ]
+}
+</screen>
+    Even there is another subnet with the "192.0.2.0/24" prefix: only the
+    textual form of subnets are compared to avoid duplicates.
+    </para>
+    <note>
+       Abuse of this feature can lead to incorrect subnet selection
+       (see <xref linkend="dhcp4-subnet-selection"/>).
+    </note>
+</section>
+
 <section xml:id="dhcp4-address-config">
   <title>Configuration of IPv4 Address Pools</title>
   <para>
index e7dd879cc47de418a830c2b25a337eab5ef93cfc..c17bd8859110112b3a8587cbf42a2570238fc7a8 100644 (file)
@@ -829,6 +829,32 @@ temporarily override a list of interface names and listen on all interfaces.
       id -->
     </section>
 
+    <section xml:id="ipv6-subnet-prefix">
+       <title>IPv6 Subnet Prefix</title>
+       <para>
+        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:
+
+    <screen>
+"Dhcp6": {
+    "subnet6": [
+        {
+            <userinput>"subnet": "2001:db8:1::1/64"</userinput>,
+            ...
+        }
+    ]
+}
+</screen>
+         Even there is another subnet with the "2001:db8:1::/64" prefix:
+         only the textual form of subnets are compared to avoid duplicates.
+        </para>
+        <note>
+          Abuse of this feature can lead to incorrect subnet selection
+          (see <xref linkend="dhcp6-config-subnets"/>).
+        </note>
+    </section>
+
     <section xml:id="dhcp6-unicast">
       <title>Unicast Traffic Support</title>
       <para>
index c033f04d076493caef711cdb719cffee531b571d..624c30d577f04e41875829069b555e2be39d33f9 100644 (file)
@@ -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.
index a0b5c8f3027efa172edbcfcf3d23ab88122491cb..d442e06872e777fa06899cef0fe0c53525cb9de9 100644 (file)
@@ -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,