Browse Source

[3352] Added test to not create NCRs if FQDN flags indicate none required

Dhcpv6Srv::createNameChangeRequests was not catching cases where FQDN flags
indicate NO changes should be made. This causes an exception to thrown by
the NCR constructor stating that both forward and reverse flags cannot be
false. Also moved the check up in the method, above of the options loop.
Thomas Markwalder 11 years ago
parent
commit
4fc2c2cb25
1 changed files with 14 additions and 9 deletions
  1. 14 9
      src/bin/dhcp6/dhcp6_srv.cc

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

@@ -1032,6 +1032,19 @@ Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer) {
         return;
     }
 
+    // Get the update directions that should be performed based on our
+    // response FQDN flags.
+    bool do_fwd = false;
+    bool do_rev = false;
+    CfgMgr::instance().getD2ClientMgr().getUpdateDirections(*opt_fqdn,
+                                                             do_fwd, do_rev);
+    if (!do_fwd && !do_rev) {
+        // Flags indicate there is Nothing to do, get out now.
+        // The Most likely scenario is that we are honoring the client's
+        // request that no updates be done.
+        return;
+    }
+
     // Get the Client Id. It is mandatory and a function creating a response
     // would have thrown an exception if it was missing. Thus throwning
     // Unexpected if it is missing as it is a programming error.
@@ -1071,16 +1084,8 @@ Dhcpv6Srv::createNameChangeRequests(const Pkt6Ptr& answer) {
         // Create new NameChangeRequest. Use the domain name from the FQDN.
         // This is an FQDN included in the response to the client, so it
         // holds a fully qualified domain-name already (not partial).
-        // Get the IP address from the lease. Also, use the S flag to determine
-        // if forward change should be performed. This flag will always be
-        // set if server has taken responsibility for the forward update.
-        // Use the inverse of the N flag to determine if a reverse change
-        // should be performed.
+        // Get the IP address from the lease.
         NameChangeRequestPtr ncr;
-        bool do_fwd = false;
-        bool do_rev = false;
-        CfgMgr::instance().getD2ClientMgr().getUpdateDirections(*opt_fqdn,
-                                                                do_fwd, do_rev);
         ncr.reset(new NameChangeRequest(isc::dhcp_ddns::CHG_ADD,
                                         do_fwd, do_rev,
                                         opt_fqdn->getDomainName(),