Skip to content

Commit 5bb91c7

Browse files
committed
[#3781] Append zero to generated v6 FQDNs
/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
1 parent 3dee914 commit 5bb91c7

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[bug] tmark
2+
When generating FQDNs from IP addresses for DDNS,
3+
kea-dhcp6 will now append a zero to the end of
4+
prefixes that would otherwise end in a hyphen.
5+
(Gitlab #3781)

doc/sphinx/arm/dhcp6-srv.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3758,6 +3758,10 @@ qualifying suffix is "example.com", and the default value is used for
37583758

37593759
``myhost-3001-1--70E.example.com.``
37603760

3761+
As of Kea 2.7.8, generated prefixes that would have ended in a hyphen
3762+
will have a zero appended to the end. For example, the generated prefix
3763+
for the address "2001:db8:1::" would be "myhost-2001-db8-1--0".
3764+
37613765
.. _dhcp6-host-name-sanitization:
37623766

37633767
Sanitizing Client FQDN Names

src/lib/dhcpsrv/d2_client_mgr.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ D2ClientMgr::generateFqdn(const asiolink::IOAddress& address,
173173
std::replace(hostname.begin(), hostname.end(),
174174
(address.isV4() ? '.' : ':'), '-');
175175

176+
if (*(hostname.rbegin()) == '-') {
177+
hostname.append("0");
178+
}
179+
176180
std::ostringstream gen_name;
177181
gen_name << ddns_params.getGeneratedPrefix() << "-" << hostname;
178182
return (qualifyName(gen_name.str(), ddns_params, trailing_dot));

src/lib/dhcpsrv/tests/d2_client_unittest.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,11 @@ TEST_F(D2ClientMgrParamsTest, generateFqdn) {
745745
EXPECT_EQ("prefix-2001-db8--2.suffix.com.",
746746
mgr.generateFqdn(v6address, *ddns_params_, do_dot));
747747

748+
// Verify that it appends a zero when v6 address ends in colon.
749+
asiolink::IOAddress v6address2("2001:db8::");
750+
EXPECT_EQ("prefix-2001-db8--0.suffix.com.",
751+
mgr.generateFqdn(v6address2, *ddns_params_, do_dot));
752+
748753
// Create a disabled config.
749754
subnet_->setDdnsSendUpdates(false);
750755

0 commit comments

Comments
 (0)