From: Razvan Becheriu Date: Mon, 4 Jan 2021 15:56:15 +0000 (+0200) Subject: [#1458] addressed comments X-Git-Tag: Kea-1.9.4~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9d4ebc82a17c3bbef536677200caa3423f270a7f;p=thirdparty%2Fkea.git [#1458] addressed comments --- diff --git a/src/lib/dhcpsrv/alloc_engine.cc b/src/lib/dhcpsrv/alloc_engine.cc index c518d1439b..3821c8e6ed 100644 --- a/src/lib/dhcpsrv/alloc_engine.cc +++ b/src/lib/dhcpsrv/alloc_engine.cc @@ -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,