mirror of
https://github.com/opnsense/core.git
synced 2026-02-03 20:39:42 -05:00
kea: add several missing validation
PR: https://github.com/opnsense/core/issues/9343 (cherry picked from commitb6a59bb7e5) (cherry picked from commitfcab636a4c) (cherry picked from commit83f9492087)
This commit is contained in:
parent
26ac1fd4bc
commit
69e7e57c2a
1 changed files with 25 additions and 0 deletions
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue