From: Marcin Siodelski Date: Mon, 20 Jan 2014 15:05:07 +0000 (+0100) Subject: [3295] Function which processes FQDN option appends it to server's answer. X-Git-Tag: bind10-1.2.0beta1-release~83^2~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=33210233e855588fa4c48450071f30a50af04e5f;p=thirdparty%2Fkea.git [3295] Function which processes FQDN option appends it to server's answer. --- diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 601a95c841..3f6c50e408 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -965,7 +965,7 @@ Dhcpv6Srv::assignLeases(const Pkt6Ptr& question, Pkt6Ptr& answer, } 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 // been included, do nothing. 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); } @@ -2175,7 +2177,7 @@ Dhcpv6Srv::processSolicit(const Pkt6Ptr& solicit) { appendRequestedOptions(solicit, advertise); appendRequestedVendorOptions(solicit, advertise); - Option6ClientFqdnPtr fqdn = processClientFqdn(solicit); + Option6ClientFqdnPtr fqdn = processClientFqdn(solicit, advertise); assignLeases(solicit, advertise, fqdn); appendClientFqdn(solicit, advertise, fqdn); // Note, that we don't create NameChangeRequests here because we don't @@ -2197,7 +2199,7 @@ Dhcpv6Srv::processRequest(const Pkt6Ptr& request) { appendRequestedOptions(request, reply); appendRequestedVendorOptions(request, reply); - Option6ClientFqdnPtr fqdn = processClientFqdn(request); + Option6ClientFqdnPtr fqdn = processClientFqdn(request, reply); assignLeases(request, reply, fqdn); appendClientFqdn(request, reply, fqdn); createNameChangeRequests(reply, fqdn); @@ -2216,7 +2218,7 @@ Dhcpv6Srv::processRenew(const Pkt6Ptr& renew) { appendDefaultOptions(renew, reply); appendRequestedOptions(renew, reply); - Option6ClientFqdnPtr fqdn = processClientFqdn(renew); + Option6ClientFqdnPtr fqdn = processClientFqdn(renew, reply); renewLeases(renew, reply, fqdn); appendClientFqdn(renew, reply, fqdn); createNameChangeRequests(reply, fqdn); diff --git a/src/bin/dhcp6/dhcp6_srv.h b/src/bin/dhcp6/dhcp6_srv.h index 26a7d7189e..2a511f3ebb 100644 --- a/src/bin/dhcp6/dhcp6_srv.h +++ b/src/bin/dhcp6/dhcp6_srv.h @@ -376,9 +376,11 @@ protected: /// held in this function. /// /// @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. - Option6ClientFqdnPtr processClientFqdn(const Pkt6Ptr& question); + Option6ClientFqdnPtr processClientFqdn(const Pkt6Ptr& question, + const Pkt6Ptr& answer); /// @brief Adds DHCPv6 Client FQDN %Option to the server response. /// diff --git a/src/bin/dhcp6/tests/fqdn_unittest.cc b/src/bin/dhcp6/tests/fqdn_unittest.cc index 8a2da6904c..65a32446f4 100644 --- a/src/bin/dhcp6/tests/fqdn_unittest.cc +++ b/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 // 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. /// /// @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 /// in the client's message. /// @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 /// server. void testFqdn(const uint16_t msg_type, - const bool use_oro, const uint8_t in_flags, const std::string& in_domain_name, const Option6ClientFqdn::DomainNameType in_domain_type, @@ -251,11 +247,14 @@ public: in_flags, in_domain_name, in_domain_type, - use_oro); + true); 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); const bool flag_n = (exp_flags & Option6ClientFqdn::FLAG_N) != 0; @@ -339,11 +338,9 @@ public: 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. @@ -394,7 +391,7 @@ public: // Test server's response when client requests that server performs AAAA update. TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdate) { - testFqdn(DHCPV6_SOLICIT, true, Option6ClientFqdn::FLAG_S, + testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S, "myhost.example.com", Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_S, "myhost.example.com."); @@ -403,7 +400,7 @@ TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdate) { // Test server's response when client provides partial domain-name and requests // that server performs AAAA update. TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdatePartialName) { - testFqdn(DHCPV6_SOLICIT, true, Option6ClientFqdn::FLAG_S, "myhost", + testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S, "myhost", Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S, "myhost.example.com."); } @@ -411,14 +408,14 @@ TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdatePartialName) { // Test server's response when client provides empty domain-name and requests // that server performs AAAA update. TEST_F(FqdnDhcpv6SrvTest, serverAAAAUpdateNoName) { - testFqdn(DHCPV6_SOLICIT, true, Option6ClientFqdn::FLAG_S, "", + testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_S, "", Option6ClientFqdn::PARTIAL, Option6ClientFqdn::FLAG_S, "myhost.example.com."); } // Test server's response when client requests no DNS update. TEST_F(FqdnDhcpv6SrvTest, noUpdate) { - testFqdn(DHCPV6_SOLICIT, true, Option6ClientFqdn::FLAG_N, + testFqdn(DHCPV6_SOLICIT, Option6ClientFqdn::FLAG_N, "myhost.example.com", Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_N, "myhost.example.com."); @@ -427,7 +424,7 @@ TEST_F(FqdnDhcpv6SrvTest, noUpdate) { // Test server's response when client requests that server delegates the AAAA // update to the client and this delegation is not allowed. TEST_F(FqdnDhcpv6SrvTest, clientAAAAUpdateNotAllowed) { - testFqdn(DHCPV6_SOLICIT, true, 0, "myhost.example.com.", + testFqdn(DHCPV6_SOLICIT, 0, "myhost.example.com.", Option6ClientFqdn::FULL, Option6ClientFqdn::FLAG_S | Option6ClientFqdn::FLAG_O, "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) { NakedDhcpv6Srv srv(0);