From: Razvan Becheriu Date: Wed, 24 Jul 2024 08:30:30 +0000 (+0300) Subject: [#3509] backported #3469 to Kea-2.6.1 X-Git-Tag: Kea-2.6.1~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a40670bc3e7fa8a3ec7f2e1ec13740771b2a042b;p=thirdparty%2Fkea.git [#3509] backported #3469 to Kea-2.6.1 --- diff --git a/ChangeLog b/ChangeLog index e101ca3f39..d42d6c9aa0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2252. [bug] tmark, razvan + Corrected an issue in MySQL config back end that + causes preferred life time values to be overwritten + when updating client classes via remote-set-class6. + command. + (Gitlab #3509, #3469) + 2251. [build] razvan The library version numbers have been bumped up for the Kea 2.6.1 stable release. @@ -17,6 +24,7 @@ sometimes not returned when they were specified at the subnet, shared network or client class level. (Gitlab #3485) + 2248. [bug] razvan Fixed a file descriptor leak in the High Availability hook library. diff --git a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc index 76c295b4f0..fa3b457fff 100644 --- a/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc +++ b/src/hooks/dhcp/mysql_cb/mysql_cb_dhcp6.cc @@ -3118,7 +3118,7 @@ public: // If position is not specified, leave the class at the same position. // Remove the binding which specifies the position and use different // query. - in_bindings.erase(in_bindings.begin() + 10, in_bindings.begin() + 11); + in_bindings.erase(in_bindings.begin() + 7, in_bindings.begin() + 8); conn_.updateDeleteQuery(MySqlConfigBackendDHCPv6Impl::UPDATE_CLIENT_CLASS6_SAME_POSITION, in_bindings); } else { diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc index 56e404a54a..e01d21fa83 100644 --- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp4_unittest.cc @@ -4187,6 +4187,11 @@ GenericConfigBackendDHCPv4Test::createUpdateClientClass4OptionsTest() { ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass4(ServerSelector::ALL(), class1->getName())); ASSERT_TRUE(client_class); + // Verify lifetime values. + EXPECT_EQ(30, client_class->getValid().getMin()); + EXPECT_EQ(60, client_class->getValid().get()); + EXPECT_EQ(90, client_class->getValid().getMax()); + // Validate options belonging to the class. ASSERT_TRUE(client_class->getCfgOption()); OptionDescriptor returned_opt_boot_file_name = @@ -4232,6 +4237,11 @@ GenericConfigBackendDHCPv4Test::createUpdateClientClass4OptionsTest() { ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass4(ServerSelector::ALL(), class1->getName())); ASSERT_TRUE(client_class); + // Re-check lifetime values. This ensure bindings line up. + EXPECT_EQ(30, client_class->getValid().getMin()); + EXPECT_EQ(60, client_class->getValid().get()); + EXPECT_EQ(90, client_class->getValid().getMax()); + // Ensure that the first option definition is gone. ASSERT_TRUE(client_class->getCfgOptionDef()); returned_def_foo = client_class->getCfgOptionDef()->get(test_option_defs_[0]->getOptionSpaceName(), diff --git a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc index ea453ac525..e42c0182ff 100644 --- a/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc +++ b/src/lib/dhcpsrv/testutils/generic_cb_dhcp6_unittest.cc @@ -4271,6 +4271,9 @@ GenericConfigBackendDHCPv6Test::getClientClass6Test() { EXPECT_EQ(30, client_class->getValid().getMin()); EXPECT_EQ(60, client_class->getValid().get()); EXPECT_EQ(90, client_class->getValid().getMax()); + EXPECT_EQ(25, client_class->getPreferred().getMin()); + EXPECT_EQ(55, client_class->getPreferred().get()); + EXPECT_EQ(85, client_class->getPreferred().getMax()); // Validate options belonging to this class. ASSERT_TRUE(client_class->getCfgOption()); @@ -4338,6 +4341,14 @@ GenericConfigBackendDHCPv6Test::createUpdateClientClass6OptionsTest() { ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::ALL(), class1->getName())); ASSERT_TRUE(client_class); + // Verify lifetime values. + EXPECT_EQ(30, client_class->getValid().getMin()); + EXPECT_EQ(60, client_class->getValid().get()); + EXPECT_EQ(90, client_class->getValid().getMax()); + EXPECT_EQ(25, client_class->getPreferred().getMin()); + EXPECT_EQ(55, client_class->getPreferred().get()); + EXPECT_EQ(85, client_class->getPreferred().getMax()); + // Validate options belonging to the class. ASSERT_TRUE(client_class->getCfgOption()); OptionDescriptor returned_opt_new_posix_timezone = @@ -4383,6 +4394,14 @@ GenericConfigBackendDHCPv6Test::createUpdateClientClass6OptionsTest() { ASSERT_NO_THROW_LOG(client_class = cbptr_->getClientClass6(ServerSelector::ALL(), class1->getName())); ASSERT_TRUE(client_class); + // Re-check lifetime values. This ensure bindings line up. + EXPECT_EQ(30, client_class->getValid().getMin()); + EXPECT_EQ(60, client_class->getValid().get()); + EXPECT_EQ(90, client_class->getValid().getMax()); + EXPECT_EQ(25, client_class->getPreferred().getMin()); + EXPECT_EQ(55, client_class->getPreferred().get()); + EXPECT_EQ(85, client_class->getPreferred().getMax()); + // Ensure that the first option definition is gone. ASSERT_TRUE(client_class->getCfgOptionDef()); returned_def_foo = client_class->getCfgOptionDef()->get(test_option_defs_[0]->getOptionSpaceName(),