From: Tomek Mrugalski Date: Wed, 7 Nov 2012 20:19:53 +0000 (-0500) Subject: [2414] Removed hardcoded DNS_SERVERS option X-Git-Tag: trac2487_base~1^2~31^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d9c83375c4fd9d67436030bbfc6f285e271d399;p=thirdparty%2Fkea.git [2414] Removed hardcoded DNS_SERVERS option DNS_SERVERS option is now sent only if requested by clients (as it should be) --- diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index a7490359dd..0652eb9a9e 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -49,8 +49,6 @@ using namespace isc::util; using namespace std; using namespace boost; -const std::string HARDCODED_DNS_SERVER = "2001:db8:1::1"; - Dhcpv6Srv::Dhcpv6Srv(uint16_t port) { LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_OPEN_SOCKET).arg(port); @@ -322,18 +320,7 @@ void Dhcpv6Srv::appendDefaultOptions(const Pkt6Ptr& question, Pkt6Ptr& answer) { .arg(question->getRemoteAddr().toText()); return; } - // Add DNS_SERVERS option. It should have been configured. - const Subnet::OptionContainer& options = subnet->getOptions(); - const Subnet::OptionContainerTypeIndex& idx = options.get<1>(); - const Subnet::OptionContainerTypeRange range = - idx.equal_range(D6O_NAME_SERVERS); - // In theory we may have multiple options with the same - // option code. They are not differentiated right now - // until support for option spaces is implemented. - // Until that's the case, simply add the first found option. - if (std::distance(range.first, range.second) > 0) { - answer->addOption(range.first->option); - } + } void Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer) { @@ -345,11 +332,6 @@ void Dhcpv6Srv::appendRequestedOptions(const Pkt6Ptr& question, Pkt6Ptr& answer) return; } - // Add dns-servers option. - OptionPtr dnsservers(new Option6AddrLst(D6O_NAME_SERVERS, - IOAddress(HARDCODED_DNS_SERVER))); - answer->addOption(dnsservers); - // Client requests some options using ORO option. Try to // get this option from client's message. boost::shared_ptr > option_oro = diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc index ed4ab610ce..7f7072b3f2 100644 --- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc +++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc @@ -344,13 +344,16 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) { // We have not requested option with code 1000 so it should not // be included in the response. ASSERT_FALSE(adv->getOption(1000)); + ASSERT_FALSE(adv->getOption(D6O_NAME_SERVERS)); // Let's now request option with code 1000. // We expect that server will include this option in its reply. boost::shared_ptr > option_oro(new Option6IntArray(D6O_ORO)); - // Create vector with one code equal to 1000. - std::vector codes(1, 1000); + // Create vector with two option codes. + std::vector codes(2); + codes[0] = 1000; + codes[1] = D6O_NAME_SERVERS; // Pass this code to option. option_oro->setValues(codes); // Append ORO to SOLICIT message. @@ -407,7 +410,7 @@ TEST_F(Dhcpv6SrvTest, advertiseOptions) { // - copy of client-id // - server-id // - IA that includes IAADDR -TEST_F(Dhcpv6SrvTest, SolicitBasic2) { +TEST_F(Dhcpv6SrvTest, SolicitBasic) { boost::scoped_ptr srv; ASSERT_NO_THROW( srv.reset(new NakedDhcpv6Srv(0)) );