Commit f260b511 authored by Francis Dupont's avatar Francis Dupont
Browse files

[419-subnet-prefix-subnet-parameter-ambiguity] Added unit tests and updated docs

parent f2fce0e4
......@@ -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>
......
......@@ -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>
......
......@@ -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.
......
......@@ -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,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment