diff --git a/doc/sphinx/arm/dhcp4-srv.rst b/doc/sphinx/arm/dhcp4-srv.rst index 895bf21f4c..2f6c1b9dc1 100644 --- a/doc/sphinx/arm/dhcp4-srv.rst +++ b/doc/sphinx/arm/dhcp4-srv.rst @@ -3409,7 +3409,6 @@ The default configuration and values would appear as follows: "ddns-qualifying-suffix": "", "ddns-update-on-renew": false, "ddns-use-conflict-resolution": true, - "ddns-ttl-percent": 0.75, "hostname-char-set": "", "hostname-char-replacement": "" ... diff --git a/doc/sphinx/arm/dhcp6-srv.rst b/doc/sphinx/arm/dhcp6-srv.rst index f506d317e6..59c7c3eadd 100644 --- a/doc/sphinx/arm/dhcp6-srv.rst +++ b/doc/sphinx/arm/dhcp6-srv.rst @@ -2992,7 +2992,6 @@ The default configuration and values would appear as follows: "ddns-qualifying-suffix": "", "ddns-update-on-renew": false, "ddns-use-conflict-resolution": true, - "ddns-ttl-percent": 0.75, "hostname-char-set": "", "hostname-char-replacement": "" ... diff --git a/src/bin/dhcp6/tests/fqdn_unittest.cc b/src/bin/dhcp6/tests/fqdn_unittest.cc index f91342fa1d..2c7ae7d0c1 100644 --- a/src/bin/dhcp6/tests/fqdn_unittest.cc +++ b/src/bin/dhcp6/tests/fqdn_unittest.cc @@ -2144,8 +2144,8 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRenew) { } } -// Verify that ddns-ttl-percent can be used to calculate -// NCR lifetime. +// Verify that when specified ddns-ttl-percent is used to calculate +// the lease length in an NCR. TEST_F(FqdnDhcpv6SrvTest, ddnsTtlPercent) { // Create Reply message with Client Id and Server id. Pkt6Ptr answer = generateMessageWithIds(DHCPV6_REPLY); @@ -2178,5 +2178,4 @@ TEST_F(FqdnDhcpv6SrvTest, ddnsTtlPercent) { 0, 500, "", false, subnet_->getDdnsTtlPercent()); } - } // end of anonymous namespace diff --git a/src/lib/dhcpsrv/ncr_generator.cc b/src/lib/dhcpsrv/ncr_generator.cc index 42ead6c2ee..4646ef8b98 100644 --- a/src/lib/dhcpsrv/ncr_generator.cc +++ b/src/lib/dhcpsrv/ncr_generator.cc @@ -32,7 +32,6 @@ namespace { /// @param label Client identification information in the textual format. /// This is used for logging purposes. /// @param subnet subnet to which the lease belongs. -/// use conflict resolution. /// /// @tparam LeasePtrType Pointer to a lease. /// @tparam IdentifierType HW Address, Client Identifier or DUID. @@ -130,7 +129,7 @@ void queueNCR(const NameChangeType& chg_type, const Lease6Ptr& lease) { uint32_t calculateDdnsTtl(uint32_t lease_lft, const util::Optional& ddns_ttl_percent) { // If we have a configured percentage use it to calculate TTL. - if (!ddns_ttl_percent.unspecified() && (ddns_ttl_percent.get() > 0.0000)) { + if (!ddns_ttl_percent.unspecified() && (ddns_ttl_percent.get() > 0.0)) { uint32_t new_lft = static_cast(round(ddns_ttl_percent.get() * lease_lft)); if (new_lft > 0) { return (new_lft); diff --git a/src/lib/dhcpsrv/parsers/base_network_parser.h b/src/lib/dhcpsrv/parsers/base_network_parser.h index 7ba01f70e7..19a1e1b3bd 100644 --- a/src/lib/dhcpsrv/parsers/base_network_parser.h +++ b/src/lib/dhcpsrv/parsers/base_network_parser.h @@ -99,6 +99,7 @@ protected: /// - ddns-generated-prefix /// - ddns-qualifying-suffix /// - ddns-use-conflict-resolution + /// - ddns-update-on-renew /// - ddns-ttl-percent /// /// @param network_data Data element holding shared network diff --git a/src/lib/dhcpsrv/srv_config.h b/src/lib/dhcpsrv/srv_config.h index 6bc66e596c..c3d1b571f7 100644 --- a/src/lib/dhcpsrv/srv_config.h +++ b/src/lib/dhcpsrv/srv_config.h @@ -155,7 +155,7 @@ public: /// This value, if greater than zero, is used to calculate the lease lifetime /// passed to D2 in the NCR. Otherwise the value is calculated per RFC 4702. /// - /// @return True if conflict resolution should be used. + /// @return TTL percent as an Optional. util::Optional getTtlPercent() const; /// @brief Returns the subnet-id of the subnet associated with these parameters diff --git a/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc b/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc index 9f157bf2db..8915dfbd82 100644 --- a/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc +++ b/src/lib/dhcpsrv/tests/client_class_def_parser_unittest.cc @@ -2072,7 +2072,7 @@ TEST_F(ClientClassDefParserTest, offerLft) { auto offer_lft = cclass->getOfferLft(); ASSERT_FALSE(offer_lft.unspecified()); - EXPECT_EQ(99, offer_lft); + EXPECT_EQ(99, offer_lft.get()); } // Test verifies that the parser rejects bogus offer-lifetime value. diff --git a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc index 4cbe1d7707..acc7f3a713 100644 --- a/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc +++ b/src/lib/dhcpsrv/tests/ncr_generator_unittest.cc @@ -732,6 +732,10 @@ TEST_F(NCRGenerator4Test, withTtlPercent) { "000001E356D43E5F0A496D65BCA24D982D646140813E3" "B03AB370BFF46BFA309AE7BFD", true, ttl_percent); } + + double dnum = -1.0; + uint32_t inum = static_cast(round(dnum * 3400)); + std::cout << "inums is: " << inum << std::endl; }