]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5437] HR_DISABLED option handling moved to subnet level.
authorMarcin Siodelski <marcin@isc.org>
Tue, 27 Feb 2018 17:20:17 +0000 (18:20 +0100)
committerMarcin Siodelski <marcin@isc.org>
Tue, 27 Feb 2018 17:20:17 +0000 (18:20 +0100)
src/bin/dhcp6/dhcp6_srv.cc
src/lib/dhcpsrv/alloc_engine.cc

index 9bf8219311b684e7d7e19d7897e4c0ad3e02479f..5ee0d37680945e1a45366754688b5b1192191e54 100644 (file)
@@ -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,
index 4447eeaac5bffe704c11b528f1e90f2aca6a4469..72b4a61318f801a8b4284e829f1701921c4b2593 100644 (file)
@@ -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;