+2232. [func]* fdupont
+ Configurations which contain subnets without explicit
+ subnet identifiers (without "id" entry) are now rejected:
+ subnet identifiers are no longer auto-generated.
+ (Gitlab #2961)
+
2231. [func] fdupont
The "ip-address" parameter in the "relay" element
is no longer supported: it was replaced by
EXPECT_EQ(1, subnet->getID());
}
-// Goal of this test is to verify that multiple subnets get unique
-// subnet-ids. Also, test checks that it's possible to do reconfiguration
-// multiple times.
-TEST_F(Dhcp4ParserTest, multipleSubnets) {
- ConstElementPtr x;
- // Collection of four subnets for which subnet ids should be
- // autogenerated - ids are unspecified or set to 0.
- string config = "{ " + genIfaceConfig() + "," +
- "\"rebind-timer\": 2000, "
- "\"renew-timer\": 1000, "
- "\"subnet4\": [ { "
- " \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
- " \"subnet\": \"192.0.2.0/24\" "
- " },"
- " {"
- " \"pools\": [ { \"pool\": \"192.0.3.101 - 192.0.3.150\" } ],"
- " \"subnet\": \"192.0.3.0/24\", "
- " \"id\": 0 "
- " },"
- " {"
- " \"pools\": [ { \"pool\": \"192.0.4.101 - 192.0.4.150\" } ],"
- " \"subnet\": \"192.0.4.0/24\" "
- " },"
- " {"
- " \"pools\": [ { \"pool\": \"192.0.5.101 - 192.0.5.150\" } ],"
- " \"subnet\": \"192.0.5.0/24\" "
- " } ],"
- "\"valid-lifetime\": 4000 }";
-
- ConstElementPtr json;
- ASSERT_NO_THROW(json = parseDHCP4(config));
-
- int cnt = 0; // Number of reconfigurations
-
- do {
- EXPECT_NO_THROW(x = Dhcpv4SrvTest::configure(*srv_, json));
- checkResult(x, 0);
-
- CfgMgr::instance().commit();
-
- const Subnet4Collection* subnets =
- CfgMgr::instance().getCurrentCfg()->getCfgSubnets4()->getAll();
- ASSERT_TRUE(subnets);
- ASSERT_EQ(4, subnets->size()); // We expect 4 subnets
-
- // Check subnet-ids of each subnet (it should be monotonously increasing)
- auto subnet = subnets->begin();
- EXPECT_EQ(1, (*subnet)->getID());
- EXPECT_EQ(2, (*++subnet)->getID());
- EXPECT_EQ(3, (*++subnet)->getID());
- EXPECT_EQ(4, (*++subnet)->getID());
-
- // Repeat reconfiguration process 10 times and check that the subnet-id
- // is set to the same value. Technically, just two iterations would be
- // sufficient, but it's nice to have a test that exercises reconfiguration
- // a bit.
- } while (++cnt < 10);
-}
-
// This test checks that it is possible to assign arbitrary ids for subnets.
TEST_F(Dhcp4ParserTest, multipleSubnetsExplicitIDs) {
ConstElementPtr x;
"\"renew-timer\": 1000, "
"\"subnet4\": [ "
"{"
+ " \"id\": 1,"
" \"pools\": [ { \"pool\": \"192.0.2.1 - 192.0.2.100\" } ],"
" \"ddns-conflict-resolution-mode\": \"check-with-dhcid\","
" \"subnet\": \"192.0.2.0/24\""
"},"
"{"
+ " \"id\": 2,"
" \"pools\": [ { \"pool\": \"192.0.3.1 - 192.0.3.100\" } ],"
" \"ddns-conflict-resolution-mode\": \"check-exists-with-dhcid\","
" \"subnet\": \"192.0.3.0/24\""
"},"
"{"
+ " \"id\": 3,"
" \"pools\": [ { \"pool\": \"192.0.4.1 - 192.0.4.100\" } ],"
" \"ddns-conflict-resolution-mode\": \"no-check-without-dhcid\","
" \"subnet\": \"192.0.4.0/24\""
"},"
"{"
+ " \"id\": 4,"
" \"pools\": [ { \"pool\": \"192.0.5.1 - 192.0.5.100\" } ],"
" \"ddns-conflict-resolution-mode\": \"no-check-with-dhcid\","
" \"subnet\": \"192.0.5.0/24\""
"},"
"{"
+ " \"id\": 5,"
" \"pools\": [ { \"pool\": \"192.0.6.1 - 192.0.6.100\" } ],"
" \"subnet\": \"192.0.6.0/24\""
"} ],"
" \"subnet4\": [\n"
" {\n"
" \"ddns-conflict-resolution-mode\": \"check-with-dhcid\",\n"
+" \"id\": 1,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"192.0.2.1 - 192.0.2.100\"\n"
" },\n"
" {\n"
" \"ddns-conflict-resolution-mode\": \"check-exists-with-dhcid\",\n"
+" \"id\": 2,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"192.0.3.1 - 192.0.3.100\"\n"
" },\n"
" {\n"
" \"ddns-conflict-resolution-mode\": \"no-check-without-dhcid\",\n"
+" \"id\": 3,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"192.0.4.1 - 192.0.4.100\"\n"
" },\n"
" {\n"
" \"ddns-conflict-resolution-mode\": \"no-check-with-dhcid\",\n"
+" \"id\": 4,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"192.0.5.1 - 192.0.5.100\"\n"
" \"subnet\": \"192.0.5.0/24\"\n"
" },\n"
" {\n"
+" \"id\": 5,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"192.0.6.1 - 192.0.6.100\"\n"
-// Copyright (C) 2016-2022 Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2016-2024 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
ConstElementPtr subnet = subnets->get(0);
ASSERT_TRUE(subnet);
- // we should have "id" parameter with the default value of 0 added for us.
- checkIntegerValue(subnet, "id", 0);
+ // no "id" where added.
+ ASSERT_FALSE(subnet->get("id"));
}
// This test checks if the parameters in option-data are assigned default values
EXPECT_EQ(1, subnet->getID());
}
-// This test checks that multiple subnets can be defined and handled properly.
-TEST_F(Dhcp6ParserTest, multipleSubnets) {
- ConstElementPtr x;
- // Collection of four subnets for which ids should be autogenerated
- // - ids are unspecified or set to 0.
- string config = "{ " + genIfaceConfig() + ","
- "\"preferred-lifetime\": 3000,"
- "\"rebind-timer\": 2000, "
- "\"renew-timer\": 1000, "
- "\"subnet6\": [ { "
- " \"pools\": [ { \"pool\": \"2001:db8:1::/80\" } ],"
- " \"subnet\": \"2001:db8:1::/64\" "
- " },"
- " {"
- " \"pools\": [ { \"pool\": \"2001:db8:2::/80\" } ],"
- " \"subnet\": \"2001:db8:2::/64\", "
- " \"id\": 0"
- " },"
- " {"
- " \"pools\": [ { \"pool\": \"2001:db8:3::/80\" } ],"
- " \"subnet\": \"2001:db8:3::/64\" "
- " },"
- " {"
- " \"pools\": [ { \"pool\": \"2001:db8:4::/80\" } ],"
- " \"subnet\": \"2001:db8:4::/64\" "
- " } ],"
- "\"valid-lifetime\": 4000 }";
-
- int cnt = 0; // Number of reconfigurations
-
- ConstElementPtr json;
- ASSERT_NO_THROW(json = parseDHCP6(config));
-
- do {
- EXPECT_NO_THROW(x = Dhcpv6SrvTest::configure(srv_, json));
- checkResult(x, 0);
-
- CfgMgr::instance().commit();
-
- const Subnet6Collection* subnets =
- CfgMgr::instance().getCurrentCfg()->getCfgSubnets6()->getAll();
- ASSERT_TRUE(subnets);
- ASSERT_EQ(4, subnets->size()); // We expect 4 subnets
-
- // Check subnet-ids of each subnet (it should be monotonously increasing)
- auto subnet = subnets->begin();
- EXPECT_EQ(1, (*subnet)->getID());
- EXPECT_EQ(2, (*++subnet)->getID());
- EXPECT_EQ(3, (*++subnet)->getID());
- EXPECT_EQ(4, (*++subnet)->getID());
-
- // Repeat reconfiguration process 10 times and check that the subnet-id
- // is set to the same value. Technically, just two iterations would be
- // sufficient, but it's nice to have a test that exercises reconfiguration
- // a bit.
- } while (++cnt < 10);
-}
-
// This test checks that it is possible to assign arbitrary ids for subnets.
TEST_F(Dhcp6ParserTest, multipleSubnetsExplicitIDs) {
ConstElementPtr x;
"\"renew-timer\": 1000, "
"\"subnet6\": [ "
"{ "
+ " \"id\": 1,"
" \"pools\": [ { \"pool\": \"2001:db8:1::1 - 2001:db8:1::ffff\" } ],"
" \"ddns-conflict-resolution-mode\": \"check-with-dhcid\","
" \"subnet\": \"2001:db8:1::/64\""
"},"
"{ "
+ " \"id\": 2,"
" \"pools\": [ { \"pool\": \"2001:db8:2::1 - 2001:db8:2::ffff\" } ],"
" \"ddns-conflict-resolution-mode\": \"check-exists-with-dhcid\","
" \"subnet\": \"2001:db8:2::/64\""
"},"
"{"
+ " \"id\": 3,"
" \"pools\": [ { \"pool\": \"2001:db8:3::1 - 2001:db8:3::ffff\" } ],"
" \"ddns-conflict-resolution-mode\": \"no-check-without-dhcid\","
" \"subnet\": \"2001:db8:3::/64\""
"},"
"{"
+ " \"id\": 4,"
" \"pools\": [ { \"pool\": \"2001:db8:4::1 - 2001:db8:4::ffff\" } ],"
" \"ddns-conflict-resolution-mode\": \"no-check-with-dhcid\","
" \"subnet\": \"2001:db8:4::/64\""
"},"
"{"
+ " \"id\": 5,"
" \"pools\": [ { \"pool\": \"2001:db8:5::1 - 2001:db8:5::ffff\" } ],"
" \"subnet\": \"2001:db8:5::/64\""
"} ],"
" \"subnet6\": [\n"
" {\n"
" \"ddns-conflict-resolution-mode\": \"check-with-dhcid\",\n"
+" \"id\": 1,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"2001:db8:1::1 - 2001:db8:1::ffff\"\n"
" },\n"
" {\n"
" \"ddns-conflict-resolution-mode\": \"check-exists-with-dhcid\",\n"
+" \"id\": 2,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"2001:db8:2::1 - 2001:db8:2::ffff\"\n"
" },\n"
" {\n"
" \"ddns-conflict-resolution-mode\": \"no-check-without-dhcid\",\n"
+" \"id\": 3,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"2001:db8:3::1 - 2001:db8:3::ffff\"\n"
" },\n"
" {\n"
" \"ddns-conflict-resolution-mode\": \"no-check-with-dhcid\",\n"
+" \"id\": 4,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"2001:db8:4::1 - 2001:db8:4::ffff\"\n"
" \"subnet\": \"2001:db8:4::/64\"\n"
" },\n"
" {\n"
+" \"id\": 5,\n"
" \"pools\": [\n"
" {\n"
" \"pool\": \"2001:db8:5::1 - 2001:db8:5::ffff\"\n"
ConstElementPtr subnet = subnets->get(0);
ASSERT_TRUE(subnet);
- // we should have "id" parameter with the default value of 0 added for us.
- checkIntegerValue(subnet, "id", 0);
+ // no "id" where added.
+ ASSERT_FALSE(subnet->get("id"));
}
// This test checks if the parameters in option-data are assigned default values
},
\"subnet4\": [
{
+ \"id\": 1,
\"subnet\": \"10.0.0.0/24\",
\"pools\": [ { \"pool\": \"10.0.0.10-10.0.0.100\" } ]
} ],
},
\"subnet6\": [
{
+ \"id\": 1,
\"subnet\": \"2001:db8:1::/64\",
\"pools\": [ { \"pool\": \"2001:db8:1::10-2001:db8:1::100\" } ]
} ],
extern const isc::log::MessageID DHCPSRV_CFGMGR_USE_ALLOCATOR = "DHCPSRV_CFGMGR_USE_ALLOCATOR";
extern const isc::log::MessageID DHCPSRV_CFGMGR_USE_UNICAST = "DHCPSRV_CFGMGR_USE_UNICAST";
extern const isc::log::MessageID DHCPSRV_CLOSE_DB = "DHCPSRV_CLOSE_DB";
-extern const isc::log::MessageID DHCPSRV_CONFIGURED_SUBNET_WITHOUT_ID = "DHCPSRV_CONFIGURED_SUBNET_WITHOUT_ID";
extern const isc::log::MessageID DHCPSRV_DDNS_TTL_PERCENT_TOO_SMALL = "DHCPSRV_DDNS_TTL_PERCENT_TOO_SMALL";
extern const isc::log::MessageID DHCPSRV_DEPRECATED = "DHCPSRV_DEPRECATED";
extern const isc::log::MessageID DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET = "DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET";
"DHCPSRV_CFGMGR_USE_ALLOCATOR", "using the %1 allocator for %2 leases in subnet %3",
"DHCPSRV_CFGMGR_USE_UNICAST", "listening on unicast address %1, on interface %2",
"DHCPSRV_CLOSE_DB", "closing currently open %1 database",
- "DHCPSRV_CONFIGURED_SUBNET_WITHOUT_ID", "a subnet was configured without an id: %1",
"DHCPSRV_DDNS_TTL_PERCENT_TOO_SMALL", "ddns-ttl-percent %1 of lease lifetime %2 is too small, ignoring it",
"DHCPSRV_DEPRECATED", "This configuration is using a deprecated feature: %1",
"DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET", "received bad DHCPv4o6 packet: %1",
extern const isc::log::MessageID DHCPSRV_CFGMGR_USE_ALLOCATOR;
extern const isc::log::MessageID DHCPSRV_CFGMGR_USE_UNICAST;
extern const isc::log::MessageID DHCPSRV_CLOSE_DB;
-extern const isc::log::MessageID DHCPSRV_CONFIGURED_SUBNET_WITHOUT_ID;
extern const isc::log::MessageID DHCPSRV_DDNS_TTL_PERCENT_TOO_SMALL;
extern const isc::log::MessageID DHCPSRV_DEPRECATED;
extern const isc::log::MessageID DHCPSRV_DHCP4O6_RECEIVED_BAD_PACKET;
server closes the currently open database, and opens a database using
the new parameters.
-% DHCPSRV_CONFIGURED_SUBNET_WITHOUT_ID a subnet was configured without an id: %1
-A warning message issued when a subnet was configured with a zero or without
-an id, causing the server to auto-generate it. Using auto-generated subnet
-ids is now deprecated. Each configured subnet should have an explicit subnet id
-specified with the "id" entry. The sole argument of this warning message contains
-a subnet prefix.
-
% DHCPSRV_DDNS_TTL_PERCENT_TOO_SMALL ddns-ttl-percent %1 of lease lifetime %2 is too small, ignoring it
A debug message issued when the DDNS TTL value calculated using the
ddns-ttl-percent is zero. Kea will ignore the value and calculate