Browse Source

[3295] Function which processes FQDN option appends it to server's answer.

Marcin Siodelski 11 years ago
parent
commit
33210233e8
3 changed files with 29 additions and 28 deletions
  1. 9 7
      src/bin/dhcp6/dhcp6_srv.cc
  2. 3 1
      src/bin/dhcp6/dhcp6_srv.h
  3. 17 20
      src/bin/dhcp6/tests/fqdn_unittest.cc

+ 9 - 7
src/bin/dhcp6/dhcp6_srv.cc

@@ -965,7 +965,7 @@ Dhcpv6Srv::assignLeases(const Pkt6Ptr& question, Pkt6Ptr& answer,
 }
 }
 
 
 Option6ClientFqdnPtr
 Option6ClientFqdnPtr
-Dhcpv6Srv::processClientFqdn(const Pkt6Ptr& question) {
+Dhcpv6Srv::processClientFqdn(const Pkt6Ptr& question, const Pkt6Ptr& answer) {
     // Get Client FQDN Option from the client's message. If this option hasn't
     // Get Client FQDN Option from the client's message. If this option hasn't
     // been included, do nothing.
     // been included, do nothing.
     Option6ClientFqdnPtr fqdn = boost::dynamic_pointer_cast<
     Option6ClientFqdnPtr fqdn = boost::dynamic_pointer_cast<
@@ -1039,9 +1039,11 @@ Dhcpv6Srv::processClientFqdn(const Pkt6Ptr& question) {
 
 
     }
     }
 
 
-    // Return the FQDN option which can be included in the server's response.
-    // Note that it doesn't have to be included, if client didn't request
-    // it using ORO and server is not configured to always include it.
+    // The FQDN has been processed successfully. Let's append it to the
+    // response to be sent to a client. Note that the Client FQDN option is
+    // always sent back to the client if Client FQDN was included in the
+    // client's message.
+    answer->addOption(fqdn_resp);
     return (fqdn_resp);
     return (fqdn_resp);
 }
 }
 
 
@@ -2175,7 +2177,7 @@ Dhcpv6Srv::processSolicit(const Pkt6Ptr& solicit) {
     appendRequestedOptions(solicit, advertise);
     appendRequestedOptions(solicit, advertise);
     appendRequestedVendorOptions(solicit, advertise);
     appendRequestedVendorOptions(solicit, advertise);
 
 
-    Option6ClientFqdnPtr fqdn = processClientFqdn(solicit);
+    Option6ClientFqdnPtr fqdn = processClientFqdn(solicit, advertise);
     assignLeases(solicit, advertise, fqdn);
     assignLeases(solicit, advertise, fqdn);
     appendClientFqdn(solicit, advertise, fqdn);
     appendClientFqdn(solicit, advertise, fqdn);
     // Note, that we don't create NameChangeRequests here because we don't
     // Note, that we don't create NameChangeRequests here because we don't
@@ -2197,7 +2199,7 @@ Dhcpv6Srv::processRequest(const Pkt6Ptr& request) {
     appendRequestedOptions(request, reply);
     appendRequestedOptions(request, reply);
     appendRequestedVendorOptions(request, reply);
     appendRequestedVendorOptions(request, reply);
 
 
-    Option6ClientFqdnPtr fqdn = processClientFqdn(request);
+    Option6ClientFqdnPtr fqdn = processClientFqdn(request, reply);
     assignLeases(request, reply, fqdn);
     assignLeases(request, reply, fqdn);
     appendClientFqdn(request, reply, fqdn);
     appendClientFqdn(request, reply, fqdn);
     createNameChangeRequests(reply, fqdn);
     createNameChangeRequests(reply, fqdn);
@@ -2216,7 +2218,7 @@ Dhcpv6Srv::processRenew(const Pkt6Ptr& renew) {
     appendDefaultOptions(renew, reply);
     appendDefaultOptions(renew, reply);
     appendRequestedOptions(renew, reply);
     appendRequestedOptions(renew, reply);
 
 
-    Option6ClientFqdnPtr fqdn = processClientFqdn(renew);
+    Option6ClientFqdnPtr fqdn = processClientFqdn(renew, reply);
     renewLeases(renew, reply, fqdn);
     renewLeases(renew, reply, fqdn);
     appendClientFqdn(renew, reply, fqdn);
     appendClientFqdn(renew, reply, fqdn);
     createNameChangeRequests(reply, fqdn);
     createNameChangeRequests(reply, fqdn);

+ 3 - 1
src/bin/dhcp6/dhcp6_srv.h

@@ -376,9 +376,11 @@ protected:
     /// held in this function.
     /// held in this function.
     ///
     ///
     /// @param question Client's message.
     /// @param question Client's message.
+    /// @param answer Server's response to a client.
     ///
     ///
     /// @return FQDN option produced in the response to the client's message.
     /// @return FQDN option produced in the response to the client's message.
-    Option6ClientFqdnPtr processClientFqdn(const Pkt6Ptr& question);
+    Option6ClientFqdnPtr processClientFqdn(const Pkt6Ptr& question,
+                                           const Pkt6Ptr& answer);
 
 
     /// @brief Adds DHCPv6 Client FQDN %Option to the server response.
     /// @brief Adds DHCPv6 Client FQDN %Option to the server response.
     ///
     ///

+ 17 - 20
src/bin/dhcp6/tests/fqdn_unittest.cc

@@ -1,4 +1,4 @@
-// Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
+// Copyright (C) 2013-2014  Internet Systems Consortium, Inc. ("ISC")
 //
 //
 // Permission to use, copy, modify, and/or distribute this software for any
 // Permission to use, copy, modify, and/or distribute this software for any
 // purpose with or without fee is hereby granted, provided that the above
 // purpose with or without fee is hereby granted, provided that the above
@@ -227,9 +227,6 @@ public:
     /// This function verifies that the FQDN option returned is correct.
     /// This function verifies that the FQDN option returned is correct.
     ///
     ///
     /// @param msg_type A type of the client's message.
     /// @param msg_type A type of the client's message.
-    /// @param use_oro A boolean value which indicates whether the DHCPv6 ORO
-    /// option (requesting return of the FQDN option by the server) should be
-    /// included in the client's message (if true), or not included (if false).
     /// @param in_flags A value of flags field to be set for the FQDN carried
     /// @param in_flags A value of flags field to be set for the FQDN carried
     /// in the client's message.
     /// in the client's message.
     /// @param in_domain_name A domain name to be carried in the client's FQDN
     /// @param in_domain_name A domain name to be carried in the client's FQDN
@@ -240,7 +237,6 @@ public:
     /// @param exp_domain_name A domain name expected in the FQDN sent by a
     /// @param exp_domain_name A domain name expected in the FQDN sent by a
     /// server.
     /// server.
     void testFqdn(const uint16_t msg_type,
     void testFqdn(const uint16_t msg_type,
-                  const bool use_oro,
                   const uint8_t in_flags,
                   const uint8_t in_flags,
                   const std::string& in_domain_name,
                   const std::string& in_domain_name,
                   const Option6ClientFqdn::DomainNameType in_domain_type,
                   const Option6ClientFqdn::DomainNameType in_domain_type,
@@ -251,11 +247,14 @@ public:
                                            in_flags,
                                            in_flags,
                                            in_domain_name,
                                            in_domain_name,
                                            in_domain_type,
                                            in_domain_type,
-                                           use_oro);
+                                           true);
         ASSERT_TRUE(getClientFqdnOption(question));
         ASSERT_TRUE(getClientFqdnOption(question));
 
 
-        Option6ClientFqdnPtr answ_fqdn;
-        ASSERT_NO_THROW(answ_fqdn = srv.processClientFqdn(question));
+        Pkt6Ptr answer(new Pkt6(msg_type == DHCPV6_SOLICIT ? DHCPV6_ADVERTISE :
+                                DHCPV6_REPLY, question->getTransid()));
+        ASSERT_NO_THROW(srv.processClientFqdn(question, answer));
+        Option6ClientFqdnPtr answ_fqdn = boost::dynamic_pointer_cast<
+            Option6ClientFqdn>(answer->getOption(D6O_CLIENT_FQDN));
         ASSERT_TRUE(answ_fqdn);
         ASSERT_TRUE(answ_fqdn);
 
 
         const bool flag_n = (exp_flags & Option6ClientFqdn::FLAG_N) != 0;
         const bool flag_n = (exp_flags & Option6ClientFqdn::FLAG_N) != 0;
@@ -339,11 +338,9 @@ public:
             ASSERT_TRUE(lease);
             ASSERT_TRUE(lease);
         }
         }
 
 
-        if (include_oro) {
-            ASSERT_TRUE(reply->getOption(D6O_CLIENT_FQDN));
-        } else {
-            ASSERT_FALSE(reply->getOption(D6O_CLIENT_FQDN));
-        }
+        // The Client FQDN option should be always present in the server's
+        // response, regardless if requested using ORO or not.
+        ASSERT_TRUE(reply->getOption(D6O_CLIENT_FQDN));
     }
     }
 
 
     /// @brief Verify that NameChangeRequest holds valid values.
     /// @brief Verify that NameChangeRequest holds valid values.
@@ -394,7 +391,7 @@ public:
 
 
 // Test server's response when client requests that server performs AAAA update.
 // Test server's response when client requests that server performs AAAA update.
 TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdate) {
 TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdate) {
-    testFqdn(DHCPV6_SOLICIT, true, Option6ClientFqdn::FLAG_S,
+    testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S,
              "myhost.example.com",
              "myhost.example.com",
              Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_S,
              Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_S,
              "myhost.example.com.");
              "myhost.example.com.");
@@ -403,7 +400,7 @@ TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdate) {
 // Test server's response when client provides partial domain-name and requests
 // Test server's response when client provides partial domain-name and requests
 // that server performs AAAA update.
 // that server performs AAAA update.
 TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdatePartialName) {
 TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdatePartialName) {
-    testFqdn(DHCPV6_SOLICIT, true, Option6ClientFqdn::FLAG_S, "myhost",
+    testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S, "myhost",
              Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S,
              Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S,
              "myhost.example.com.");
              "myhost.example.com.");
 }
 }
@@ -411,14 +408,14 @@ TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdatePartialName) {
 // Test server's response when client provides empty domain-name and requests
 // Test server's response when client provides empty domain-name and requests
 // that server performs AAAA update.
 // that server performs AAAA update.
 TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdateNoName) {
 TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdateNoName) {
-    testFqdn(DHCPV6_SOLICIT, true, Option6ClientFqdn::FLAG_S, "",
+    testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S, "",
              Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S,
              Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S,
              "myhost.example.com.");
              "myhost.example.com.");
 }
 }
 
 
 // Test server's response when client requests no DNS update.
 // Test server's response when client requests no DNS update.
 TEST_F(FqdnDhcpv6SrvTest, noUpdate) {
 TEST_F(FqdnDhcpv6SrvTest, noUpdate) {
-    testFqdn(DHCPV6_SOLICIT, true, Option6ClientFqdn::FLAG_N,
+    testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_N,
              "myhost.example.com",
              "myhost.example.com",
              Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_N,
              Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_N,
              "myhost.example.com.");
              "myhost.example.com.");
@@ -427,7 +424,7 @@ TEST_F(FqdnDhcpv6SrvTest, noUpdate) {
 // Test server's response when client requests that server delegates the AAAA
 // Test server's response when client requests that server delegates the AAAA
 // update to the client and this delegation is not allowed.
 // update to the client and this delegation is not allowed.
 TEST_F(FqdnDhcpv6SrvTest, clientAAAAUpdateNotAllowed) {
 TEST_F(FqdnDhcpv6SrvTest, clientAAAAUpdateNotAllowed) {
-    testFqdn(DHCPV6_SOLICIT, true, 0, "myhost.example.com.",
+    testFqdn(DHCPV6_SOLICIT, 0, "myhost.example.com.",
              Option6ClientFqdn::FULL,
              Option6ClientFqdn::FULL,
              Option6ClientFqdn::FLAG_S | Option6ClientFqdn::FLAG_O,
              Option6ClientFqdn::FLAG_S | Option6ClientFqdn::FLAG_O,
              "myhost.example.com.");
              "myhost.example.com.");
@@ -758,8 +755,8 @@ TEST_F(FqdnDhcpv6SrvTest, processRequestRelease) {
 
 
 }
 }
 
 
-// Checks that the server does not include DHCPv6 Client FQDN option in its
-// response when client doesn't include ORO option in the Request.
+// Checks that the server include DHCPv6 Client FQDN option in its
+// response even when client doesn't request this option using ORO.
 TEST_F(FqdnDhcpv6SrvTest, processRequestWithoutFqdn) {
 TEST_F(FqdnDhcpv6SrvTest, processRequestWithoutFqdn) {
     NakedDhcpv6Srv srv(0);
     NakedDhcpv6Srv srv(0);