Fixes #3967, configure ip alias on top of carp by joining them to the same vhid as its parent
This commit is contained in:
parent
5063f1df93
commit
b0d054ca3b
|
@ -2150,20 +2150,30 @@ function interfaces_vips_configure($interface = "") {
|
|||
function interface_ipalias_configure(&$vip) {
|
||||
global $config;
|
||||
|
||||
if ($vip['mode'] != "ipalias")
|
||||
if ($vip['mode'] != 'ipalias')
|
||||
return;
|
||||
|
||||
if ($vip['interface'] != 'lo0' && !isset($config['interfaces'][$vip['interface']]))
|
||||
return;
|
||||
if ($vip['interface'] != 'lo0' && stripos($vip['interface'], '_vip') === false) {
|
||||
if (!isset($config['interfaces'][$vip['interface']]))
|
||||
return;
|
||||
|
||||
if ($vip['interface'] != 'lo0' && !isset($config['interfaces'][$vip['interface']]['enable']))
|
||||
return;
|
||||
if (!isset($config['interfaces'][$vip['interface']]['enable']))
|
||||
return;
|
||||
}
|
||||
|
||||
$if = get_real_interface($vip['interface']);
|
||||
$af = "inet";
|
||||
$af = 'inet';
|
||||
if(is_ipaddrv6($vip['subnet']))
|
||||
$af = "inet6";
|
||||
mwexec("/sbin/ifconfig " . escapeshellarg($if) ." {$af} ". escapeshellarg($vip['subnet']) ."/" . escapeshellarg($vip['subnet_bits']) . " alias");
|
||||
$af = 'inet6';
|
||||
$iface = $vip['interface'];
|
||||
$vipadd = '';
|
||||
if (stripos($vip['interface'], '_vip')) {
|
||||
$carpvip = get_configured_carp_interface_list($vip['interface'], $af, 'vip');
|
||||
$iface = $carpvip['interface'];
|
||||
$vipadd = "vhid {$carpvip['vhid']}";
|
||||
}
|
||||
$if = get_real_interface($vip['interface']);
|
||||
mwexec("/sbin/ifconfig " . escapeshellarg($if) ." {$af} ". escapeshellarg($vip['subnet']) ."/" . escapeshellarg($vip['subnet_bits']) . " alias {$vipadd}");
|
||||
unset($iface, $af, $if, $carpvip, $vipadd);
|
||||
}
|
||||
|
||||
function interface_reload_carps($cif) {
|
||||
|
|
|
@ -826,7 +826,7 @@ function is_inrange($test, $start, $end) {
|
|||
}
|
||||
|
||||
/* XXX: return the configured carp interface list */
|
||||
function get_configured_carp_interface_list($carpinterface = "", $family = "inet") {
|
||||
function get_configured_carp_interface_list($carpinterface = '', $family = 'inet', $what = 'ip') {
|
||||
global $config;
|
||||
|
||||
$iflist = array();
|
||||
|
@ -838,10 +838,33 @@ function get_configured_carp_interface_list($carpinterface = "", $family = "inet
|
|||
case "carp":
|
||||
if (!empty($carpinterface)) {
|
||||
if ($carpinterface == "{$vip['interface']}_vip{$vip['vhid']}") {
|
||||
if ($family == "inet" && is_ipaddrv4($vip['subnet']))
|
||||
return $vip['subnet'];
|
||||
else if ($family == "inet6" && is_ipaddrv6($vip['subnet']))
|
||||
return $vip['subnet'];
|
||||
switch ($what) {
|
||||
case 'subnet':
|
||||
if ($family == 'inet' && is_ipaddrv4($vip['subnet']))
|
||||
return "{$vip['subnet']}/{$vip['subnet_bits']}";
|
||||
else if ($family == 'inet6' && is_ipaddrv6($vip['subnet']))
|
||||
return "{$vip['subnet']}/{$vip['subnet_bits']}";
|
||||
break;
|
||||
case 'iface':
|
||||
if ($family == 'inet' && is_ipaddrv4($vip['subnet']))
|
||||
return $vip['interface'];
|
||||
else if ($family == 'inet6' && is_ipaddrv6($vip['subnet']))
|
||||
return $vip['interface'];
|
||||
break;
|
||||
case 'vip':
|
||||
if ($family == 'inet' && is_ipaddrv4($vip['subnet']))
|
||||
return $vip;
|
||||
else if ($family == 'inet6' && is_ipaddrv6($vip['subnet']))
|
||||
return $vip;
|
||||
break;
|
||||
case 'ip':
|
||||
default:
|
||||
if ($family == 'inet' && is_ipaddrv4($vip['subnet']))
|
||||
return $vip['subnet'];
|
||||
else if ($family == 'inet6' && is_ipaddrv6($vip['subnet']))
|
||||
return $vip['subnet'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$iflist["{$vip['interface']}_vip{$vip['vhid']}"] = $vip['subnet'];
|
||||
|
|
Reference in New Issue