]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#3781] Append zero to generated v6 FQDNs
authorThomas Markwalder <tmark@isc.org>
Tue, 25 Mar 2025 19:35:56 +0000 (15:35 -0400)
committerThomas Markwalder <tmark@isc.org>
Tue, 25 Mar 2025 19:35:56 +0000 (15:35 -0400)
/doc/sphinx/arm/dhcp6-srv.rst
    Updated the arm

/src/lib/dhcpsrv/d2_client_mgr.cc
    D2ClientMgr::generateFqdn() - modified to append zero
    to names that end in hyphen.

/src/lib/dhcpsrv/tests/d2_client_unittest.cc
    TEST_F(D2ClientMgrParamsTest, generateFqdn) - updated test

changelog_unreleased/3781-kea-dhcpv6-synthesized-hostnames-invalid-for-ddns-if-last-quartet-is-zero [new file with mode: 0644]
doc/sphinx/arm/dhcp6-srv.rst
src/lib/dhcpsrv/d2_client_mgr.cc
src/lib/dhcpsrv/tests/d2_client_unittest.cc

diff --git a/changelog_unreleased/3781-kea-dhcpv6-synthesized-hostnames-invalid-for-ddns-if-last-quartet-is-zero b/changelog_unreleased/3781-kea-dhcpv6-synthesized-hostnames-invalid-for-ddns-if-last-quartet-is-zero
new file mode 100644 (file)
index 0000000..f7af26c
--- /dev/null
@@ -0,0 +1,5 @@
+[bug]          tmark
+       When generating FQDNs from IP addresses for DDNS,
+       kea-dhcp6 will now append a zero to the end of
+       prefixes that would otherwise end in a hyphen.
+       (Gitlab #3781)
index 17b06270bca875b4b65cbea247fc45ba4002b121..2064ada15ad645dfe01e7ff7d78bd8feabc6e56f 100644 (file)
@@ -3758,6 +3758,10 @@ qualifying suffix is "example.com", and the default value is used for
 
 ``myhost-3001-1--70E.example.com.``
 
+As of Kea 2.7.8, generated prefixes that would have ended in a hyphen
+will have a zero appended to the end. For example, the generated prefix
+for the address "2001:db8:1::" would be "myhost-2001-db8-1--0".
+
 .. _dhcp6-host-name-sanitization:
 
 Sanitizing Client FQDN Names
index 6b5e4a4e4ec30ee97321e8b01f380971b078ea1a..4eb58d23c06fd59fe2863b9af82c70e315d6c2b2 100644 (file)
@@ -173,6 +173,10 @@ D2ClientMgr::generateFqdn(const asiolink::IOAddress& address,
     std::replace(hostname.begin(), hostname.end(),
                  (address.isV4() ? '.' : ':'), '-');
 
+    if (*(hostname.rbegin()) == '-') {
+        hostname.append("0");
+    }
+
     std::ostringstream gen_name;
     gen_name << ddns_params.getGeneratedPrefix() << "-" << hostname;
     return (qualifyName(gen_name.str(), ddns_params, trailing_dot));
index 3ca6b7eeeb5397b6ad85dc690b49da17f23bd3a6..842cc827611542e62c99e91a99161baedd85e870 100644 (file)
@@ -745,6 +745,11 @@ TEST_F(D2ClientMgrParamsTest, generateFqdn) {
     EXPECT_EQ("prefix-2001-db8--2.suffix.com.",
               mgr.generateFqdn(v6address, *ddns_params_, do_dot));
 
+    // Verify that it appends a zero when v6 address ends in colon.
+    asiolink::IOAddress v6address2("2001:db8::");
+    EXPECT_EQ("prefix-2001-db8--0.suffix.com.",
+              mgr.generateFqdn(v6address2, *ddns_params_, do_dot));
+
     // Create a disabled config.
     subnet_->setDdnsSendUpdates(false);