summaryrefslogtreecommitdiffstats
path: root/src/lib/dhcpsrv
diff options
context:
space:
mode:
authorRazvan Becheriu <razvan@isc.org>2023-06-29 13:56:19 +0200
committerRazvan Becheriu <razvan@isc.org>2023-06-29 19:54:14 +0200
commitf3706a575ec6602149fd7a28665025426ae37f65 (patch)
tree0ec7bdf63fc423a6c7e2a8ddc7fdcd162a4d9d87 /src/lib/dhcpsrv
parent[#2725] added unittests (diff)
downloadkea-f3706a575ec6602149fd7a28665025426ae37f65.tar.xz
kea-f3706a575ec6602149fd7a28665025426ae37f65.zip
[#2725] disable strict prefixlen checks in ctrs
Diffstat (limited to 'src/lib/dhcpsrv')
-rw-r--r--src/lib/dhcpsrv/host.cc5
-rw-r--r--src/lib/dhcpsrv/lease.cc10
-rw-r--r--src/lib/dhcpsrv/tests/host_unittest.cc6
-rw-r--r--src/lib/dhcpsrv/tests/lease_unittest.cc2
4 files changed, 18 insertions, 5 deletions
diff --git a/src/lib/dhcpsrv/host.cc b/src/lib/dhcpsrv/host.cc
index 0f9c4212ef..458d100810 100644
--- a/src/lib/dhcpsrv/host.cc
+++ b/src/lib/dhcpsrv/host.cc
@@ -106,7 +106,9 @@ IPv6Resrv::set(const Type& type, const asiolink::IOAddress& prefix,
isc_throw(isc::BadValue, "invalid prefix length '"
<< static_cast<int>(prefix_len)
<< "' for reserved IPv6 address, expected 128");
- } else if ((type == TYPE_PD) && (prefix_len != 128)) {
+ }
+ /* uncomment if strict prefix and prefix length is required. see #2943
+ else if ((type == TYPE_PD) && (prefix_len != 128)) {
IOAddress first_address = firstAddrInPrefix(prefix, prefix_len);
if (first_address != prefix) {
isc_throw(BadValue, "Invalid host address boundaries: " << prefix
@@ -114,6 +116,7 @@ IPv6Resrv::set(const Type& type, const asiolink::IOAddress& prefix,
<< "/" << static_cast<uint32_t>(prefix_len));
}
}
+ */
type_ = type;
prefix_ = prefix;
diff --git a/src/lib/dhcpsrv/lease.cc b/src/lib/dhcpsrv/lease.cc
index 375a6fc032..6dfeaaa2de 100644
--- a/src/lib/dhcpsrv/lease.cc
+++ b/src/lib/dhcpsrv/lease.cc
@@ -461,7 +461,9 @@ Lease6::Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr,
if (prefixlen != 128) {
if (type != Lease::TYPE_PD) {
isc_throw(BadValue, "prefixlen must be 128 for non prefix type");
- } else {
+ }
+ /* uncomment if strict prefix and prefix length is required. see #2943
+ else {
IOAddress first_address = firstAddrInPrefix(addr, prefixlen);
if (first_address != addr) {
isc_throw(BadValue, "Invalid lease address boundaries: " << addr
@@ -469,6 +471,7 @@ Lease6::Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr,
<< "/" << static_cast<uint32_t>(prefixlen));
}
}
+ */
}
cltt_ = time(NULL);
@@ -493,7 +496,9 @@ Lease6::Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr,
if (prefixlen != 128) {
if (type != Lease::TYPE_PD) {
isc_throw(BadValue, "prefixlen must be 128 for non prefix type");
- } else {
+ }
+ /* uncomment if strict prefix and prefix length is required. see #2943
+ else {
IOAddress first_address = firstAddrInPrefix(addr, prefixlen);
if (first_address != addr) {
isc_throw(BadValue, "Invalid lease address boundaries: " << addr
@@ -501,6 +506,7 @@ Lease6::Lease6(Lease::Type type, const isc::asiolink::IOAddress& addr,
<< "/" << static_cast<uint32_t>(prefixlen));
}
}
+ */
}
cltt_ = time(NULL);
diff --git a/src/lib/dhcpsrv/tests/host_unittest.cc b/src/lib/dhcpsrv/tests/host_unittest.cc
index 042e7de244..170d9b3eb3 100644
--- a/src/lib/dhcpsrv/tests/host_unittest.cc
+++ b/src/lib/dhcpsrv/tests/host_unittest.cc
@@ -86,13 +86,14 @@ TEST(IPv6ResrvTest, constructiorInvalidPrefixLength) {
EXPECT_THROW_MSG(IPv6Resrv(IPv6Resrv::TYPE_NA,
IOAddress("2001:db8:1::"), 64),
isc::BadValue, expected);
-
+ /* uncomment if strict prefix and prefix length is required. see #2943
// Check for extra specified bits in prefix.
expected = "Invalid host address boundaries: 2001:db8:1:: is not the first "
"address in prefix: 2001:db8::/32";
EXPECT_THROW_MSG(IPv6Resrv(IPv6Resrv::TYPE_PD,
IOAddress("2001:db8:1::"), 32),
isc::BadValue, expected);
+ */
}
// This test verifies that it is possible to modify prefix and its
@@ -123,13 +124,14 @@ TEST(IPv6ResrvTest, setPrefix) {
EXPECT_THROW_MSG(resrv.set(IPv6Resrv::TYPE_PD,
IOAddress("2001:db8:1::"), 129),
isc::BadValue, expected);
-
+ /* uncomment if strict prefix and prefix length is required. see #2943
// Check for extra specified bits in prefix.
expected = "Invalid host address boundaries: 2001:db8:1:: is not the first "
"address in prefix: 2001:db8::/32";
EXPECT_THROW_MSG(resrv.set(IPv6Resrv::TYPE_PD,
IOAddress("2001:db8:1::"), 32),
isc::BadValue, expected);
+ */
}
// This test checks that the equality operators work fine.
diff --git a/src/lib/dhcpsrv/tests/lease_unittest.cc b/src/lib/dhcpsrv/tests/lease_unittest.cc
index a3cfb86615..7608d40f4c 100644
--- a/src/lib/dhcpsrv/tests/lease_unittest.cc
+++ b/src/lib/dhcpsrv/tests/lease_unittest.cc
@@ -657,6 +657,7 @@ TEST(Lease6Test, constructorDefault) {
subnet_id, true, true, "", HWAddrPtr())),
BadValue, "DUID is mandatory for an IPv6 lease");
+ /* uncomment if strict prefix and prefix length is required. see #2943
// Lease6 must have a valid prefix and prefix length.
addr = IOAddress(ADDRESS[5]);
EXPECT_THROW_MSG(lease2.reset(new Lease6(Lease::TYPE_PD, addr,
@@ -670,6 +671,7 @@ TEST(Lease6Test, constructorDefault) {
subnet_id, true, true, "", HWAddrPtr(), 16)),
BadValue, "Invalid lease address boundaries: 8000::1 is not "
"the first address in prefix: 8000::/16");
+ */
// Lease6 must have a prefixlen set to 128 for non prefix type.
addr = IOAddress(ADDRESS[4]);