BIND 10 trac2414, updated. 9d9c83375c4fd9d67436030bbfc6f285e271d399 [2414] Removed hardcoded DNS_SERVERS option

BIND 10 source code commits bind10-changes at lists.isc.org
Wed Nov 7 20:20:40 UTC 2012


The branch, trac2414 has been updated
       via  9d9c83375c4fd9d67436030bbfc6f285e271d399 (commit)
       via  c778e931a645b277b7e18a83f702bb08a0173ffb (commit)
      from  aa1643faad572dfc6c91d0fac707f4cac4d5b7a6 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 9d9c83375c4fd9d67436030bbfc6f285e271d399
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Wed Nov 7 15:19:53 2012 -0500

    [2414] Removed hardcoded DNS_SERVERS option
    
    DNS_SERVERS option is now sent only if requested by clients
     (as it should be)

commit c778e931a645b277b7e18a83f702bb08a0173ffb
Author: Tomek Mrugalski <tomasz at isc.org>
Date:   Wed Nov 7 15:18:06 2012 -0500

    [2414] solicitBasic1 test fixed and renamed to advertiseOptions

-----------------------------------------------------------------------

Summary of changes:
 src/bin/dhcp6/dhcp6_srv.cc                |   20 +-----
 src/bin/dhcp6/tests/dhcp6_srv_unittest.cc |  105 +++++++----------------------
 2 files changed, 25 insertions(+), 100 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc
index a749035..0652eb9 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<Option6IntArray<uint16_t> > option_oro =
diff --git a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
index 7e9a395..7f7072b 100644
--- a/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
+++ b/src/bin/dhcp6/tests/dhcp6_srv_unittest.cc
@@ -293,15 +293,17 @@ TEST_F(Dhcpv6SrvTest, DUID) {
     }
 }
 
-TEST_F(Dhcpv6SrvTest, solicitBasic1) {
+// This test checks if Option Request Option (ORO) is parsed correctly
+// and the requested options are actually assigned.
+TEST_F(Dhcpv6SrvTest, advertiseOptions) {
     ConstElementPtr x;
     string config = "{ \"interface\": [ \"all\" ],"
         "\"preferred-lifetime\": 3000,"
         "\"rebind-timer\": 2000, "
         "\"renew-timer\": 1000, "
         "\"subnet6\": [ { "
-        "    \"pool\": [ \"2001:db8:1234::/80\" ],"
-        "    \"subnet\": \"2001:db8:1234::/64\", "
+        "    \"pool\": [ \"2001:db8:1::/64\" ],"
+        "    \"subnet\": \"2001:db8:1::/48\", "
         "    \"option-data\": [ {"
         "          \"name\": \"OPTION_DNS_SERVERS\","
         "          \"code\": 23,"
@@ -327,98 +329,43 @@ TEST_F(Dhcpv6SrvTest, solicitBasic1) {
 
     ASSERT_EQ(0, rcode_);
 
-    // a dummy content for client-id
-    OptionBuffer clntDuid(32);
-    for (int i = 0; i < 32; i++) {
-        clntDuid[i] = 100 + i;
-    }
-
-    Pkt6Ptr sol = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234));
-
-    boost::shared_ptr<Option6IA> ia =
-        boost::shared_ptr<Option6IA>(new Option6IA(D6O_IA_NA, 234));
-    ia->setT1(1501);
-    ia->setT2(2601);
-    sol->addOption(ia);
-
-    // Let's not send address in solicit yet
-    /*    boost::shared_ptr<Option6IAAddr>
-        addr(new Option6IAAddr(D6O_IAADDR, IOAddress("2001:db8:1234:ffff::ffff"), 5001, 7001));
-    ia->addOption(addr);
-    sol->addOption(ia); */
-
-    // constructed very simple SOLICIT message with:
-    // - client-id option (mandatory)
-    // - IA option (a request for address, without any addresses)
-
-    // expected returned ADVERTISE message:
-    // - copy of client-id
-    // - server-id
-    // - IA that includes IAADDR
-
-    OptionPtr clientid = OptionPtr(new Option(Option::V6, D6O_CLIENTID,
-                                              clntDuid.begin(),
-                                              clntDuid.begin() + 16));
+     Pkt6Ptr sol = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234));
+    sol->setRemoteAddr(IOAddress("fe80::abcd"));
+    sol->addOption(generateIA(234, 1500, 3000));
+    OptionPtr clientid = generateClientId();
     sol->addOption(clientid);
 
-    boost::shared_ptr<Pkt6> reply = srv->processSolicit(sol);
+    // Pass it to the server and get an advertise
+    boost::shared_ptr<Pkt6> adv = srv->processSolicit(sol);
 
     // check if we get response at all
-    ASSERT_TRUE(reply);
-
-    EXPECT_EQ(DHCPV6_ADVERTISE, reply->getType());
-    EXPECT_EQ(1234, reply->getTransid());
+    ASSERT_TRUE(adv);
 
     // We have not requested option with code 1000 so it should not
     // be included in the response.
-    ASSERT_FALSE(reply->getOption(1000));
+    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<Option6IntArray<uint16_t> >
         option_oro(new Option6IntArray<uint16_t>(D6O_ORO));
-    // Create vector with one code equal to 1000.
-    std::vector<uint16_t> codes(1, 1000);
+    // Create vector with two option codes.
+    std::vector<uint16_t> codes(2);
+    codes[0] = 1000;
+    codes[1] = D6O_NAME_SERVERS;
     // Pass this code to option.
     option_oro->setValues(codes);
     // Append ORO to SOLICIT message.
     sol->addOption(option_oro);
-    
-    // Need to process SOLICIT again after requesting new option.
-    reply = srv->processSolicit(sol);
-    ASSERT_TRUE(reply);
-
-    EXPECT_EQ(DHCPV6_ADVERTISE, reply->getType());
 
-    OptionPtr tmp = reply->getOption(D6O_IA_NA);
-    ASSERT_TRUE(tmp);
-
-    boost::shared_ptr<Option6IA> reply_ia =
-        boost::dynamic_pointer_cast<Option6IA>(tmp);
-    ASSERT_TRUE(reply_ia);
-    EXPECT_EQ(234, reply_ia->getIAID());
-
-    // check that there's an address included
-    EXPECT_TRUE(reply_ia->getOption(D6O_IAADDR));
+    // Need to process SOLICIT again after requesting new option.
+    adv = srv->processSolicit(sol);
+    ASSERT_TRUE(adv);
 
-    // check that server included our own client-id
-    tmp = reply->getOption(D6O_CLIENTID);
+    OptionPtr tmp = adv->getOption(D6O_NAME_SERVERS);
     ASSERT_TRUE(tmp);
-    EXPECT_EQ(clientid->getType(), tmp->getType());
-    ASSERT_EQ(clientid->len(), tmp->len());
 
-    EXPECT_TRUE(clientid->getData() == tmp->getData());
-
-    // check that server included its server-id
-    tmp = reply->getOption(D6O_SERVERID);
-    EXPECT_EQ(tmp->getType(), srv->getServerID()->getType());
-    ASSERT_EQ(tmp->len(),  srv->getServerID()->len());
-
-    EXPECT_TRUE(tmp->getData() == srv->getServerID()->getData());
- 
-    tmp = reply->getOption(D6O_NAME_SERVERS);
-    ASSERT_TRUE(tmp);
-    
     boost::shared_ptr<Option6AddrLst> reply_nameservers =
         boost::dynamic_pointer_cast<Option6AddrLst>(tmp);
     ASSERT_TRUE(reply_nameservers);
@@ -430,7 +377,7 @@ TEST_F(Dhcpv6SrvTest, solicitBasic1) {
 
     // There is a dummy option with code 1000 we requested from a server.
     // Expect that this option is in server's response.
-    tmp = reply->getOption(1000);
+    tmp = adv->getOption(1000);
     ASSERT_TRUE(tmp);
 
     // Check that the option contains valid data (from configuration).
@@ -463,18 +410,14 @@ TEST_F(Dhcpv6SrvTest, solicitBasic1) {
 // - copy of client-id
 // - server-id
 // - IA that includes IAADDR
-TEST_F(Dhcpv6SrvTest, SolicitBasic2) {
+TEST_F(Dhcpv6SrvTest, SolicitBasic) {
     boost::scoped_ptr<NakedDhcpv6Srv> srv;
     ASSERT_NO_THROW( srv.reset(new NakedDhcpv6Srv(0)) );
 
     Pkt6Ptr sol = Pkt6Ptr(new Pkt6(DHCPV6_SOLICIT, 1234));
-
     sol->setRemoteAddr(IOAddress("fe80::abcd"));
-
     sol->addOption(generateIA(234, 1500, 3000));
-
     OptionPtr clientid = generateClientId();
-
     sol->addOption(clientid);
 
     // Pass it to the server and get an advertise



More information about the bind10-changes mailing list