summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorErmal <eri@pfsense.org>2014-11-10 15:18:55 +0100
committerErmal <eri@pfsense.org>2014-11-10 15:18:55 +0100
commitb0d054ca3b314d0ac7dcfd6a5ba30170a71fe63b (patch)
tree6b25051c7eae28368dc9e6d406749fc1293d13b9 /etc
parent5063f1df931b2887e2da2560c73fef954656e4e8 (diff)
downloadpfsense-b0d054ca3b314d0ac7dcfd6a5ba30170a71fe63b.zip
pfsense-b0d054ca3b314d0ac7dcfd6a5ba30170a71fe63b.tar.gz
Fixes #3967, configure ip alias on top of carp by joining them to the same vhid as its parent
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/interfaces.inc28
-rw-r--r--etc/inc/util.inc33
2 files changed, 47 insertions, 14 deletions
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index f560b38..97ef517 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -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) {
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index e15cdd7..c64a5ed 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -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'];
OpenPOWER on IntegriCloud