kea: add several missing validation

PR: https://github.com/opnsense/core/issues/9343

(cherry picked from commit b6a59bb7e5)
(cherry picked from commit fcab636a4c)
(cherry picked from commit 83f9492087)
This commit is contained in:
Ad Schellevis 2026-01-27 20:05:34 +01:00 committed by Franco Fichtner
parent 26ac1fd4bc
commit 69e7e57c2a

View file

@ -91,6 +91,31 @@ class KeaDhcpv6 extends BaseModel
}
}
}
// validate changed pd_pools
foreach ($this->pd_pools->pd_pool->iterateItems() as $pool) {
if (!$validateFullModel && !$pool->isFieldChanged()) {
continue;
}
$key = $pool->__reference;
if ($pool->prefix_len->getValue() >= $pool->delegated_len->getValue()) {
$messages->appendMessage(new Message(gettext("Delegated length must be longer than or equal to prefix length"), $key . ".delegated_len"));
}
$subnet = $pool->prefix->getValue() . "/" . $pool->prefix_len->getValue();
$trange = Util::cidrToRange($subnet);
if (!Util::isSubnetStrict($subnet)) {
$messages->appendMessage(new Message(gettext("Invalid Pool boundaries, offered address is not the first address in the prefix."), $key . ".prefix"));
}
foreach ($this->pd_pools->pd_pool->iterateItems() as $tmppool) {
if ($key === $tmppool->__reference) {
continue;
}
$osubnet = $tmppool->prefix->getValue() . "/" . $tmppool->prefix_len->getValue();
$orange = Util::cidrToRange($osubnet);
if (Util::isIPInCIDR($orange[0], $subnet) || Util::isIPInCIDR($trange[0], $osubnet)) {
$messages->appendMessage(new Message(gettext("Pool overlaps with an existing one."), $key . ".prefix"));
}
}
}
return $messages;
}