]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[#1458] addressed comments
authorRazvan Becheriu <razvan@isc.org>
Mon, 4 Jan 2021 15:56:15 +0000 (17:56 +0200)
committerRazvan Becheriu <razvan@isc.org>
Mon, 4 Jan 2021 17:14:40 +0000 (17:14 +0000)
src/lib/dhcpsrv/alloc_engine.cc

index c518d1439b0adb91ac721fdd9f64146422f95ff0..3821c8e6ed38210f0d69acb986ab8eb6c401ca19 100644 (file)
@@ -629,7 +629,7 @@ AllocEngine::findReservation(ClientContext6& ctx) {
             // belong to subnets outside of the shared network. We'll need
             // to eliminate them.
             for (auto host = hosts.begin(); host != hosts.end(); ++host) {
-                if ((*host)->getIPv6SubnetID() > 0) {
+                if ((*host)->getIPv6SubnetID() != SUBNET_ID_GLOBAL) {
                     host_map[(*host)->getIPv6SubnetID()] = *host;
                 }
             }
@@ -645,14 +645,12 @@ AllocEngine::findReservation(ClientContext6& ctx) {
             subnet->getReservationsInSubnet()) {
             // Iterate over configured identifiers in the order of preference
             // and try to use each of them to search for the reservations.
-            for (const IdentifierPair& id_pair : ctx.host_identifiers_) {
-                if (use_single_query) {
-                    if (host_map.count(subnet->getID()) > 0) {
-                        ctx.hosts_[subnet->getID()] = host_map[subnet->getID()];
-                        break;
-                    }
-
-                } else {
+            if (use_single_query) {
+                if (host_map.count(subnet->getID()) > 0) {
+                    ctx.hosts_[subnet->getID()] = host_map[subnet->getID()];
+                }
+            } else {
+                for (const IdentifierPair& id_pair : ctx.host_identifiers_) {
                     // Attempt to find a host using a specified identifier.
                     ConstHostPtr host = HostMgr::instance().get6(subnet->getID(),
                                                                  id_pair.first,
@@ -3378,7 +3376,7 @@ AllocEngine::findReservation(ClientContext4& ctx) {
             // belong to subnets outside of the shared network. We'll need
             // to eliminate them.
             for (auto host = hosts.begin(); host != hosts.end(); ++host) {
-                if ((*host)->getIPv4SubnetID() > 0) {
+                if ((*host)->getIPv4SubnetID() != SUBNET_ID_GLOBAL) {
                     host_map[(*host)->getIPv4SubnetID()] = *host;
                 }
             }
@@ -3394,14 +3392,12 @@ AllocEngine::findReservation(ClientContext4& ctx) {
             subnet->getReservationsInSubnet()) {
             // Iterate over configured identifiers in the order of preference
             // and try to use each of them to search for the reservations.
-            for (const IdentifierPair& id_pair : ctx.host_identifiers_) {
-                if (use_single_query) {
-                    if (host_map.count(subnet->getID()) > 0) {
-                        ctx.hosts_[subnet->getID()] = host_map[subnet->getID()];
-                        break;
-                    }
-
-                } else {
+            if (use_single_query) {
+                if (host_map.count(subnet->getID()) > 0) {
+                    ctx.hosts_[subnet->getID()] = host_map[subnet->getID()];
+                }
+            } else {
+                for (const IdentifierPair& id_pair : ctx.host_identifiers_) {
                     // Attempt to find a host using a specified identifier.
                     ConstHostPtr host = HostMgr::instance().get4(subnet->getID(),
                                                                  id_pair.first,