From: Marcin Siodelski Date: Fri, 27 Apr 2018 11:35:24 +0000 (+0200) Subject: [5458] Removed ClientContext6::committed_ flag. X-Git-Tag: trac5488_base~2^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=050f91156f7f41493d2d7bd7def6f952c880b4d4;p=thirdparty%2Fkea.git [5458] Removed ClientContext6::committed_ flag. --- diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 7c9001b78b..ecc4c1fb8d 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -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 { diff --git a/src/bin/dhcp6/tests/hooks_unittest.cc b/src/bin/dhcp6/tests/hooks_unittest.cc index 476d219c0b..0aecfb1d74 100644 --- a/src/bin/dhcp6/tests/hooks_unittest.cc +++ b/src/bin/dhcp6/tests/hooks_unittest.cc @@ -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. diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 452e970c7d..e393e4702e 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -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) { diff --git a/src/lib/dhcpsrv/alloc_engine.h b/src/lib/dhcpsrv/alloc_engine.h index e16dc6a311..7c761ba6d3 100644 --- a/src/lib/dhcpsrv/alloc_engine.h +++ b/src/lib/dhcpsrv/alloc_engine.h @@ -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, diff --git a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc index 8f36ed97bf..0a8afebc32 100644 --- a/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc +++ b/src/lib/dhcpsrv/tests/alloc_engine6_unittest.cc @@ -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);