]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5458] Removed ClientContext6::committed_ flag.
authorMarcin Siodelski <marcin@isc.org>
Fri, 27 Apr 2018 11:35:24 +0000 (13:35 +0200)
committerMarcin Siodelski <marcin@isc.org>
Fri, 27 Apr 2018 11:35:24 +0000 (13:35 +0200)
src/bin/dhcp6/dhcp6_srv.cc
src/bin/dhcp6/tests/hooks_unittest.cc
src/lib/dhcpsrv/alloc_engine.cc
src/lib/dhcpsrv/alloc_engine.h
src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc

index 7c9001b78b581ec0762d773e06d00f3e5a0ca683..ecc4c1fb8d8f57b2462e0470370f5797a955c3f4 100644 (file)
@@ -761,7 +761,8 @@ Dhcpv6Srv::processPacket(Pkt6Ptr& query, Pkt6Ptr& rsp) {
 
     bool packet_park = false;
 
-    if (ctx.committed_ &&
+    if (!ctx.fake_allocation_ && (ctx.query_->getType() != DHCPV6_CONFIRM) &&
+        (ctx.query_->getType() != DHCPV6_INFORMATION_REQUEST) &&
         HooksManager::calloutsPresent(Hooks.hook_index_leases6_committed_)) {
         CalloutHandlePtr callout_handle = getCalloutHandle(query);
 
@@ -1723,19 +1724,6 @@ Dhcpv6Srv::assignIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
         return (ia_rsp);
     }
 
-    // "Fake" allocation is the case when the server is processing the Solicit
-    // message without the Rapid Commit option and advertises a lease to
-    // the client, but doesn't commit this lease to the lease database. If
-    // the Solicit contains the Rapid Commit option and the server is
-    // configured to honor the Rapid Commit option, or the client has sent
-    // the Request message, the lease will be committed to the lease
-    // database. The type of the server's response may be used to determine
-    // if this is the fake allocation case or not. When the server sends
-    // Reply message it means that it is committing leases. Other message
-    // type (Advertise) means that server is not committing leases (fake
-    // allocation).
-    bool fake_allocation = (answer->getType() != DHCPV6_REPLY);
-
     // Get DDNS update direction flags
     bool do_fwd = false;
     bool do_rev = false;
@@ -1749,7 +1737,6 @@ Dhcpv6Srv::assignIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
     // Update per-packet context values.
     ctx.fwd_dns_update_ = do_fwd;
     ctx.rev_dns_update_ = do_rev;
-    ctx.fake_allocation_ = fake_allocation;
 
     // Set per-IA context values.
     ctx.createIAContext();
@@ -1777,7 +1764,7 @@ Dhcpv6Srv::assignIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
     if (lease) {
         // We have a lease! Let's wrap its content into IA_NA option
         // with IAADDR suboption.
-        LOG_INFO(lease6_logger, fake_allocation ? DHCP6_LEASE_ADVERT : DHCP6_LEASE_ALLOC)
+        LOG_INFO(lease6_logger, ctx.fake_allocation_ ? DHCP6_LEASE_ADVERT : DHCP6_LEASE_ALLOC)
             .arg(query->getLabel())
             .arg(lease->addr_.toText())
             .arg(ia->getIAID());
@@ -1803,7 +1790,7 @@ Dhcpv6Srv::assignIA_NA(const Pkt6Ptr& query, const Pkt6Ptr& answer,
         // cause of that failure. The only thing left is to insert
         // status code to pass the sad news to the client.
 
-        LOG_DEBUG(lease6_logger, DBG_DHCP6_DETAIL, fake_allocation ?
+        LOG_DEBUG(lease6_logger, DBG_DHCP6_DETAIL, ctx.fake_allocation_ ?
                   DHCP6_LEASE_ADVERT_FAIL : DHCP6_LEASE_ALLOC_FAIL)
             .arg(query->getLabel())
             .arg(ia->getIAID());
@@ -1857,19 +1844,6 @@ Dhcpv6Srv::assignIA_PD(const Pkt6Ptr& query, const Pkt6Ptr& answer,
         return (ia_rsp);
     }
 
-    // "Fake" allocation is the case when the server is processing the Solicit
-    // message without the Rapid Commit option and advertises a lease to
-    // the client, but doesn't commit this lease to the lease database. If
-    // the Solicit contains the Rapid Commit option and the server is
-    // configured to honor the Rapid Commit option, or the client has sent
-    // the Request message, the lease will be committed to the lease
-    // database. The type of the server's response may be used to determine
-    // if this is the fake allocation case or not. When the server sends
-    // Reply message it means that it is committing leases. Other message
-    // type (Advertise) means that server is not committing leases (fake
-    // allocation).
-    ctx.fake_allocation_ = (answer->getType() != DHCPV6_REPLY);
-
     // Set per-IA context values.
     ctx.createIAContext();
     ctx.currentIA().iaid_ = ia->getIAID();
@@ -2726,6 +2700,19 @@ Dhcpv6Srv::processSolicit(AllocEngine::ClientContext6& ctx) {
         }
     }
 
+    // "Fake" allocation is the case when the server is processing the Solicit
+    // message without the Rapid Commit option and advertises a lease to
+    // the client, but doesn't commit this lease to the lease database. If
+    // the Solicit contains the Rapid Commit option and the server is
+    // configured to honor the Rapid Commit option, or the client has sent
+    // the Request message, the lease will be committed to the lease
+    // database. The type of the server's response may be used to determine
+    // if this is the fake allocation case or not. When the server sends
+    // Reply message it means that it is committing leases. Other message
+    // type (Advertise) means that server is not committing leases (fake
+    // allocation).
+    ctx.fake_allocation_ = (response->getType() != DHCPV6_REPLY);
+
     processClientFqdn(solicit, response, ctx);
     assignLeases(solicit, response, ctx);
 
@@ -2773,8 +2760,6 @@ Dhcpv6Srv::processRequest(AllocEngine::ClientContext6& ctx) {
     generateFqdn(reply);
     createNameChangeRequests(reply, ctx);
 
-    ctx.committed_ = true;
-
     return (reply);
 }
 
@@ -2801,8 +2786,6 @@ Dhcpv6Srv::processRenew(AllocEngine::ClientContext6& ctx) {
     generateFqdn(reply);
     createNameChangeRequests(reply, ctx);
 
-    ctx.committed_ = true;
-
     return (reply);
 }
 
@@ -2829,8 +2812,6 @@ Dhcpv6Srv::processRebind(AllocEngine::ClientContext6& ctx) {
     generateFqdn(reply);
     createNameChangeRequests(reply, ctx);
 
-    ctx.committed_ = true;
-
     return (reply);
 }
 
@@ -2947,8 +2928,6 @@ Dhcpv6Srv::processRelease(AllocEngine::ClientContext6& ctx) {
     /// @todo If client sent a release and we should remove outstanding
     /// DNS records.
 
-    ctx.committed_ = true;
-
     return (reply);
 }
 
@@ -2973,7 +2952,6 @@ Dhcpv6Srv::processDecline(AllocEngine::ClientContext6& ctx) {
     appendDefaultOptions(decline, reply, co_list);
 
     if (declineLeases(decline, reply, ctx)) {
-        ctx.committed_ = true;
         return (reply);
     } else {
 
index 476d219c0b1428a26acfea7dea67419dbb097dd2..0aecfb1d747021d4923ed86949de12624d4629be 100644 (file)
@@ -3740,7 +3740,7 @@ TEST_F(LoadUnloadDhcpv6SrvTest, Dhcpv6SrvConfigured) {
 
     // Make sure there were no errors.
     int status_code;
-    std::cout << isc::config::parseAnswer(status_code, answer)->str() << std::endl;
+    isc::config::parseAnswer(status_code, answer);
     ASSERT_EQ(0, status_code);
 
     // The hook library should have been loaded.
index 452e970c7d3f4e3bb40ed3854af188ea1e041bb1..e393e4702e770476209b14a9c759961914be6002 100644 (file)
@@ -429,8 +429,7 @@ namespace dhcp {
 AllocEngine::ClientContext6::ClientContext6()
     : query_(), fake_allocation_(false), subnet_(), host_subnet_(), duid_(),
       hwaddr_(), host_identifiers_(), hosts_(), fwd_dns_update_(false),
-      rev_dns_update_(false), committed_(false), hostname_(),
-      callout_handle_(), ias_() {
+      rev_dns_update_(false), hostname_(), callout_handle_(), ias_() {
 }
 
 AllocEngine::ClientContext6::ClientContext6(const Subnet6Ptr& subnet,
@@ -443,9 +442,9 @@ AllocEngine::ClientContext6::ClientContext6(const Subnet6Ptr& subnet,
                                             const CalloutHandlePtr& callout_handle)
     : query_(query), fake_allocation_(fake_allocation), subnet_(subnet),
       duid_(duid), hwaddr_(), host_identifiers_(), hosts_(),
-      fwd_dns_update_(fwd_dns), rev_dns_update_(rev_dns), committed_(false),
-      hostname_(hostname), callout_handle_(callout_handle),
-      allocated_resources_(), new_leases_(), deleted_leases_(), ias_() {
+      fwd_dns_update_(fwd_dns), rev_dns_update_(rev_dns), hostname_(hostname),
+      callout_handle_(callout_handle), allocated_resources_(), new_leases_(),
+      deleted_leases_(), ias_() {
 
     // Initialize host identifiers.
     if (duid) {
index e16dc6a311a08154d5a81e44c2ecc8c233375d11..7c761ba6d3450b27da1b19f45883fcbd08ffbf69 100644 (file)
@@ -365,10 +365,6 @@ public:
         ///        (if true).
         bool rev_dns_update_;
 
-        /// @brief A boolean value which indicates that server must
-        ///        invoke the leases committed callout (if true).
-        bool committed_;
-
         /// @brief Hostname.
         ///
         /// The server retrieves the hostname from the Client FQDN option,
index 8f36ed97bfd0bfbcc8f1661c3234ccf994400410..0a8afebc32334a489c8cd674712d01f33af0d660 100644 (file)
@@ -35,7 +35,6 @@ TEST(ClientContext6Test, addHint) {
 // a context.
 TEST(ClientContext6Test, addAllocatedResource) {
    AllocEngine::ClientContext6 ctx;
-   ASSERT_FALSE(ctx.committed_);
    ctx.addAllocatedResource(IOAddress("2001:db8:1::1"));
    ctx.addAllocatedResource(IOAddress("3000:1::"), 64);