Browse Source

[3341] Allow b10-dchp-ddns to optionally support updates in a given direction

Added methods to D2CfgMgr to return whether or not forward or reverse
updates are enabled. Altered D2UpdateMgr::makeTransaction to utlilize
these new methods. Added additional logs and unittests.
Thomas Markwalder 11 years ago
parent
commit
d1aaf04e15

+ 12 - 0
src/bin/d2/d2_cfg_mgr.cc

@@ -73,6 +73,18 @@ D2CfgMgr::~D2CfgMgr() {
 }
 
 bool
+D2CfgMgr::forwardUpdatesEnabled() {
+    // Forward updates are not enabled if no forward servers are defined.
+    return (getD2CfgContext()->getForwardMgr()->size() > 0);
+}
+
+bool
+D2CfgMgr::reverseUpdatesEnabled() {
+    // Reverse updates are not enabled if no revese servers are defined.
+    return (getD2CfgContext()->getReverseMgr()->size() > 0);
+}
+
+bool
 D2CfgMgr::matchForward(const std::string& fqdn, DdnsDomainPtr& domain) {
     if (fqdn.empty()) {
         // This is a programmatic error and should not happen.

+ 10 - 0
src/bin/d2/d2_cfg_mgr.h

@@ -126,6 +126,16 @@ public:
         return (boost::dynamic_pointer_cast<D2CfgContext>(getContext()));
     }
 
+    /// @brief Returns whether not forward updates are enabled.
+    ///
+    /// @return true if forward updates are enabled, false otherwise.
+    bool forwardUpdatesEnabled();
+
+    /// @brief Returns whether not reverse updates are enabled.
+    ///
+    /// @return true if reverse updates are enabled, false otherwise.
+    bool reverseUpdatesEnabled();
+
     /// @brief Matches a given FQDN to a forward domain.
     ///
     /// This calls the matchDomain method of the forward domain manager to

+ 173 - 157
src/bin/d2/d2_messages.mes

@@ -112,6 +112,15 @@ service first starts.
 This is an informational message issued when the controller is exiting
 following a shut down (normal or otherwise) of the service.
 
+% DHCP_DDNS_ADD_FAILED DHCP_DDNS failed attempting to make DNS mapping additions for this request: %1, event: %2
+This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
+entry additions have failed.  The precise reason for the failure should be
+documented in preceding log entries.
+
+% DHCP_DDNS_ADD_SUCCEEDED DHCP_DDNS successfully added the DNS mapping addition for this request: %1
+This is a debug message issued after DHCP_DDNS has submitted DNS mapping
+additions which were received and accepted by an appropriate DNS server.
+
 % DHCP_DDNS_AT_MAX_TRANSACTIONS application has %1 queued requests but has reached maximum number of %2 concurrent transactions
 This is a debug message that indicates that the application has DHCP_DDNS
 requests in the queue but is working as many concurrent requests as allowed.
@@ -132,6 +141,114 @@ has been invoked.
 This is a debug message issued when the Dhcp-Ddns application encounters an
 unrecoverable error from within the event loop.
 
+% DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while adding a forward address mapping for FQDN %2 to DNS server %3
+This is an error message issued when DNSClient returns an unrecognized status
+while DHCP_DDNS was adding a forward address mapping.  The request will be
+aborted.  This is most likely a programmatic issue and should be reported.
+
+% DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE DNS udpate message to add a forward DNS entry could not be constructed for this request: %1, reason: %2
+This is an error message issued when an error occurs attempting to construct
+the server bound packet requesting a forward address addition.  This is due
+to invalid data contained in the NameChangeRequest. The request will be aborted.
+This is most likely a configuration issue.
+
+% DHCP_DDNS_FORWARD_ADD_IO_ERROR DHCP_DDNS encountered an IO error sending a forward mapping add for FQDN %1 to DNS server %2
+This is an error message issued when a communication error occurs while
+DHCP_DDNS is carrying out a forward address update.  The application will
+retry against the same server or others as appropriate.
+
+% DHCP_DDNS_FORWARD_ADD_REJECTED DNS Server, %1, rejected a DNS update request to add the address mapping for FQDN, %2, with an RCODE: %3
+This is an error message issued when an update was rejected by the DNS server
+it was sent to for the reason given by the RCODE. The rcode values are defined
+in RFC 2136.
+
+% DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while adding forward address mapping for FQDN, %2
+This is an error message issued when the response received by DHCP_DDNS, to a
+update request to add a forward address mapping,  is mangled or malformed.
+The application will retry against the same server or others as appropriate.
+
+% DHCP_DDNS_FORWARD_REMOVE_ADDRS_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while removing a forward address mapping for FQDN %2 to DNS server %3
+This is an error message issued when DNSClient returns an unrecognized status
+while DHCP_DDNS was removing a forward address mapping.  The request will be
+aborted.  This is most likely a programmatic issue and should be reported.
+
+% DHCP_DDNS_FORWARD_REMOVE_ADDRS_BUILD_FAILURE DNS udpate message to remove a forward DNS Address entry could not be constructed for this request: %1,  reason: %2
+This is an error message issued when an error occurs attempting to construct
+the server bound packet requesting a forward address (A or AAAA) removal.  This
+is due to invalid data contained in the NameChangeRequest. The request will be
+aborted.  This is most likely a configuration issue.
+
+% DHCP_DDNS_FORWARD_REMOVE_ADDRS_IO_ERROR DHCP_DDNS encountered an IO error sending a forward mapping address removal for FQDN %1 to DNS server %2
+This is an error message issued when a communication error occurs while
+DHCP_DDNS is carrying out a forward address remove.  The application will retry
+against the same server or others as appropriate.
+
+% DHCP_DDNS_FORWARD_REMOVE_ADDRS_REJECTED DNS Server, %1, rejected a DNS update request to remove the forward address mapping for FQDN, %2, with an RCODE: %3
+This is an error message issued when an update was rejected by the DNS server
+it was sent to for the reason given by the RCODE. The rcode values are defined
+in RFC 2136.
+
+% DHCP_DDNS_FORWARD_REMOVE_ADDRS_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while removing forward address mapping for FQDN, %2
+This is an error message issued when the response received by DHCP_DDNS, to a
+update request to remove a forward address mapping, is mangled or malformed.
+The application will retry against the same server or others as appropriate.
+
+% DHCP_DDNS_FORWARD_REMOVE_RRS_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while removing forward RRs for FQDN %2 to DNS server %3
+This is an error message issued when DNSClient returns an unrecognized status
+while DHCP_DDNS was removing forward RRs.  The request will be aborted. This is
+most likely a programmatic issue and should be reported.
+
+% DHCP_DDNS_FORWARD_REMOVE_RRS_BUILD_FAILURE DNS udpate message to remove forward DNS RR entries could not be constructed for this request: %1,  reason: %2
+This is an error message issued when an error occurs attempting to construct
+the server bound packet requesting forward RR (DHCID RR) removal.  This is due
+to invalid data contained in the NameChangeRequest. The request will be aborted.This is most likely a configuration issue.
+
+% DHCP_DDNS_FORWARD_REMOVE_RRS_IO_ERROR DHCP_DDNS encountered an IO error sending a forward RR removal for FQDN %1 to DNS server %2
+This is an error message issued when a communication error occurs while
+DHCP_DDNS is carrying out a forward RR remove.  The application will retry
+against the same server.
+
+% DHCP_DDNS_FORWARD_REMOVE_RRS_REJECTED DNS Server, %1, rejected a DNS update request to remove forward RR entries for FQDN, %2, with an RCODE: %3
+This is an error message issued when an update was rejected by the DNS server
+it was sent to for the reason given by the RCODE. The rcode values are defined
+in RFC 2136.
+
+% DHCP_DDNS_FORWARD_REMOVE_RRS_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while removing forward RRs for FQDN, %2
+This is an error message issued when the response received by DHCP_DDNS, to a
+update request to remove forward RRs mapping, is mangled or malformed.
+The application will retry against the same server or others as appropriate.
+
+% DHCP_DDNS_FORWARD_REPLACE_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while replacing forward address mapping for FQDN %2 to DNS server %3
+This is an error message issued when DNSClient returns an unrecognized status
+while DHCP_DDNS was replacing a forward address mapping.  The request will be
+aborted.  This is most likely a programmatic issue and should be reported.
+
+% DHCP_DDNS_FORWARD_REPLACE_BUILD_FAILURE DNS update message to replace a forward DNS entry could not be constructed from this request: %1, reason: %2
+This is an error message issued when an error occurs attempting to construct
+the server bound packet requesting a forward address replacement.  This is
+due to invalid data contained in the NameChangeRequest. The request will be
+aborted.  This is most likely a configuration issue.
+
+% DHCP_DDNS_FORWARD_REPLACE_IO_ERROR DHCP_DDNS encountered an IO error sending a forward mapping replace for FQDN %1 to DNS server %2
+This is an error message issued when a communication error occurs while
+DHCP_DDNS is carrying out a forward address update.  The application will
+retry against the same server or others as appropriate.
+
+% DHCP_DDNS_FORWARD_REPLACE_REJECTED DNS Server, %1, rejected a DNS update request to replace the address mapping for FQDN, %2, with an RCODE: %3
+This is an error message issued when an update was rejected by the DNS server
+it was sent to for the reason given by the RCODE. The rcode values are defined
+in RFC 2136.
+
+% DHCP_DDNS_FORWARD_REPLACE_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while replacing forward address mapping for FQDN, %2
+This is an error message issued when the response received by DHCP_DDNS, to a
+update request to replace a forward address mapping,  is mangled or malformed.
+The application will retry against the same server or others as appropriate.
+
+% DHCP_DDNS_FWD_REQUEST_IGNORED Forward updates are disabled, the forward portion of request will be ignored: %1
+This is a debug message issued when forward DNS updates are disabled and
+DHCP_DDNS receives an update request containing a forward DNS update. The
+forward update will not performed.
+
 % DHCP_DDNS_INVALID_RESPONSE received response to DNS Update message is malformed: %1
 This is a debug message issued when the DHCP-DDNS application encountered an
 error while decoding a response to DNS Update message. Typically, this error
@@ -142,7 +259,7 @@ This is a debug message issued when all of the queued requests represent clients
 for which there is a an update already in progress.  This may occur under
 normal operations but should be temporary situation.
 
-% DHCP_DDNS_NO_FWD_MATCH_ERROR the configured list of forward DDNS domains does not contain a match for FQDN %1  The request has been discarded.
+% DHCP_DDNS_NO_FWD_MATCH_ERROR the configured list of forward DDNS domains does not contain a match for: %1  The request has been discarded.
 This is an error message that indicates that DHCP_DDNS received a request to
 update a the forward DNS information for the given FQDN but for which there are
 no configured DDNS domains in the DHCP_DDNS configuration.  Either the DHCP_DDNS
@@ -154,7 +271,7 @@ This is warning message issued when there are no domains in the configuration
 which match the cited fully qualified domain name (FQDN).  The DNS Update
 request for the FQDN cannot be processed.
 
-% DHCP_DDNS_NO_REV_MATCH_ERROR the configured list of reverse DDNS domains does not contain a match for FQDN %1  The request has been discarded.
+% DHCP_DDNS_NO_REV_MATCH_ERROR the configured list of reverse DDNS domains does not contain a match for: %1  The request has been discarded.
 This is an error message that indicates that DHCP_DDNS received a request to
 update a the reverse DNS information for the given FQDN but for which there are
 no configured DDNS domains in the DHCP_DDNS configuration.  Either the DHCP_DDNS
@@ -241,77 +358,45 @@ receive was unexpected interrupted.  Normally, the read is receive is only
 interrupted as a normal part of stopping the queue manager.  This is most
 likely a programmatic issue that should be reported.
 
-% DHCP_DDNS_RUN_ENTER application has entered the event loop
-This is a debug message issued when the Dhcp-Ddns application enters
-its run method.
-
-% DHCP_DDNS_RUN_EXIT application is exiting the event loop
-This is a debug message issued when the Dhcp-Ddns exits the
-in event loop.
-
-% DHCP_DDNS_SHUTDOWN application received shutdown command with args: %1
-This is informational message issued when the application has been instructed
-to shut down by the controller.
-
-% DHCP_DDNS_STATE_MODEL_UNEXPECTED_ERROR application encountered an unexpected error while carrying out a NameChangeRequest: %1
-This is error message issued when the application fails to process a
-NameChangeRequest correctly. Some or all of the DNS updates requested as part
-of this update did not succeed. This is a programmatic error and should be
-reported.
-
-% DHCP_DDNS_FORWARD_ADD_REJECTED DNS Server, %1, rejected a DNS update request to add the address mapping for FQDN, %2, with an RCODE: %3
-This is an error message issued when an update was rejected by the DNS server
-it was sent to for the reason given by the RCODE. The rcode values are defined
-in RFC 2136.
+% DHCP_DDNS_REMOVE_FAILED DHCP_DDNS failed attempting to make DNS mapping removals for this request: %1, event: %2
+This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
+entry removals have failed.  The precise reason for the failure should be
+documented in preceding log entries.
 
-% DHCP_DDNS_FORWARD_ADD_IO_ERROR DHCP_DDNS encountered an IO error sending a forward mapping add for FQDN %1 to DNS server %2
-This is an error message issued when a communication error occurs while
-DHCP_DDNS is carrying out a forward address update.  The application will
-retry against the same server or others as appropriate.
+% DHCP_DDNS_REMOVE_SUCCEEDED DHCP_DDNS successfully removed the DNS mapping addition for this request: %1
+This is a debug message issued after DHCP_DDNS has submitted DNS mapping
+removals which were received and accepted by an appropriate DNS server.
 
-% DHCP_DDNS_FORWARD_ADD_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while adding forward address mapping for FQDN, %2
-This is an error message issued when the response received by DHCP_DDNS, to a
-update request to add a forward address mapping,  is mangled or malformed.
-The application will retry against the same server or others as appropriate.
+% DHCP_DDNS_REQUEST_DROPPED Request contains no enabled update requests and will be dropped: %1
+This is a debug message issued when DHCP_DDNS receives a request which does not
+contain updates in a direction that is enabled.  In other words, if only forward
+updates are enabled and request is recevied that asks only for reverse updates
+then the request is dropped.
 
-% DHCP_DDNS_FORWARD_ADD_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while adding a forward address mapping for FQDN %2 to DNS server %3
+% DHCP_DDNS_REVERSE_REMOVE_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while removing reverse address mapping for FQDN %2 to DNS server %3
 This is an error message issued when DNSClient returns an unrecognized status
-while DHCP_DDNS was adding a forward address mapping.  The request will be
+while DHCP_DDNS was removing a reverse address mapping.  The request will be
 aborted.  This is most likely a programmatic issue and should be reported.
 
-% DHCP_DDNS_FORWARD_REPLACE_REJECTED DNS Server, %1, rejected a DNS update request to replace the address mapping for FQDN, %2, with an RCODE: %3
-This is an error message issued when an update was rejected by the DNS server
-it was sent to for the reason given by the RCODE. The rcode values are defined
-in RFC 2136.
+% DHCP_DDNS_REVERSE_REMOVE_BUILD_FAILURE DNS update message to remove a reverse DNS entry could not be constructed from this request: %1,  reason: %2
+This is an error message issued when an error occurs attempting to construct
+the server bound packet requesting a reverse PTR removal.  This is
+due to invalid data contained in the NameChangeRequest. The request will be
+aborted.  This is most likely a configuration issue.
 
-% DHCP_DDNS_FORWARD_REPLACE_IO_ERROR DHCP_DDNS encountered an IO error sending a forward mapping replace for FQDN %1 to DNS server %2
+% DHCP_DDNS_REVERSE_REMOVE_IO_ERROR DHCP_DDNS encountered an IO error sending a reverse mapping remove for FQDN %1 to DNS server %2
 This is an error message issued when a communication error occurs while
-DHCP_DDNS is carrying out a forward address update.  The application will
+DHCP_DDNS is carrying out a reverse address update.  The application will
 retry against the same server or others as appropriate.
 
-% DHCP_DDNS_FORWARD_REPLACE_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while replacing forward address mapping for FQDN, %2
-This is an error message issued when the response received by DHCP_DDNS, to a
-update request to replace a forward address mapping,  is mangled or malformed.
-The application will retry against the same server or others as appropriate.
-
-% DHCP_DDNS_FORWARD_REPLACE_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while replacing forward address mapping for FQDN %2 to DNS server %3
-This is an error message issued when DNSClient returns an unrecognized status
-while DHCP_DDNS was replacing a forward address mapping.  The request will be
-aborted.  This is most likely a programmatic issue and should be reported.
-
-% DHCP_DDNS_REVERSE_REPLACE_REJECTED DNS Server, %1, rejected a DNS update request to replace the reverse mapping for FQDN, %2, with an RCODE: %3
+% DHCP_DDNS_REVERSE_REMOVE_REJECTED DNS Server, %1, rejected a DNS update request to remove the reverse mapping for FQDN, %2, with an RCODE: %3
 This is an error message issued when an update was rejected by the DNS server
 it was sent to for the reason given by the RCODE. The rcode values are defined
 in RFC 2136.
 
-% DHCP_DDNS_REVERSE_REPLACE_IO_ERROR DHCP_DDNS encountered an IO error sending a reverse mapping replacement for FQDN %1 to DNS server %2
-This is an error message issued when a communication error occurs while
-DHCP_DDNS is carrying out a reverse address update.  The application will
-retry against the same server or others as appropriate.
-
-% DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while replacing reverse address mapping for FQDN, %2
+% DHCP_DDNS_REVERSE_REMOVE_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while removing reverse address mapping for FQDN, %2
 This is an error message issued when the response received by DHCP_DDNS, to a
-update request to replace a reverse address,  is mangled or malformed.
+update request to remove a reverse address,  is mangled or malformed.
 The application will retry against the same server or others as appropriate.
 
 % DHCP_DDNS_REVERSE_REPLACE_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while replacing reverse address mapping for FQDN %2 to DNS server %3
@@ -319,126 +404,57 @@ This is an error message issued when DNSClient returns an unrecognized status
 while DHCP_DDNS was replacing a reverse address mapping.  The request will be
 aborted.  This is most likely a programmatic issue and should be reported.
 
-% DHCP_DDNS_TRANS_SEND_ERROR application encountered an unexpected error while attempting to send a DNS update: %1
-This is error message issued when the application is able to construct an update
-message but the attempt to send it suffered a unexpected error. This is most
-likely a programmatic error, rather than a communications issue. Some or all
-of the DNS updates requested as part of this request did not succeed.
-
-% DHCP_DDNS_FORWARD_ADD_BUILD_FAILURE DNS udpate message to add a forward DNS entry could not be constructed for this request: %1, reason: %2
-This is an error message issued when an error occurs attempting to construct
-the server bound packet requesting a forward address addition.  This is due
-to invalid data contained in the NameChangeRequest. The request will be aborted.
-This is most likely a configuration issue.
-
-% DHCP_DDNS_FORWARD_REPLACE_BUILD_FAILURE DNS update message to replace a forward DNS entry could not be constructed from this request: %1, reason: %2
-This is an error message issued when an error occurs attempting to construct
-the server bound packet requesting a forward address replacement.  This is
-due to invalid data contained in the NameChangeRequest. The request will be
-aborted.  This is most likely a configuration issue.
-
 % DHCP_DDNS_REVERSE_REPLACE_BUILD_FAILURE DNS update message to replace a reverse DNS entry could not be constructed from this request: %1, reason: %2
 This is an error message issued when an error occurs attempting to construct
 the server bound packet requesting a reverse PTR replacement.  This is
 due to invalid data contained in the NameChangeRequest. The request will be
 aborted.  This is most likely a configuration issue.
 
-% DHCP_DDNS_ADD_SUCCEEDED DHCP_DDNS successfully added the DNS mapping addition for this request: %1
-This is a debug message issued after DHCP_DDNS has submitted DNS mapping
-additions which were received and accepted by an appropriate DNS server.
-
-% DHCP_DDNS_ADD_FAILED DHCP_DDNS failed attempting to make DNS mapping additions for this request: %1, event: %2
-This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
-entry additions have failed.  The precise reason for the failure should be
-documented in preceding log entries.
-
-% DHCP_DDNS_FORWARD_REMOVE_ADDRS_BUILD_FAILURE DNS udpate message to remove a forward DNS Address entry could not be constructed for this request: %1,  reason: %2
-This is an error message issued when an error occurs attempting to construct
-the server bound packet requesting a forward address (A or AAAA) removal.  This
-is due to invalid data contained in the NameChangeRequest. The request will be
-aborted.  This is most likely a configuration issue.
-
-% DHCP_DDNS_FORWARD_REMOVE_ADDRS_REJECTED DNS Server, %1, rejected a DNS update request to remove the forward address mapping for FQDN, %2, with an RCODE: %3
-This is an error message issued when an update was rejected by the DNS server
-it was sent to for the reason given by the RCODE. The rcode values are defined
-in RFC 2136.
-
-% DHCP_DDNS_FORWARD_REMOVE_ADDRS_IO_ERROR DHCP_DDNS encountered an IO error sending a forward mapping address removal for FQDN %1 to DNS server %2
+% DHCP_DDNS_REVERSE_REPLACE_IO_ERROR DHCP_DDNS encountered an IO error sending a reverse mapping replacement for FQDN %1 to DNS server %2
 This is an error message issued when a communication error occurs while
-DHCP_DDNS is carrying out a forward address remove.  The application will retry
-against the same server or others as appropriate.
-
-% DHCP_DDNS_FORWARD_REMOVE_ADDRS_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while removing forward address mapping for FQDN, %2
-This is an error message issued when the response received by DHCP_DDNS, to a
-update request to remove a forward address mapping, is mangled or malformed.
-The application will retry against the same server or others as appropriate.
-
-% DHCP_DDNS_FORWARD_REMOVE_ADDRS_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while removing a forward address mapping for FQDN %2 to DNS server %3
-This is an error message issued when DNSClient returns an unrecognized status
-while DHCP_DDNS was removing a forward address mapping.  The request will be
-aborted.  This is most likely a programmatic issue and should be reported.
-
-% DHCP_DDNS_FORWARD_REMOVE_RRS_BUILD_FAILURE DNS udpate message to remove forward DNS RR entries could not be constructed for this request: %1,  reason: %2
-This is an error message issued when an error occurs attempting to construct
-the server bound packet requesting forward RR (DHCID RR) removal.  This is due
-to invalid data contained in the NameChangeRequest. The request will be aborted.This is most likely a configuration issue.
+DHCP_DDNS is carrying out a reverse address update.  The application will
+retry against the same server or others as appropriate.
 
-% DHCP_DDNS_FORWARD_REMOVE_RRS_REJECTED DNS Server, %1, rejected a DNS update request to remove forward RR entries for FQDN, %2, with an RCODE: %3
+% DHCP_DDNS_REVERSE_REPLACE_REJECTED DNS Server, %1, rejected a DNS update request to replace the reverse mapping for FQDN, %2, with an RCODE: %3
 This is an error message issued when an update was rejected by the DNS server
 it was sent to for the reason given by the RCODE. The rcode values are defined
 in RFC 2136.
 
-% DHCP_DDNS_FORWARD_REMOVE_RRS_IO_ERROR DHCP_DDNS encountered an IO error sending a forward RR removal for FQDN %1 to DNS server %2
-This is an error message issued when a communication error occurs while
-DHCP_DDNS is carrying out a forward RR remove.  The application will retry
-against the same server.
-
-% DHCP_DDNS_FORWARD_REMOVE_RRS_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while removing forward RRs for FQDN, %2
+% DHCP_DDNS_REVERSE_REPLACE_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while replacing reverse address mapping for FQDN, %2
 This is an error message issued when the response received by DHCP_DDNS, to a
-update request to remove forward RRs mapping, is mangled or malformed.
+update request to replace a reverse address,  is mangled or malformed.
 The application will retry against the same server or others as appropriate.
 
-% DHCP_DDNS_FORWARD_REMOVE_RRS_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while removing forward RRs for FQDN %2 to DNS server %3
-This is an error message issued when DNSClient returns an unrecognized status
-while DHCP_DDNS was removing forward RRs.  The request will be aborted. This is
-most likely a programmatic issue and should be reported.
+% DHCP_DDNS_REV_REQUEST_IGNORED Reverse updates are disabled, the reverse portion of request will be ignored: %1
+This is a debug message issued when reverse DNS updates are disabled and
+DHCP_DDNS receives an update request containing a reverse DNS update.  The
+reverse update will not performed.
 
-% DHCP_DDNS_REVERSE_REMOVE_BUILD_FAILURE DNS update message to remove a reverse DNS entry could not be constructed from this request: %1,  reason: %2
-This is an error message issued when an error occurs attempting to construct
-the server bound packet requesting a reverse PTR removal.  This is
-due to invalid data contained in the NameChangeRequest. The request will be
-aborted.  This is most likely a configuration issue.
-
-% DHCP_DDNS_REVERSE_REMOVE_REJECTED DNS Server, %1, rejected a DNS update request to remove the reverse mapping for FQDN, %2, with an RCODE: %3
-This is an error message issued when an update was rejected by the DNS server
-it was sent to for the reason given by the RCODE. The rcode values are defined
-in RFC 2136.
-
-% DHCP_DDNS_REVERSE_REMOVE_IO_ERROR DHCP_DDNS encountered an IO error sending a reverse mapping remove for FQDN %1 to DNS server %2
-This is an error message issued when a communication error occurs while
-DHCP_DDNS is carrying out a reverse address update.  The application will
-retry against the same server or others as appropriate.
+% DHCP_DDNS_RUN_ENTER application has entered the event loop
+This is a debug message issued when the Dhcp-Ddns application enters
+its run method.
 
-% DHCP_DDNS_REVERSE_REMOVE_RESP_CORRUPT DHCP_DDNS received a corrupt response from the DNS server, %1, while removing reverse address mapping for FQDN, %2
-This is an error message issued when the response received by DHCP_DDNS, to a
-update request to remove a reverse address,  is mangled or malformed.
-The application will retry against the same server or others as appropriate.
+% DHCP_DDNS_RUN_EXIT application is exiting the event loop
+This is a debug message issued when the Dhcp-Ddns exits the
+in event loop.
 
-% DHCP_DDNS_REVERSE_REMOVE_BAD_DNSCLIENT_STATUS DHCP_DDNS received an unknown DNSClient status: %1, while removing reverse address mapping for FQDN %2 to DNS server %3
-This is an error message issued when DNSClient returns an unrecognized status
-while DHCP_DDNS was removing a reverse address mapping.  The request will be
-aborted.  This is most likely a programmatic issue and should be reported.
+% DHCP_DDNS_SHUTDOWN application received shutdown command with args: %1
+This is informational message issued when the application has been instructed
+to shut down by the controller.
 
-% DHCP_DDNS_REMOVE_SUCCEEDED DHCP_DDNS successfully removed the DNS mapping addition for this request: %1
-This is a debug message issued after DHCP_DDNS has submitted DNS mapping
-removals which were received and accepted by an appropriate DNS server.
+% DHCP_DDNS_STARTING_TRANSACTION Transaction Key: %1
 
-% DHCP_DDNS_REMOVE_FAILED DHCP_DDNS failed attempting to make DNS mapping removals for this request: %1, event: %2
-This is an error message issued after DHCP_DDNS attempts to submit DNS mapping
-entry removals have failed.  The precise reason for the failure should be
-documented in preceding log entries.
+% DHCP_DDNS_STATE_MODEL_UNEXPECTED_ERROR application encountered an unexpected error while carrying out a NameChangeRequest: %1
+This is error message issued when the application fails to process a
+NameChangeRequest correctly. Some or all of the DNS updates requested as part
+of this update did not succeed. This is a programmatic error and should be
+reported.
 
-% DHCP_DDNS_STARTING_TRANSACTION Transaction Key: %1
+% DHCP_DDNS_TRANS_SEND_ERROR application encountered an unexpected error while attempting to send a DNS update: %1
+This is error message issued when the application is able to construct an update
+message but the attempt to send it suffered a unexpected error. This is most
+likely a programmatic error, rather than a communications issue. Some or all
+of the DNS updates requested as part of this request did not succeed.
 
 % DHCP_DDNS_UPDATE_REQUEST_SENT for transaction key: %1 to server: %2
 This is a debug message issued when DHCP_DDNS sends a DNS request to a DNS

+ 43 - 16
src/bin/d2/d2_update_mgr.cc

@@ -132,34 +132,61 @@ D2UpdateMgr::makeTransaction(dhcp_ddns::NameChangeRequestPtr& next_ncr) {
             << key.toStr());
     }
 
+    int direction_count = 0;
     // If forward change is enabled, match to forward servers.
     DdnsDomainPtr forward_domain;
     if (next_ncr->isForwardChange()) {
-        bool matched = cfg_mgr_->matchForward(next_ncr->getFqdn(),
-                                             forward_domain);
-        // Could not find a match for forward DNS server. Log it and get out.
-        // This has the net affect of dropping the request on the floor.
-        if (!matched) {
-            LOG_ERROR(dctl_logger, DHCP_DDNS_NO_FWD_MATCH_ERROR)
-                      .arg(next_ncr->getFqdn());
-            return;
+        if (!cfg_mgr_->forwardUpdatesEnabled()) {
+            next_ncr->setForwardChange(false);
+            LOG_DEBUG(dctl_logger, DBGLVL_TRACE_DETAIL_DATA,
+                      DHCP_DDNS_FWD_REQUEST_IGNORED).arg(next_ncr->toText());
+        } else {
+            bool matched = cfg_mgr_->matchForward(next_ncr->getFqdn(),
+                                                  forward_domain);
+            // Could not find a match for forward DNS server. Log it and get
+            // out. This has the net affect of dropping the request on the
+            // floor.
+            if (!matched) {
+                LOG_ERROR(dctl_logger, DHCP_DDNS_NO_FWD_MATCH_ERROR)
+                          .arg(next_ncr->toText());
+                return;
+            }
+
+            ++direction_count;
         }
     }
 
     // If reverse change is enabled, match to reverse servers.
     DdnsDomainPtr reverse_domain;
     if (next_ncr->isReverseChange()) {
-        bool matched = cfg_mgr_->matchReverse(next_ncr->getIpAddress(),
-                                              reverse_domain);
-        // Could not find a match for reverse DNS server. Log it and get out.
-        // This has the net affect of dropping the request on the floor.
-        if (!matched) {
-            LOG_ERROR(dctl_logger, DHCP_DDNS_NO_REV_MATCH_ERROR)
-                      .arg(next_ncr->getIpAddress());
-            return;
+        if (!cfg_mgr_->reverseUpdatesEnabled()) {
+            next_ncr->setReverseChange(false);
+            LOG_DEBUG(dctl_logger, DBGLVL_TRACE_DETAIL_DATA,
+                      DHCP_DDNS_REV_REQUEST_IGNORED).arg(next_ncr->toText());
+        } else {
+            bool matched = cfg_mgr_->matchReverse(next_ncr->getIpAddress(),
+                                                  reverse_domain);
+            // Could not find a match for reverse DNS server. Log it and get
+            // out. This has the net affect of dropping the request on the
+            // floor.
+            if (!matched) {
+                LOG_ERROR(dctl_logger, DHCP_DDNS_NO_REV_MATCH_ERROR)
+                          .arg(next_ncr->toText());
+                return;
+            }
+
+            ++direction_count;
         }
     }
 
+    // If there is nothing to actually do, then the request falls on the floor.
+    // Should we log this?
+    if (!direction_count) {
+        LOG_DEBUG(dctl_logger, DBGLVL_TRACE_DETAIL_DATA,
+                  DHCP_DDNS_REQUEST_DROPPED).arg(next_ncr->toText());
+        return;
+    }
+
     // We matched to the required servers, so construct the transaction.
     // @todo If multi-threading is implemented, one would pass in an
     // empty IOServicePtr, rather than our instance value.  This would cause

+ 15 - 7
src/bin/d2/d2_update_mgr.h

@@ -147,13 +147,21 @@ protected:
 
     /// @brief Create a new transaction for the given request.
     ///
-    /// This method will attempt to match the request to a list of configured
-    /// DNS servers.  If a list of servers is found, it will instantiate a
-    /// transaction for it and add the transaction to the transaction list.
+    /// This method will attempt to match the request to suitable DNS servers.
+    /// If matching servers are found, it will instantiate a transaction for
+    /// the requests, add the transaction to the transaction list, and start
+    /// the transaction.
     ///
-    /// If no servers are found that match the request, this constitutes a
-    /// configuration error.  The error will be logged and the request will
-    /// be discarded.
+    /// If updates in a given direction are disabled requests for updates in
+    /// that direction will be ignored.  For example: If a request is received
+    /// which asks for updates both directions but only forward updates are
+    /// enabled; only the forward update will be attempted.  Effectively, the
+    /// request will be treated as if it only asked for forward updates.
+    ///
+    /// If updates in a given direction are enabled, and a request asks for
+    /// updates in that direction, failing to match the request to a list
+    /// of servers is an error which will be logged and the request will be
+    /// discarded.
     ///
     /// @param ncr the NameChangeRequest for which to create a transaction.
     ///
@@ -162,7 +170,7 @@ protected:
     void makeTransaction(isc::dhcp_ddns::NameChangeRequestPtr& ncr);
 
 public:
-    /// @brief Gets the UpdateMgr's IOService.
+    /// @brief Gets the D2UpdateMgr's IOService.
     ///
     /// @return returns a reference to the IOService
     const IOServicePtr& getIOService() {

+ 12 - 0
src/bin/d2/tests/d2_cfg_mgr_unittests.cc

@@ -1008,6 +1008,10 @@ TEST_F(D2CfgMgrTest, fullConfig) {
         EXPECT_EQ(3, count);
     }
 
+    // Test directional update flags.
+    EXPECT_TRUE(cfg_mgr_->forwardUpdatesEnabled());
+    EXPECT_TRUE(cfg_mgr_->reverseUpdatesEnabled());
+
     // Verify that parsing the exact same configuration a second time
     // does not cause a duplicate value errors. 
     answer_ = cfg_mgr_->parseConfig(config_set_);
@@ -1061,6 +1065,10 @@ TEST_F(D2CfgMgrTest, forwardMatch) {
     D2CfgContextPtr context;
     ASSERT_NO_THROW(context = cfg_mgr_->getD2CfgContext());
 
+    // Test directional update flags.
+    EXPECT_TRUE(cfg_mgr_->forwardUpdatesEnabled());
+    EXPECT_FALSE(cfg_mgr_->reverseUpdatesEnabled());
+
     DdnsDomainPtr match;
     // Verify that an exact match works.
     EXPECT_TRUE(cfg_mgr_->matchForward("tmark.org", match));
@@ -1227,6 +1235,10 @@ TEST_F(D2CfgMgrTest, matchReverse) {
     D2CfgContextPtr context;
     ASSERT_NO_THROW(context = cfg_mgr_->getD2CfgContext());
 
+    // Test directional update flags.
+    EXPECT_FALSE(cfg_mgr_->forwardUpdatesEnabled());
+    EXPECT_TRUE(cfg_mgr_->reverseUpdatesEnabled());
+
     DdnsDomainPtr match;
 
     // Verify an exact match.

+ 103 - 0
src/bin/d2/tests/d2_update_mgr_unittests.cc

@@ -347,6 +347,109 @@ TEST_F(D2UpdateMgrTest, transactionList) {
     EXPECT_NO_THROW(update_mgr_->removeTransaction(ncr->getDhcid()));
 }
 
+/// @brief Checks transaction creation when both update directions are enabled.
+/// Verifies that when both directions are enabled and servers are matched to
+/// the request, that the transaction is created with both directions turned on.
+TEST_F(D2UpdateMgrTest, bothEnabled) {
+    // Grab a canned request for test purposes.
+    NameChangeRequestPtr& ncr = canned_ncrs_[0];
+    ncr->setReverseChange(true);
+
+    // Verify we are requesting both directions.
+    ASSERT_TRUE(ncr->isForwardChange());
+    ASSERT_TRUE(ncr->isReverseChange());
+
+    // Verify both both directions are enabled.
+    ASSERT_TRUE(cfg_mgr_->forwardUpdatesEnabled());
+    ASSERT_TRUE(cfg_mgr_->reverseUpdatesEnabled());
+
+    // Attempt to make a transaction.
+    ASSERT_NO_THROW(update_mgr_->makeTransaction(ncr));
+
+    // Verify we create a transaction with both directions turned on.
+    EXPECT_EQ(1, update_mgr_->getTransactionCount());
+    EXPECT_TRUE(ncr->isForwardChange());
+    EXPECT_TRUE(ncr->isReverseChange());
+}
+
+/// @brief Checks transaction creation when reverse updates are disabled.
+/// Verifies that when reverse updates are disabled, and there matching forward
+/// servers, that the transaction is still created but with only the forward
+/// direction turned on.
+TEST_F(D2UpdateMgrTest, reverseDisable) {
+    // Make a NCR which requests both directions.
+    NameChangeRequestPtr& ncr = canned_ncrs_[0];
+    ncr->setReverseChange(true);
+
+    // Wipe out forward domain list.
+    DdnsDomainMapPtr emptyDomains(new DdnsDomainMap());
+    cfg_mgr_->getD2CfgContext()->getReverseMgr()->setDomains(emptyDomains);
+
+    // Verify enable methods are correct.
+    ASSERT_TRUE(cfg_mgr_->forwardUpdatesEnabled());
+    ASSERT_FALSE(cfg_mgr_->reverseUpdatesEnabled());
+
+    // Attempt to make a transaction.
+    ASSERT_NO_THROW(update_mgr_->makeTransaction(ncr));
+
+    // Verify we create a transaction with only forward turned on.
+    EXPECT_EQ(1, update_mgr_->getTransactionCount());
+    EXPECT_TRUE(ncr->isForwardChange());
+    EXPECT_FALSE(ncr->isReverseChange());
+}
+
+/// @brief Checks transaction creation when forward updates are disabled.
+/// Verifies that when forward updates are disabled, and there matching reverse
+/// servers, that the transaction is still created but with only the reverse
+/// direction turned on.
+TEST_F(D2UpdateMgrTest, forwardDisabled) {
+    // Make a NCR which requests both directions.
+    NameChangeRequestPtr& ncr = canned_ncrs_[0];
+    ncr->setReverseChange(true);
+
+    // Wipe out forward domain list.
+    DdnsDomainMapPtr emptyDomains(new DdnsDomainMap());
+    cfg_mgr_->getD2CfgContext()->getForwardMgr()->setDomains(emptyDomains);
+
+    // Verify enable methods are correct.
+    ASSERT_FALSE(cfg_mgr_->forwardUpdatesEnabled());
+    ASSERT_TRUE(cfg_mgr_->reverseUpdatesEnabled());
+
+    // Attempt to make a transaction.
+    ASSERT_NO_THROW(update_mgr_->makeTransaction(ncr));
+
+    // Verify we create a transaction with only reverse turned on.
+    EXPECT_EQ(1, update_mgr_->getTransactionCount());
+    EXPECT_FALSE(ncr->isForwardChange());
+    EXPECT_TRUE(ncr->isReverseChange());
+}
+
+
+/// @brief Checks transaction creation when neither update direction is enabled.
+/// Verifies that transactions are not created when both forward and reverse
+/// directions are disabled.
+TEST_F(D2UpdateMgrTest, bothDisabled) {
+    // Grab a canned request for test purposes.
+    NameChangeRequestPtr& ncr = canned_ncrs_[0];
+    ncr->setReverseChange(true);
+    TransactionList::iterator pos;
+
+    // Wipe out both forward and reverse domain lists.
+    DdnsDomainMapPtr emptyDomains(new DdnsDomainMap());
+    cfg_mgr_->getD2CfgContext()->getForwardMgr()->setDomains(emptyDomains);
+    cfg_mgr_->getD2CfgContext()->getReverseMgr()->setDomains(emptyDomains);
+
+    // Verify enable methods are correct.
+    EXPECT_FALSE(cfg_mgr_->forwardUpdatesEnabled());
+    EXPECT_FALSE(cfg_mgr_->reverseUpdatesEnabled());
+
+    // Attempt to make a transaction.
+    ASSERT_NO_THROW(update_mgr_->makeTransaction(ncr));
+
+    // Verify that do not create a transaction.
+    EXPECT_EQ(0, update_mgr_->getTransactionCount());
+}
+
 /// @brief Tests D2UpdateManager's checkFinishedTransactions method.
 /// This test verifies that:
 /// 1. Completed transactions are removed from the transaction list.