|
@@ -104,13 +104,8 @@ namespace {
|
|
|
// DHCPv6 Client FQDN Option sent by a client. They will be removed
|
|
|
// when DDNS parameters for DHCPv6 are implemented with the ticket #3034.
|
|
|
|
|
|
-// Enable AAAA RR update delegation to the client (Disabled).
|
|
|
-const bool FQDN_ALLOW_CLIENT_UPDATE = false;
|
|
|
// Globally enable updates (Enabled).
|
|
|
const bool FQDN_ENABLE_UPDATE = true;
|
|
|
-// The partial name generated for the client if empty name has been
|
|
|
-// supplied.
|
|
|
-const char* FQDN_GENERATED_PARTIAL_NAME = "myhost";
|
|
|
// Do update, even if client requested no updates with N flag (Disabled).
|
|
|
const bool FQDN_OVERRIDE_NO_UPDATE = false;
|
|
|
// Server performs an update when client requested delegation (Enabled).
|
|
@@ -1012,69 +1007,18 @@ Dhcpv6Srv::processClientFqdn(const Pkt6Ptr& question, const Pkt6Ptr& answer) {
|
|
|
|
|
|
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_DETAIL,
|
|
|
DHCP6_DDNS_RECEIVE_FQDN).arg(fqdn->toText());
|
|
|
-
|
|
|
-
|
|
|
- // Prepare the FQDN option which will be included in the response to
|
|
|
- // the client.
|
|
|
+ // Create the DHCPv6 Client FQDN Option to be included in the server's
|
|
|
+ // response to a client.
|
|
|
Option6ClientFqdnPtr fqdn_resp(new Option6ClientFqdn(*fqdn));
|
|
|
- // RFC 4704, section 6. - all flags set to 0.
|
|
|
- fqdn_resp->resetFlags();
|
|
|
-
|
|
|
- // Conditions when N flag has to be set to indicate that server will not
|
|
|
- // perform DNS updates:
|
|
|
- // 1. Updates are globally disabled,
|
|
|
- // 2. Client requested no update and server respects it,
|
|
|
- // 3. Client requested that the AAAA update is delegated to the client but
|
|
|
- // server neither respects delegation of updates nor it is configured
|
|
|
- // to send update on its own when client requested delegation.
|
|
|
- if (!FQDN_ENABLE_UPDATE ||
|
|
|
- (fqdn->getFlag(Option6ClientFqdn::FLAG_N) &&
|
|
|
- !FQDN_OVERRIDE_NO_UPDATE) ||
|
|
|
- (!fqdn->getFlag(Option6ClientFqdn::FLAG_S) &&
|
|
|
- !FQDN_ALLOW_CLIENT_UPDATE && !FQDN_OVERRIDE_CLIENT_UPDATE)) {
|
|
|
- fqdn_resp->setFlag(Option6ClientFqdn::FLAG_N, true);
|
|
|
-
|
|
|
- // Conditions when S flag is set to indicate that server will perform
|
|
|
- // DNS update on its own:
|
|
|
- // 1. Client requested that server performs DNS update and DNS updates are
|
|
|
- // globally enabled
|
|
|
- // 2. Client requested that server delegates AAAA update to the client but
|
|
|
- // server doesn't respect delegation and it is configured to perform
|
|
|
- // an update on its own when client requested delegation.
|
|
|
- } else if (fqdn->getFlag(Option6ClientFqdn::FLAG_S) ||
|
|
|
- (!fqdn->getFlag(Option6ClientFqdn::FLAG_S) &&
|
|
|
- !FQDN_ALLOW_CLIENT_UPDATE && FQDN_OVERRIDE_CLIENT_UPDATE)) {
|
|
|
- fqdn_resp->setFlag(Option6ClientFqdn::FLAG_S, true);
|
|
|
- }
|
|
|
-
|
|
|
- // Server MUST set the O flag if it has overridden the client's setting
|
|
|
- // of S flag.
|
|
|
- if (fqdn->getFlag(Option6ClientFqdn::FLAG_S) !=
|
|
|
- fqdn_resp->getFlag(Option6ClientFqdn::FLAG_S)) {
|
|
|
- fqdn_resp->setFlag(Option6ClientFqdn::FLAG_O, true);
|
|
|
- }
|
|
|
-
|
|
|
- // If client supplied partial or empty domain-name, server should
|
|
|
- // generate one.
|
|
|
- if (fqdn->getDomainNameType() == Option6ClientFqdn::PARTIAL) {
|
|
|
- std::ostringstream 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);
|
|
|
- }
|
|
|
|
|
|
- // Server may be configured to replace a name supplied by a client,
|
|
|
- // even if client supplied fully qualified domain-name.
|
|
|
- } else if (FQDN_REPLACE_CLIENT_NAME) {
|
|
|
- std::ostringstream name;
|
|
|
- name << FQDN_GENERATED_PARTIAL_NAME << "." << FQDN_PARTIAL_SUFFIX;
|
|
|
- fqdn_resp->setDomainName(name.str(), Option6ClientFqdn::FULL);
|
|
|
+ // Set the server S, N, and O flags based on client's flags and
|
|
|
+ // current configuration.
|
|
|
+ D2ClientMgr& d2_mgr = CfgMgr::instance().getD2ClientMgr();
|
|
|
+ d2_mgr.adjustFqdnFlags<Option6ClientFqdn>(*fqdn, *fqdn_resp);
|
|
|
|
|
|
- }
|
|
|
+ // Adjust the domain name based on domain name value and type sent by the
|
|
|
+ // client and current configuration.
|
|
|
+ d2_mgr.adjustDomainName<Option6ClientFqdn>(*fqdn, *fqdn_resp);
|
|
|
|
|
|
// 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
|
|
@@ -1295,14 +1239,11 @@ Dhcpv6Srv::assignIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
|
|
|
Option6ClientFqdnPtr fqdn = boost::dynamic_pointer_cast<
|
|
|
Option6ClientFqdn>(answer->getOption(D6O_CLIENT_FQDN));
|
|
|
if (fqdn) {
|
|
|
- // Flag S must not coexist with flag N being set to 1, so if S=1
|
|
|
- // server takes responsibility for both reverse and forward updates.
|
|
|
- // Otherwise, we have to check N.
|
|
|
+ // For now, we assert that if we are doing forward we are also
|
|
|
+ // doing reverse.
|
|
|
if (fqdn->getFlag(Option6ClientFqdn::FLAG_S)) {
|
|
|
do_fwd = true;
|
|
|
do_rev = true;
|
|
|
- } else if (!fqdn->getFlag(Option6ClientFqdn::FLAG_N)) {
|
|
|
- do_rev = true;
|
|
|
}
|
|
|
}
|
|
|
// Set hostname only in case any of the updates is being performed.
|
|
@@ -1553,11 +1494,11 @@ Dhcpv6Srv::renewIA_NA(const Subnet6Ptr& subnet, const DuidPtr& duid,
|
|
|
Option6ClientFqdnPtr fqdn = boost::dynamic_pointer_cast<
|
|
|
Option6ClientFqdn>(answer->getOption(D6O_CLIENT_FQDN));
|
|
|
if (fqdn) {
|
|
|
+ // For now, we assert that if we are doing forward we are also
|
|
|
+ // doing reverse.
|
|
|
if (fqdn->getFlag(Option6ClientFqdn::FLAG_S)) {
|
|
|
do_fwd = true;
|
|
|
do_rev = true;
|
|
|
- } else if (!fqdn->getFlag(Option6ClientFqdn::FLAG_N)) {
|
|
|
- do_rev = true;
|
|
|
}
|
|
|
}
|
|
|
|