]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[4217] HostMgr now uses exactly one identifier in get4() query
authorTomek Mrugalski <tomasz@isc.org>
Thu, 3 Dec 2015 16:47:41 +0000 (17:47 +0100)
committerTomek Mrugalski <tomasz@isc.org>
Thu, 3 Dec 2015 16:47:41 +0000 (17:47 +0100)
 - Includes fix in AllocEngine6Test ctor, provided by Thomas

src/lib/dhcpsrv/host_mgr.cc
src/lib/dhcpsrv/mysql_host_data_source.cc
src/lib/dhcpsrv/tests/alloc_engine_utils.cc

index 60dc72f519a5605cc0cca7061451d821db1faff6..c6a18c7c347caed7827d2ccba87c8f2e7c789c3d 100644 (file)
@@ -104,7 +104,12 @@ HostMgr::get4(const SubnetID& subnet_id, const HWAddrPtr& hwaddr,
             .arg(subnet_id)
             .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)")
             .arg(duid ? duid->toText() : "(duid)");
-        host = alternate_source_->get4(subnet_id, hwaddr, duid);
+        if (duid) {
+            host = alternate_source_->get4(subnet_id, HWAddrPtr(), duid);
+        }
+        if (!host && hwaddr) {
+            host = alternate_source_->get4(subnet_id, hwaddr, DuidPtr());
+        }
     }
     return (host);
 }
@@ -134,7 +139,12 @@ HostMgr::get6(const SubnetID& subnet_id, const DuidPtr& duid,
             .arg(subnet_id)
             .arg(duid ? duid->toText() : "(duid)")
             .arg(hwaddr ? hwaddr->toText() : "(no-hwaddr)");
-        host = alternate_source_->get6(subnet_id, duid, hwaddr);
+        if (duid) {
+            host = alternate_source_->get6(subnet_id, duid, HWAddrPtr());
+        }
+        if (!host && hwaddr) {
+            host = alternate_source_->get6(subnet_id, DuidPtr(), hwaddr);
+        }
     }
     return (host);
 }
index e5aeb7141365ba6631b8de6093ca5804b739bce8..593fbe9d8f088fc8968bb61295e16fb3a8ddbf30 100644 (file)
@@ -867,7 +867,7 @@ MySqlHostDataSource::get6(const SubnetID& subnet_id, const DuidPtr& duid,
     inbind[0].buffer = reinterpret_cast<char*>(&subnet_buffer);
     inbind[0].is_unsigned = MLM_TRUE;
 
-    /// @todo: Rethink the logic in BaseHostDataSource::get4(subnet, hwaddr, duid)
+    /// @todo: Rethink the logic in BaseHostDataSource::get6(subnet, hwaddr, duid)
     if (hwaddr && duid) {
         isc_throw(BadValue, "MySQL host data source get6() called with both"
                   " hwaddr and duid, only one of them is allowed");
index 46db622ac7ce8ead94c2e57ddd6f97f13254f061..94477737706d59a1098ea0235e6f6a06163082de 100644 (file)
@@ -134,6 +134,9 @@ AllocEngine6Test::AllocEngine6Test() {
     duid_ = DuidPtr(new DUID(std::vector<uint8_t>(8, 0x42)));
     iaid_ = 42;
 
+    // Create fresh instance of the HostMgr, and drop any previous HostMgr state.
+    HostMgr::instance().create();
+
     // Let's use odd hardware type to check if there is no Ethernet
     // hardcoded anywhere.
     const uint8_t mac[] = { 0, 1, 22, 33, 44, 55};