From: Marcin Siodelski Date: Mon, 27 Jan 2014 10:08:00 +0000 (+0100) Subject: [3295] Generate client FQDN using leased IP address. X-Git-Tag: bind10-1.2.0beta1-release~83^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=fcd99b14aaf1b7e5938f1ff66d434eabfcd2b698;p=thirdparty%2Fkea.git [3295] Generate client FQDN using leased IP address. --- diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 284e078ede..4ae64a850d 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -1017,13 +1017,14 @@ Dhcpv6Srv::processClientFqdn(const Pkt6Ptr& question, const Pkt6Ptr& answer) { // generate one. if (fqdn->getDomainNameType() == Option6ClientFqdn::PARTIAL) { std::ostringstream name; - if (fqdn->getDomainName().empty()) { - name << FQDN_GENERATED_PARTIAL_NAME; + if (fqdn->getDomainName().empty() || FQDN_REPLACE_CLIENT_NAME) { + fqdn->setDomainName("", Option6ClientFqdn::PARTIAL); + } else { name << fqdn->getDomainName(); + name << "." << FQDN_PARTIAL_SUFFIX; + fqdn_resp->setDomainName(name.str(), Option6ClientFqdn::FULL); } - name << "." << FQDN_PARTIAL_SUFFIX; - fqdn_resp->setDomainName(name.str(), Option6ClientFqdn::FULL); // Server may be configured to replace a name supplied by a client, // even if client supplied fully qualified domain-name. diff --git a/src/bin/dhcp6/tests/fqdn_unittest.cc b/src/bin/dhcp6/tests/fqdn_unittest.cc index 1e974e00c0..ecce409f82 100644 --- a/src/bin/dhcp6/tests/fqdn_unittest.cc +++ b/src/bin/dhcp6/tests/fqdn_unittest.cc @@ -266,7 +266,19 @@ public: EXPECT_EQ(flag_o, answ_fqdn->getFlag(Option6ClientFqdn::FLAG_O)); EXPECT_EQ(exp_domain_name, answ_fqdn->getDomainName()); - EXPECT_EQ(Option6ClientFqdn::FULL, answ_fqdn->getDomainNameType()); + // If server is configured to generate full FQDN for a client, and/or + // client sent empty FQDN the expected result of the processing by + // processClientFqdn is an empty, partial FQDN. This is an indication + // for the code which performs lease allocation that the FQDN has to + // be generated from the lease address. + if (exp_domain_name.empty()) { + EXPECT_EQ(Option6ClientFqdn::PARTIAL, + answ_fqdn->getDomainNameType()); + + } else { + EXPECT_EQ(Option6ClientFqdn::FULL, answ_fqdn->getDomainNameType()); + + } } /// @brief Tests that the client's message holding an FQDN is processed @@ -409,8 +421,7 @@ TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdatePartialName) { // that server performs AAAA update. TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdateNoName) { testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S, "", - Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S, - "myhost.example.com."); + Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S, ""); } // Test server's response when client requests no DNS update.