From: Marcin Siodelski Date: Tue, 27 Feb 2018 17:20:17 +0000 (+0100) Subject: [5437] HR_DISABLED option handling moved to subnet level. X-Git-Tag: ha_checkpoints12~10^2~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a3114dfcc86fe2badf56ea8c1658860a6f5a0735;p=thirdparty%2Fkea.git [5437] HR_DISABLED option handling moved to subnet level. --- diff --git a/src/bin/dhcp6/dhcp6_srv.cc b/src/bin/dhcp6/dhcp6_srv.cc index 9bf8219311..5ee0d37680 100644 --- a/src/bin/dhcp6/dhcp6_srv.cc +++ b/src/bin/dhcp6/dhcp6_srv.cc @@ -316,8 +316,7 @@ Dhcpv6Srv::initContext(const Pkt6Ptr& pkt, // Collect host identifiers if host reservations enabled. The identifiers // are stored in order of preference. The server will use them in that // order to search for host reservations. - if (ctx.subnet_ && - (ctx.subnet_->getHostReservationMode() != Network::HR_DISABLED)) { + if (ctx.subnet_) { const ConstCfgHostOperationsPtr cfg = CfgMgr::instance().getCurrentCfg()->getCfgHostOperations6(); BOOST_FOREACH(const Host::IdentifierType& id_type, diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index 4447eeaac5..72b4a61318 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -536,8 +536,9 @@ void AllocEngine::findReservation(ClientContext6& ctx) { while (subnet) { // Only makes sense to get reservations if the client has access - // to the class. - if (subnet->clientSupported(ctx.query_->getClasses())) { + // to the class and host reservations are enabled. + if (subnet->clientSupported(ctx.query_->getClasses()) && + (subnet->getHostReservationMode() != Network::HR_DISABLED)) { // Iterate over configured identifiers in the order of preference // and try to use each of them to search for the reservations. BOOST_FOREACH(const IdentifierPair& id_pair, ctx.host_identifiers_) { @@ -750,9 +751,6 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) { << Lease6::typeToText(ctx.currentIA().type_)); } - // Check which host reservation mode is supported in this subnet. - Network::HRMode hr_mode = ctx.subnet_->getHostReservationMode(); - Lease6Collection leases; IOAddress hint = IOAddress::IPV6_ZERO_ADDRESS(); @@ -789,6 +787,9 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) { if (pool) { + // Check which host reservation mode is supported in this subnet. + Network::HRMode hr_mode = subnet->getHostReservationMode(); + /// @todo: We support only one hint for now Lease6Ptr lease = LeaseMgrFactory::instance().getLease6(ctx.currentIA().type_, hint); @@ -893,6 +894,8 @@ AllocEngine::allocateUnreservedLeases6(ClientContext6& ctx) { } uint64_t max_attempts = (attempts_ > 0 ? attempts_ : possible_attempts); + Network::HRMode hr_mode = subnet->getHostReservationMode(); + for (uint64_t i = 0; i < max_attempts; ++i) { ++total_attempts;