Add checks in case there are dpinger param problems

in 2.3 installations that were upgraded from 2.2.* when the apinger to
dpinger params conversion code in upgrade_130_to_131() was not so good.

(cherry picked from commit f8f2eae491)
This commit is contained in:
Phil Davis 2016-04-15 17:40:21 +05:45 committed by Stephen Beaver
parent 048f29dce6
commit af69e4d63c
3 changed files with 61 additions and 2 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0"?>
<pfsense>
<version>15.0</version>
<version>15.1</version>
<lastchange/>
<system>
<optimization>normal</optimization>

View File

@ -99,7 +99,7 @@ $g = array(
"disablecrashreporter" => false,
"crashreporterurl" => "https://crashreporter.pfsense.org/crash_reporter.php",
"debug" => false,
"latest_config" => "15.0",
"latest_config" => "15.1",
"nopkg_platforms" => array("cdrom"),
"minimum_ram_warning" => "101",
"minimum_ram_warning_text" => "128 MB",

View File

@ -4833,4 +4833,63 @@ function upgrade_149_to_150() {
}
}
}
function upgrade_150_to_151() {
global $config;
// Default dpinger parameters at time of this upgrade (2.3.1)
$default_interval = 500;
$default_alert_interval = 1000;
$default_loss_interval = 2000;
$default_time_period = 60000;
$default_latencyhigh = 500;
// Check advanced gateway parameter relationships in case they are incorrect
foreach ($config['gateways']['gateway_item'] as &$gw) {
if (isset($gw['interval'])) {
$effective_interval = $gw['interval'];
} else {
$effective_interval = $default_interval;
}
if (isset($gw['alert_interval'])) {
$effective_alert_interval = $gw['alert_interval'];
} else {
$effective_alert_interval = $default_alert_interval;
}
if (isset($gw['loss_interval'])) {
$effective_loss_interval = $gw['loss_interval'];
} else {
$effective_loss_interval = $default_loss_interval;
}
if (isset($gw['time_period'])) {
$effective_time_period = $gw['time_period'];
} else {
$effective_time_period = $default_time_period;
}
if (isset($gw['latencyhigh'])) {
$effective_latencyhigh = $gw['latencyhigh'];
} else {
$effective_latencyhigh = $default_latencyhigh;
}
// Loss interval has to be at least as big as high latency.
if ($effective_latencyhigh > $effective_loss_interval) {
$effective_loss_interval = $gw['loss_interval'] = $effective_latencyhigh;
}
// Alert interval has to be at least as big as probe interval.
if ($effective_interval > $effective_alert_interval) {
$gw['alert_interval'] = $effective_interval;
}
// The time period for averaging has to be more than 2 probes plus the loss interval.
if ((($effective_interval * 2) + $effective_loss_interval) >= $effective_time_period) {
$gw['time_period'] = ($effective_interval * 2) + $effective_loss_interval + 1;
}
}
}
?>