Commit e05819fb authored by Tomek Mrugalski's avatar Tomek Mrugalski 🛰
Browse files

[4217] HostMgr now uses exactly one identifier in get4() query

 - Includes fix in AllocEngine6Test ctor, provided by Thomas
parent 599edbc9
......@@ -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);
}
......
......@@ -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");
......
......@@ -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};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment