Commit 75e7e0e4 authored by Ad Schellevis's avatar Ad Schellevis

cleanup carp_status.php

parent 51aec445
...@@ -1918,6 +1918,11 @@ function interface_carp_configure(&$vip) ...@@ -1918,6 +1918,11 @@ function interface_carp_configure(&$vip)
return; return;
} }
// when CARP is temporary disabled, don't try to configure on any interface-up events
if (get_single_sysctl('net.inet.carp.allow') == '0') {
return;
}
/* NOTE: Maybe its useless nowdays */ /* NOTE: Maybe its useless nowdays */
$realif = get_real_interface($vip['interface']); $realif = get_real_interface($vip['interface']);
if (!does_interface_exist($realif)) { if (!does_interface_exist($realif)) {
......
...@@ -30,28 +30,6 @@ ...@@ -30,28 +30,6 @@
require_once("guiconfig.inc"); require_once("guiconfig.inc");
require_once("interfaces.inc"); require_once("interfaces.inc");
function interfaces_carp_set_maintenancemode($carp_maintenancemode)
{
global $config;
if (isset($config["virtualip_carp_maintenancemode"]) && $carp_maintenancemode == false) {
unset($config["virtualip_carp_maintenancemode"]);
write_config("Leave CARP maintenance mode");
} elseif (!isset($config["virtualip_carp_maintenancemode"]) && $carp_maintenancemode == true) {
$config["virtualip_carp_maintenancemode"] = true;
write_config("Enter CARP maintenance mode");
}
if (isset($config['virtualip']['vip'])) {
$viparr = &$config['virtualip']['vip'];
foreach ($viparr as $vip) {
if ($vip['mode'] == 'carp') {
interface_carp_configure($vip);
}
}
}
}
// init $config['virtualip']['vip'] // init $config['virtualip']['vip']
if ( !isset($config['virtualip']['vip']) || !is_array($config['virtualip']['vip'])) { if ( !isset($config['virtualip']['vip']) || !is_array($config['virtualip']['vip'])) {
$config['virtualip']['vip'] = array(); $config['virtualip']['vip'] = array();
...@@ -59,35 +37,45 @@ if ( !isset($config['virtualip']['vip']) || !is_array($config['virtualip']['vip' ...@@ -59,35 +37,45 @@ if ( !isset($config['virtualip']['vip']) || !is_array($config['virtualip']['vip'
$a_vip = &$config['virtualip']['vip']; $a_vip = &$config['virtualip']['vip'];
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$act = null;
if (!empty($_POST['carp_maintenancemode'])) { if (!empty($_POST['carp_maintenancemode'])) {
interfaces_carp_set_maintenancemode(!isset($config["virtualip_carp_maintenancemode"])); $act = "maintenance";
if (isset($config["virtualip_carp_maintenancemode"])) {
unset($config["virtualip_carp_maintenancemode"]);
write_config("Leave CARP maintenance mode");
} else {
$config["virtualip_carp_maintenancemode"] = true;
write_config("Enter CARP maintenance mode");
}
} elseif (!empty($_POST['disablecarp'])) { } elseif (!empty($_POST['disablecarp'])) {
if (get_single_sysctl('net.inet.carp.allow') > 0) { if (get_single_sysctl('net.inet.carp.allow') > 0) {
$carp_counter = 0; $act = "disable";
$savemsg = gettext("All virtual IPs have been disabled. Please note that disabling does not survive a reboot.");
set_single_sysctl('net.inet.carp.allow', '0'); set_single_sysctl('net.inet.carp.allow', '0');
foreach ($a_vip as $vip) {
switch ($vip['mode']) {
case "carp":
interface_vip_bring_down($vip);
$carp_counter++;
sleep(1);
break;
}
}
$savemsg = sprintf(gettext("%s IPs have been disabled. Please note that disabling does not survive a reboot."), $carp_counter);
} else { } else {
$act = "enable";
$savemsg = gettext("CARP has been enabled."); $savemsg = gettext("CARP has been enabled.");
interfaces_carp_setup();
set_single_sysctl('net.inet.carp.allow', '1');
}
foreach ($a_vip as $vip) { foreach ($a_vip as $vip) {
switch ($vip['mode']) { if ($vip['mode'] == 'carp') {
case "carp": switch ($act) {
case 'maintenance':
interface_carp_configure($vip);
break;
case 'disable':
interface_vip_bring_down($vip);
break;
case 'enable':
interface_carp_configure($vip); interface_carp_configure($vip);
sleep(1); break;
default:
break; break;
} }
} }
interfaces_carp_setup();
set_single_sysctl('net.inet.carp.allow', '1');
} }
} }
} }
......
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