]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[5437] Do not fetch reservations for subnets for which HR_DISABLED is set.
authorMarcin Siodelski <marcin@isc.org>
Sat, 24 Feb 2018 12:41:48 +0000 (13:41 +0100)
committerMarcin Siodelski <marcin@isc.org>
Mon, 26 Feb 2018 12:28:51 +0000 (13:28 +0100)
src/lib/dhcpsrv/alloc_engine.cc

index 24795c429cc1c77d5464c96b3228a6e3ed28b06d..8c9c2114fdc4545961d46200672b4bca3fee3e92 100644 (file)
@@ -2512,15 +2512,17 @@ namespace {
 /// @return true if the address is reserved for another client.
 bool
 addressReserved(const IOAddress& address, const AllocEngine::ClientContext4& ctx) {
-    ConstHostPtr host = HostMgr::instance().get4(ctx.subnet_->getID(), address);
-    if (host) {
-        for (auto id = ctx.host_identifiers_.cbegin(); id != ctx.host_identifiers_.cend();
-             ++id) {
-            if (id->first == host->getIdentifierType()) {
-                return (id->second != host->getIdentifier());
+    if (ctx.subnet_ && (ctx.subnet_->getHostReservationMode() != Network::HR_DISABLED)) {
+        ConstHostPtr host = HostMgr::instance().get4(ctx.subnet_->getID(), address);
+        if (host) {
+            for (auto id = ctx.host_identifiers_.cbegin(); id != ctx.host_identifiers_.cend();
+                 ++id) {
+                if (id->first == host->getIdentifierType()) {
+                    return (id->second != host->getIdentifier());
+                }
             }
+            return (true);
         }
-        return (true);
     }
     return (false);
 }
@@ -2804,7 +2806,8 @@ AllocEngine::findReservation(ClientContext4& ctx) {
 
         // Only makes sense to get reservations if the client has access
         // to the class.
-        if (subnet->clientSupported(ctx.query_->getClasses())) {
+        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_) {