Commit bc2765ea authored by Ad Schellevis's avatar Ad Schellevis

bring vips down when interface is down, fix carp setup order.

parent b90babbf
......@@ -1158,6 +1158,18 @@ function interface_reconfigure($interface = 'wan', $reloadall = false)
interface_configure($interface, $reloadall);
}
function interface_vips_bring_down($intf)
{
global $config;
if (!empty($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $vip) {
if ($vip['interface'] == $intf) {
interface_vip_bring_down($vip);
}
}
}
}
function interface_vip_bring_down($vip)
{
$vipif = get_real_interface($vip['interface']);
......@@ -1825,7 +1837,17 @@ function interfaces_carp_setup()
mwexec("/sbin/ifconfig pfsync0 -syncdev -syncpeer down", false);
}
if (isset($config['virtualip']['vip']) && $config['virtualip']['vip']) {
$has_carp_vips = false;
if (isset($config['virtualip']['vip']) && count($config['virtualip']['vip']) > 0) {
foreach ($config['virtualip']['vip'] as $vip) {
if ($vip['mode'] == 'carp') {
$has_carp_vips = true;
break;
}
}
}
if ($has_carp_vips) {
set_single_sysctl("net.inet.carp.allow", "1");
} else {
set_single_sysctl("net.inet.carp.allow", "0");
......@@ -1924,6 +1946,10 @@ function interfaces_vips_configure($interface = '')
if ($interface <> "" && $vip['interface'] <> $interface) {
continue;
}
if (!$carp_setuped) {
// interfaces_carp_setup will enable carp when pfsync completes.
set_single_sysctl("net.inet.carp.allow", "0");
}
if ($carp_setuped == false) {
$carp_setuped = true;
}
......
......@@ -68,6 +68,7 @@ function handle_argument_group($iface, $argument2) {
case "stop":
log_error("DEVD Ethernet detached event for {$iface}");
interface_bring_down($iface);
interface_vips_bring_down($iface);
break;
case "start":
log_error("DEVD Ethernet attached event for {$iface}");
......
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