summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--etc/inc/filter.inc2
-rw-r--r--etc/inc/gwlb.inc7
-rw-r--r--etc/inc/interfaces.inc176
-rw-r--r--etc/inc/pfsense-utils.inc14
-rw-r--r--etc/inc/services.inc6
-rw-r--r--etc/inc/system.inc45
-rw-r--r--etc/inc/util.inc4
-rw-r--r--etc/inc/vpn.inc2
-rwxr-xr-xetc/rc.carpbackup21
-rwxr-xr-xetc/rc.carpmaster23
-rw-r--r--usr/local/pkg/openntpd.inc12
-rw-r--r--usr/local/www/carp_status.php6
-rw-r--r--usr/local/www/interfaces_gif_edit.php8
-rw-r--r--usr/local/www/interfaces_gre_edit.php8
-rw-r--r--usr/local/www/services_dnsmasq.php15
-rw-r--r--usr/local/www/services_snmp.php10
-rw-r--r--usr/local/www/services_unbound.php29
-rw-r--r--usr/local/www/system_gateway_groups_edit.php4
-rw-r--r--usr/local/www/widgets/widgets/carp_status.widget.php2
-rwxr-xr-xusr/local/www/xmlrpc.php4
20 files changed, 204 insertions, 194 deletions
diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc
index 03d21f2..6b044d6 100644
--- a/etc/inc/filter.inc
+++ b/etc/inc/filter.inc
@@ -3678,7 +3678,7 @@ function filter_generate_ipsec_rules($log = array()) {
}
if (strpos($ph1ent['interface'], "_vip"))
- list($parentinterface, $vhid) = explode("_vip", $ph1ent['interface']);
+ $parentinterface = get_configured_carp_interface_list($ph1ent['interface'], '', 'iface');
else
$parentinterface = $ph1ent['interface'];
if (empty($FilterIflist[$parentinterface]['descr'])) {
diff --git a/etc/inc/gwlb.inc b/etc/inc/gwlb.inc
index 53e69eb..70acf38 100644
--- a/etc/inc/gwlb.inc
+++ b/etc/inc/gwlb.inc
@@ -989,8 +989,10 @@ function lookup_gateway_interface_by_name($name) {
function get_interface_gateway($interface, &$dynamic = false) {
global $config, $g;
- $gw = NULL;
+ if (substr($interface, 0, 4) == 'vip')
+ $interface = get_configured_carp_interface_list($interface, 'inet6', 'iface');
+ $gw = NULL;
$gwcfg = $config['interfaces'][$interface];
if (!empty($gwcfg['gateway']) && is_array($config['gateways']['gateway_item'])) {
foreach($config['gateways']['gateway_item'] as $gateway) {
@@ -1020,6 +1022,9 @@ function get_interface_gateway($interface, &$dynamic = false) {
function get_interface_gateway_v6($interface, &$dynamic = false) {
global $config, $g;
+ if (substr($interface, 0, 4) == 'vip')
+ $interface = get_configured_carp_interface_list($interface, 'inet6', 'iface');
+
$gw = NULL;
$gwcfg = $config['interfaces'][$interface];
if (!empty($gwcfg['gatewayv6']) && is_array($config['gateways']['gateway_item'])) {
diff --git a/etc/inc/interfaces.inc b/etc/inc/interfaces.inc
index cd709a9..6c5ee1b 100644
--- a/etc/inc/interfaces.inc
+++ b/etc/inc/interfaces.inc
@@ -412,7 +412,8 @@ function interfaces_bridge_configure($checkmember = 0, $realif = "") {
continue;
if ($checkmember == 1) {
- if (strstr($bridge['if'], "_vip"))
+ /* XXX: It should not be possible no? */
+ if (strstr($bridge['if'], '_vip'))
continue;
$members = explode(',', $bridge['members']);
foreach ($members as $member) {
@@ -421,6 +422,7 @@ function interfaces_bridge_configure($checkmember = 0, $realif = "") {
}
}
else if ($checkmember == 2) {
+ /* XXX: It should not be possible no? */
if (!strstr($bridge['if'], "_vip"))
continue;
$members = explode(',', $bridge['members']);
@@ -719,13 +721,17 @@ function interfaces_gre_configure($checkparent = 0, $realif = "") {
continue;
if ($checkparent == 1) {
- if (strstr($gre['if'], "_vip"))
+ if (substr($gre['if'], 0, 4) == '_vip')
+ continue;
+ if (substr($gre['if'], 0, 5) == '_lloc')
continue;
if (!empty($config['interfaces'][$gre['if']]) && $config['interfaces'][$gre['if']]['ipaddrv6'] == "track6")
continue;
}
else if ($checkparent == 2) {
- if (!strstr($gre['if'], "_vip"))
+ if (substr($gre['if'], 0, 4) == '_vip')
+ continue;
+ if (substr($gre['if'], 0, 5) == '_lloc')
continue;
if (empty($config['interfaces'][$gre['if']]) || $config['interfaces'][$gre['if']]['ipaddrv6'] != "track6")
continue;
@@ -800,13 +806,17 @@ function interfaces_gif_configure($checkparent = 0, $realif = "") {
continue;
if ($checkparent == 1) {
- if (strstr($gif['if'], "_vip"))
+ if (substr($gif['if'], 0, 4) == '_vip')
+ continue;
+ if (substr($gif['if'], 0, 5) == '_lloc')
continue;
if (!empty($config['interfaces'][$gif['if']]) && $config['interfaces'][$gif['if']]['ipaddrv6'] == "track6")
continue;
}
else if ($checkparent == 2) {
- if (!strstr($gif['if'], "_vip"))
+ if (substr($gif['if'], 0, 4) == '_vip')
+ continue;
+ if (substr($gif['if'], 0, 5) == '_lloc')
continue;
if (empty($config['interfaces'][$gif['if']]) || $config['interfaces'][$gif['if']]['ipaddrv6'] != "track6")
continue;
@@ -825,7 +835,7 @@ function interface_gif_configure(&$gif, $gifkey = "") {
return -1;
$realif = get_real_interface($gif['if']);
- $ipaddr = $gif['ipaddr'];
+ $ipaddr = get_interface_ip($gif['if']);
if (is_ipaddrv4($gif['remote-addr'])) {
if (is_ipaddrv4($ipaddr))
@@ -4062,7 +4072,7 @@ function convert_friendly_interface_to_friendly_descr($interface) {
else
$ifdesc = strtoupper($config['interfaces'][$interface]['descr']);
break;
- } else if (stristr($interface, "_vip")) {
+ } else if (substr($interface, 0, 4) == '_vip')) {
if (is_array($config['virtualip']['vip'])) {
foreach ($config['virtualip']['vip'] as $counter => $vip) {
if ($vip['mode'] == "carp") {
@@ -4071,6 +4081,8 @@ function convert_friendly_interface_to_friendly_descr($interface) {
}
}
}
+ } else if (substr($interface, 0, 5) == '_lloc')) {
+ return get_interface_linklocal($interface);
} else {
/* if list */
$ifdescrs = get_configured_interface_with_descr(false, true);
@@ -4209,11 +4221,20 @@ function get_real_interface($interface = "wan", $family = "all", $realv6iface =
$wanif = "ppp";
break;
default:
- // If a real interface was alread passed simply
- // pass the real interface back. This encourages
- // the usage of this function in more cases so that
- // we can combine logic for more flexibility.
- if(does_interface_exist($interface, $flush)) {
+ if (substr($interface, 0, 4) == '_vip') {
+ $wanif = get_configured_carp_interface_list($interface, '', 'iface');
+ if (!empty($wanif))
+ $wanif = get_real_interface($wanif, $family);
+ break;
+ } else if (substr($interface, 0, 5) == '_lloc') {
+ $interface = substr($interface, 5);
+ } else if (does_interface_exist($interface, $flush)) {
+ /*
+ * If a real interface was alread passed simply
+ * pass the real interface back. This encourages
+ * the usage of this function in more cases so that
+ * we can combine logic for more flexibility.
+ */
$wanif = $interface;
break;
}
@@ -4579,7 +4600,7 @@ function link_interface_to_vlans($int, $action = "") {
}
}
-function link_interface_to_vips($int, $action = "") {
+function link_interface_to_vips($int, $action = "", $vhid = '') {
global $config;
if (is_array($config['virtualip']['vip'])) {
@@ -4588,8 +4609,10 @@ function link_interface_to_vips($int, $action = "") {
if ($int == $vip['interface']) {
if ($action == "update")
interfaces_vips_configure($int);
- else
- $result[] = $vip;
+ else {
+ if (empty($vhid) || ($vhid == $vip['vhid']))
+ $result[] = $vip;
+ }
}
}
return $result;
@@ -4788,15 +4811,60 @@ function ip_in_interface_alias_subnet($interface, $ipalias) {
return false;
}
+function get_possible_listen_ips($include_ipv6_link_local=false) {
+
+ $interfaces = get_configured_interface_with_descr();
+ foreach ($interfaces as $iface => $ifacename) {
+ if ($include_ipv6_link_local) {
+ /* This is to avoid going though added ll below */
+ if (substr($iface, 0, 5) == '_lloc')
+ continue;
+ $llip = find_interface_ipv6_ll(get_real_interface($iface));
+ if (!empty($llip)) {
+ $interfaces["_lloc{$iface}"] = "{$ifacename} IPv6 Link-Local";
+ }
+ }
+ }
+ /* XXX: Maybe use array_merge below? */
+ $carplist = get_configured_carp_interface_list();
+ foreach ($carplist as $cif => $carpip)
+ $interfaces[$cif] = $carpip . ' (' . get_vip_descr($carpip) . ')';
+ $aliaslist = get_configured_ip_aliases_list();
+ foreach ($aliaslist as $aliasip => $aliasif)
+ $interfaces[$aliasip] = $aliasip . ' (' . get_vip_descr($aliasip) . ')';
+
+ $interfaces['lo0'] = 'Localhost';
+
+ return $interfaces;
+}
+
+function get_possible_traffic_source_addresses($include_ipv6_link_local=false) {
+ global $config;
+
+ $sourceips = get_possible_listen_ips($include_ipv6_link_local);
+ foreach (array('server', 'client') as $mode) {
+ if (is_array($config['openvpn']["openvpn-{$mode}"])) {
+ foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
+ if (!isset($setting['disable'])) {
+ $vpn = array();
+ $vpn['value'] = 'ovpn' . substr($mode, 0, 1) . $setting['vpnid'];
+ $vpn['name'] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']);
+ $sourceips[] = $vpn;
+ }
+ }
+ }
+ }
+ return $sourceips;
+}
+
function get_interface_ip($interface = "wan") {
$realif = get_failover_interface($interface);
- if (!$realif) {
- if (strstr($interface, "_vip"))
- return get_configured_carp_interface_list($interface);
- else
- return null;
- }
+ if (!$realif)
+ return null;
+
+ if (substr($realif, 0, 4) == '_vip')
+ return get_configured_carp_interface_list($realif, 'inet', 'ip');
$curip = find_interface_ip($realif);
if ($curip && is_ipaddr($curip) && ($curip != "0.0.0.0"))
@@ -4808,13 +4876,15 @@ function get_interface_ip($interface = "wan") {
function get_interface_ipv6($interface = "wan", $flush = false) {
global $config;
- $realif = get_failover_interface($interface, "inet6");
- if (!$realif) {
- if (strstr($interface, "_vip"))
- return get_configured_carp_interface_list($interface, "inet6");
- else
- return null;
- }
+ $realif = get_failover_interface($interface, 'inet6');
+ if (!$realif)
+ return null;
+
+ if (substr($realif, 0, 4) == '_vip')
+ return get_configured_carp_interface_list($realif, 'inet6', 'ip');
+ else if (substr($realif, 0, 5) == '_lloc')
+ return get_interface_linklocal($interface);
+
/*
* NOTE: On the case when only the prefix is requested,
@@ -4827,7 +4897,7 @@ function get_interface_ipv6($interface = "wan", $flush = false) {
case 'pptp':
case 'ppp':
if ($config['interfaces'][$interface]['ipaddrv6'] == 'dhcp6')
- $realif = get_real_interface($interface, "inet6", true);
+ $realif = get_real_interface($interface, 'inet6', true);
break;
}
if (isset($config['interfaces'][$interface]['dhcp6prefixonly'])) {
@@ -4846,14 +4916,14 @@ function get_interface_ipv6($interface = "wan", $flush = false) {
function get_interface_linklocal($interface = "wan") {
- $realif = get_failover_interface($interface, "inet6");
- if (!$realif) {
- if (strstr($interface, "_vip")) {
- list($interface, $vhid) = explode("_vip", $interface);
- $realif = get_real_interface($interface);
- } else
- return null;
- }
+ $realif = get_failover_interface($interface, 'inet6');
+ if (!$realif)
+ return null;
+
+ if (substr($interface, 0, 4) == '_vip')
+ $realif = get_real_interface($interface);
+ else if (substr($interface, 0, 5) == '_lloc')
+ $realif = get_real_interface(substr($interface, 5));
$curip = find_interface_ipv6_ll($realif);
if ($curip && is_ipaddrv6($curip) && ($curip != "::"))
@@ -4863,14 +4933,13 @@ function get_interface_linklocal($interface = "wan") {
}
function get_interface_subnet($interface = "wan") {
+
+ if (substr($interface, 0, 4) == '_vip')
+ return get_configured_carp_interface_list($interface, 'inet', 'subnet');
+
$realif = get_real_interface($interface);
- if (!$realif) {
- if (strstr($interface, "_vip")) {
- list($interface, $vhid) = explode("_vip", $interface);
- $realif = get_real_interface($interface);
- } else
- return null;
- }
+ if (!$realif)
+ return null;
$cursn = find_interface_subnet($realif);
if (!empty($cursn))
@@ -4880,16 +4949,15 @@ function get_interface_subnet($interface = "wan") {
}
function get_interface_subnetv6($interface = "wan") {
- global $config;
- $realif = get_real_interface($interface, "inet6");
- if (!$realif) {
- if (strstr($interface, "_vip")) {
- list($interface, $vhid) = explode("_vip", $interface);
- $realif = get_real_interface($interface);
- } else
- return null;
- }
+ if (substr($interface, 0, 4) == '_vip')
+ return get_configured_carp_interface_list($interface, 'inet6', 'subnet');
+ else if (substr($interface, 0, 5) == '_lloc')
+ $interface = substr($interface, 5);
+
+ $realif = get_real_interface($interface, 'inet6');
+ if (!$realif)
+ return null;
$cursn = find_interface_subnetv6($realif);
if (!empty($cursn))
@@ -5263,7 +5331,7 @@ function get_failover_interface($interface, $family = "all") {
$a_groups = return_gateway_groups_array();
if (is_array($a_groups[$interface])) {
/* we found a gateway group, fetch the interface or vip */
- if ($a_groups[$interface][0]['vip'] <> "")
+ if (!empty($a_groups[$interface][0]['vip']))
return $a_groups[$interface][0]['vip'];
else
return $a_groups[$interface][0]['int'];
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 1bfa1a4..a89c151 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -369,18 +369,16 @@ function convert_ip_to_network_format($ip, $subnet) {
* get_carp_interface_status($carpinterface): returns the status of a carp ip
*/
function get_carp_interface_status($carpinterface) {
- $carp_query = "";
- /* XXX: Need to fidn a better way for this! */
- list ($interface, $vhid) = explode("_vip", $carpinterface);
$interface = get_real_interface($interface);
- exec("/sbin/ifconfig $interface | /usr/bin/grep -v grep | /usr/bin/grep carp: | /usr/bin/grep 'vhid {$vhid}'", $carp_query);
+ $carp_query = '';
+ $_gb = exec("/sbin/ifconfig $interface | /usr/bin/grep -v grep | /usr/bin/grep carp: | /usr/bin/head -n 1", $carp_query);
foreach($carp_query as $int) {
- if(stristr($int, "MASTER"))
+ if (stripos($int, "MASTER"))
return gettext("MASTER");
- if(stristr($int, "BACKUP"))
+ if (stripos($int, "BACKUP"))
return gettext("BACKUP");
- if(stristr($int, "INIT"))
+ if (stripos($int, "INIT"))
return gettext("INIT");
}
return;
@@ -2627,7 +2625,7 @@ function is_ipaddr_configured($ipaddr, $ignore_if = "", $check_localip = false,
$interface_list_vips = get_configured_vips_list(true);
foreach ($interface_list_vips as $id => $vip) {
/* Skip CARP interfaces here since they were already checked above */
- if ($id == $ignore_vip_id || (strstr($ignore_if, '_vip') && $ignore_vip_if == $vip['if']))
+ if ($id == $ignore_vip_id || (substr($ignore_if, 0, 4) == '_vip') && substr($ignore_vip_if, 5) == $vip['uniqdid']))
continue;
if (strcasecmp($ipaddr, $vip['ipaddr']) == 0)
return true;
diff --git a/etc/inc/services.inc b/etc/inc/services.inc
index 194b4f3..ea9358a 100644
--- a/etc/inc/services.inc
+++ b/etc/inc/services.inc
@@ -1783,10 +1783,10 @@ function services_dnsmasq_configure() {
} else {
$if = get_real_interface($interface);
if (does_interface_exist($if)) {
- $laddr = find_interface_ip($if);
+ $laddr = get_interface_ip($interface);
if (is_ipaddrv4($laddr))
$listen_addresses .= " --listen-address={$laddr} ";
- $laddr6 = find_interface_ipv6($if);
+ $laddr6 = get_interface_ipv6($interface);
if (is_ipaddrv6($laddr6) && !isset($config['dnsmasq']['strictbind'])) {
/*
* XXX: Since dnsmasq does not support link-local address
@@ -2029,7 +2029,7 @@ EOD;
} else {
$if = get_real_interface($config['snmpd']['bindip']);
if (does_interface_exist($if))
- $bind_to_ip = find_interface_ip($if);
+ $bind_to_ip = get_interface_ip($config['snmpd']['bindip']);
}
}
diff --git a/etc/inc/system.inc b/etc/inc/system.inc
index ba24c88..d40faa6 100644
--- a/etc/inc/system.inc
+++ b/etc/inc/system.inc
@@ -2060,49 +2060,4 @@ function system_get_dmesg_boot() {
return file_get_contents("{$g['varlog_path']}/dmesg.boot");
}
-function get_possible_listen_ips($include_ipv6_link_local=false) {
- $interfaces = get_configured_interface_with_descr();
- $carplist = get_configured_carp_interface_list();
- $listenips = array();
- foreach ($carplist as $cif => $carpip)
- $interfaces[$cif] = $carpip." (".get_vip_descr($carpip).")";
- $aliaslist = get_configured_ip_aliases_list();
- foreach ($aliaslist as $aliasip => $aliasif)
- $interfaces[$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
- foreach ($interfaces as $iface => $ifacename) {
- $tmp["name"] = $ifacename;
- $tmp["value"] = $iface;
- $listenips[] = $tmp;
- if ($include_ipv6_link_local) {
- $llip = find_interface_ipv6_ll(get_real_interface($iface));
- if (!empty($llip)) {
- $tmp["name"] = "{$ifacename} IPv6 Link-Local";
- $tmp["value"] = $llip;
- $listenips[] = $tmp;
- }
- }
- }
- $tmp["name"] = "Localhost";
- $tmp["value"] = "lo0";
- $listenips[] = $tmp;
- return $listenips;
-}
-
-function get_possible_traffic_source_addresses($include_ipv6_link_local=false) {
- global $config;
- $sourceips = get_possible_listen_ips($include_ipv6_link_local);
- foreach (array('server', 'client') as $mode) {
- if (is_array($config['openvpn']["openvpn-{$mode}"])) {
- foreach ($config['openvpn']["openvpn-{$mode}"] as $id => $setting) {
- if (!isset($setting['disable'])) {
- $vpn = array();
- $vpn['value'] = 'ovpn' . substr($mode, 0, 1) . $setting['vpnid'];
- $vpn['name'] = gettext("OpenVPN") . " ".$mode.": ".htmlspecialchars($setting['description']);
- $sourceips[] = $vpn;
- }
- }
- }
- }
- return $sourceips;
-}
?>
diff --git a/etc/inc/util.inc b/etc/inc/util.inc
index 8e3eed7..b5b0877 100644
--- a/etc/inc/util.inc
+++ b/etc/inc/util.inc
@@ -953,7 +953,7 @@ function get_configured_carp_interface_list($carpinterface = '', $family = 'inet
switch ($vip['mode']) {
case "carp":
if (!empty($carpinterface)) {
- if ($carpinterface == "{$vip['interface']}_vip{$vip['vhid']}") {
+ if ($carpinterface == "_vip{$vip['uniqid']}") {
switch ($what) {
case 'subnet':
if ($family == 'inet' && is_ipaddrv4($vip['subnet']))
@@ -983,7 +983,7 @@ function get_configured_carp_interface_list($carpinterface = '', $family = 'inet
}
}
} else {
- $iflist["{$vip['interface']}_vip{$vip['vhid']}"] = $vip['subnet'];
+ $iflist["_vip{$vip['uniqid']}"] = $vip['subnet'];
}
break;
}
diff --git a/etc/inc/vpn.inc b/etc/inc/vpn.inc
index 0b8dfc1..46ed338 100644
--- a/etc/inc/vpn.inc
+++ b/etc/inc/vpn.inc
@@ -227,7 +227,6 @@ function vpn_ipsec_configure($ipchg = false)
if ($ph2ent['pinghost']) {
if (!is_array($iflist))
$iflist = get_configured_interface_list();
- $viplist = get_configured_vips_list();
$srcip = null;
$local_subnet = ipsec_idinfo_to_cidr($ph2ent['localid'], true, $ph2ent['mode']);
if(is_ipaddrv6($ph2ent['pinghost'])) {
@@ -253,6 +252,7 @@ function vpn_ipsec_configure($ipchg = false)
}
/* if no valid src IP was found in configured interfaces, try the vips */
if (is_null($srcip)) {
+ $viplist = get_configured_vips_list();
foreach ($viplist as $vip) {
if (ip_in_subnet($vip['ipaddr'], $local_subnet)) {
$srcip = $vip['ipaddr'];
diff --git a/etc/rc.carpbackup b/etc/rc.carpbackup
index 4ecd1c9..19da7a4 100755
--- a/etc/rc.carpbackup
+++ b/etc/rc.carpbackup
@@ -45,21 +45,26 @@ if (!strstr($argument, "@"))
list($vhid, $iface) = explode("@", $argument);
$friendly = convert_real_interface_to_friendly_interface_name($iface);
+$friendly_descr = convert_friendly_interface_to_friendly_descr($friendly);
+$vips = link_interface_to_vips($friendly, '', $vhid);
$carp_iface = "{$friendly}_vip{$vhid}";
-$friendly_descr = convert_friendly_interface_to_friendly_descr($carp_iface);
-$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "BACKUP" for vhid %s', $argument, $friendly_descr, $vhid);
+foreach ($vips as $vip) {
+ $notificationmsg = sprintf('Carp cluster member "{$friendly_descr)(%2$s): {$vip['subnet']} (%1$s)" has resumed the state "BACKUP" for vhid %s', $argument, $vip['descr'], $vhid);
-notify_via_smtp($notificationmsg);
-notify_via_growl($notificationmsg);
-log_error($notificationmsg);
+ notify_via_smtp($notificationmsg);
+ notify_via_growl($notificationmsg);
+ log_error($notificationmsg);
+}
/* Stop OpenVPN clients running on this VIP, since multiple active OpenVPN clients on a CARP cluster can be problematic. */
global $config;
if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-client'])) {
foreach ($config['openvpn']['openvpn-client'] as $settings) {
- if ($settings['interface'] == $carp_iface) {
- log_error("Stopping OpenVPN client instance on {$friendly_descr} because of transition to CARP backup.");
- openvpn_restart('client', $settings);
+ foreach ($vips as $vip) {
+ if ($settings['interface'] == "_vip{$vip['uniqid']}") {
+ log_error("Stopping OpenVPN client instance on {$friendly_descr} because of transition to CARP backup.");
+ openvpn_restart('client', $settings);
+ }
}
}
}
diff --git a/etc/rc.carpmaster b/etc/rc.carpmaster
index 1ae652f..6e1ad61 100755
--- a/etc/rc.carpmaster
+++ b/etc/rc.carpmaster
@@ -45,21 +45,26 @@ if (!strstr($argument, "@"))
list($vhid, $iface) = explode("@", $argument);
$friendly = convert_real_interface_to_friendly_interface_name($iface);
-$carp_iface = "{$friendly}_vip${vhid}";
-$friendly_descr = convert_friendly_interface_to_friendly_descr($carp_iface);
-$notificationmsg = sprintf('Carp cluster member "%2$s (%1$s)" has resumed the state "MASTER" for vhid %s', $argument, $friendly_descr, $vhid);
+$friendly_descr = convert_friendly_interface_to_friendly_descr($friendly);
+$vips = link_interface_to_vips($friendly, '', $vhid);
+$carp_iface = "{$friendly}_vip{$vhid}";
+foreach ($vips as $vip) {
+ $notificationmsg = sprintf('Carp cluster member "{$friendly_descr)(%2$s): {$vip['subnet']} (%1$s)" has resumed the state "MASTER" for vhid %s', $argument, $vip['descr'], $vhid);
-notify_via_smtp($notificationmsg);
-notify_via_growl($notificationmsg);
-log_error($notificationmsg);
+ notify_via_smtp($notificationmsg);
+ notify_via_growl($notificationmsg);
+ log_error($notificationmsg);
+}
/* Start OpenVPN clients running on this VIP, since they should be in the stopped state while the VIP is CARP Backup. */
global $config;
if (is_array($config['openvpn']) && is_array($config['openvpn']['openvpn-client'])) {
foreach ($config['openvpn']['openvpn-client'] as $settings) {
- if ($settings['interface'] == $carp_iface) {
- log_error("Starting OpenVPN client instance on {$friendly_descr} because of transition to CARP master.");
- openvpn_restart('client', $settings);
+ foreach ($vips as $vip) {
+ if ($settings['interface'] == "_vip{$vip['uniqid']}") {
+ log_error("Starting OpenVPN client instance on {$friendly_descr} because of transition to CARP master.");
+ openvpn_restart('client', $settings);
+ }
}
}
}
diff --git a/usr/local/pkg/openntpd.inc b/usr/local/pkg/openntpd.inc
index dcbb50a..8907493 100644
--- a/usr/local/pkg/openntpd.inc
+++ b/usr/local/pkg/openntpd.inc
@@ -19,14 +19,6 @@ EOD;
write_rcfile($rcfile);
}
-function openntpd_get_iface_ip($iface) {
- $iface = convert_friendly_interface_to_real_interface_name($iface);
- $line = trim(shell_exec("ifconfig " . escapeshellarg($iface) . " | grep inet | grep -v inet6"));
- list($dummy, $ip, $dummy2, $dummy3) = explode(' ', $line);
-
- return $ip;
-}
-
function openntpd_resync() {
global $g, $config;
@@ -37,7 +29,7 @@ function openntpd_resync() {
$conf = '';
$ifaces = explode(',', $settings['interface']);
- $ips = array_map('openntpd_get_iface_ip', $ifaces);
+ $ips = array_map('get_interface_ip', $ifaces);
foreach ($ips as $ip)
$conf .= "listen on $ip\n";
@@ -45,7 +37,7 @@ function openntpd_resync() {
foreach ($servers as $server)
$conf .= "servers $server\n";
- file_put_contents($config_file, $conf);
+ @file_put_contents($config_file, $conf);
}
else {
if (file_exists($config_file))
diff --git a/usr/local/www/carp_status.php b/usr/local/www/carp_status.php
index cbccbc6..db55c3b 100644
--- a/usr/local/www/carp_status.php
+++ b/usr/local/www/carp_status.php
@@ -162,12 +162,8 @@ include("head.inc");
if ($carp['mode'] != "carp")
continue;
$ipaddress = $carp['subnet'];
- $password = $carp['password'];
- $netmask = $carp['subnet_bits'];
$vhid = $carp['vhid'];
- $advskew = $carp['advskew'];
- $advbase = $carp['advbase'];
- $status = get_carp_interface_status("{$carp['interface']}_vip{$carp['vhid']}");
+ $status = get_carp_interface_status("_vhid{$carp['uniqid']}");
echo "<tr>";
$align = "style=\"vertical-align:middle\"";
if($carp_enabled == false) {
diff --git a/usr/local/www/interfaces_gif_edit.php b/usr/local/www/interfaces_gif_edit.php
index a290e97..294c1ca 100644
--- a/usr/local/www/interfaces_gif_edit.php
+++ b/usr/local/www/interfaces_gif_edit.php
@@ -153,13 +153,7 @@ include("head.inc");
<td width="78%" class="vtable">
<select name="if" class="formselect">
<?php
- $portlist = get_configured_interface_with_descr();
- $carplist = get_configured_carp_interface_list();
- foreach ($carplist as $cif => $carpip)
- $portlist[$cif] = $carpip." (".get_vip_descr($carpip).")";
- $aliaslist = get_configured_ip_aliases_list();
- foreach ($aliaslist as $aliasip => $aliasif)
- $portlist[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
+ $portlist = get_possible_listen_ips();
foreach ($portlist as $ifn => $ifinfo) {
echo "<option value=\"{$ifn}\"";
if ($ifn == $pconfig['if'])
diff --git a/usr/local/www/interfaces_gre_edit.php b/usr/local/www/interfaces_gre_edit.php
index b360f17..6a7eeb1 100644
--- a/usr/local/www/interfaces_gre_edit.php
+++ b/usr/local/www/interfaces_gre_edit.php
@@ -147,13 +147,7 @@ include("head.inc");
<td width="78%" class="vtable">
<select name="if" class="formselect">
<?php
- $portlist = get_configured_interface_with_descr();
- $carplist = get_configured_carp_interface_list();
- foreach ($carplist as $cif => $carpip)
- $portlist[$cif] = $carpip." (".get_vip_descr($carpip).")";
- $aliaslist = get_configured_ip_aliases_list();
- foreach ($aliaslist as $aliasip => $aliasif)
- $portlist[$aliasif.'|'.$aliasip] = $aliasip." (".get_vip_descr($aliasip).")";
+ $portlist = get_possible_listen_ips();
foreach ($portlist as $ifn => $ifinfo) {
echo "<option value=\"{$ifn}\"";
if ($ifn == $pconfig['if'])
diff --git a/usr/local/www/services_dnsmasq.php b/usr/local/www/services_dnsmasq.php
index 0361932..273f81d 100644
--- a/usr/local/www/services_dnsmasq.php
+++ b/usr/local/www/services_dnsmasq.php
@@ -270,21 +270,22 @@ function show_advanced_dns() {
<td width="78%" class="vtable">
<?php
$interface_addresses = get_possible_listen_ips(true);
- $size=count($interface_addresses)+1;
?>
<?=gettext("Interface IPs used by the DNS Forwarder for responding to queries from clients. If an interface has both IPv4 and IPv6 IPs, both are used. Queries to other interface IPs not selected below are discarded. The default behavior is to respond to queries on every available IPv4 and IPv6 address.");?>
<br /><br />
- <select id="interface" name="interface[]" multiple="multiple" class="formselect" size="<?php echo $size; ?>">
+ <select id="interface" name="interface[]" multiple="multiple" class="formselect" size="5">
<option value="" <?php if (empty($pconfig['interface']) || empty($pconfig['interface'][0])) echo 'selected="selected"'; ?>>All</option>
- <?php foreach ($interface_addresses as $laddr):
+ <?php foreach ($interface_addresses as $laddr => $ldescr):
$selected = "";
- if (in_array($laddr['value'], $pconfig['interface']))
+ if (in_array($laddr, $pconfig['interface']))
$selected = 'selected="selected"';
?>
- <option value="<?=$laddr['value'];?>" <?=$selected;?>>
- <?=htmlspecialchars($laddr['name']);?>
+ <option value="<?=$laddr;?>" <?=$selected;?>>
+ <?=htmlspecialchars($ldescr);?>
</option>
- <?php endforeach; ?>
+ <?php endforeach;
+ unset($interface_addresses);
+ ?>
</select>
<br /><br />
</td>
diff --git a/usr/local/www/services_snmp.php b/usr/local/www/services_snmp.php
index 3aef6a0..cfdd958 100644
--- a/usr/local/www/services_snmp.php
+++ b/usr/local/www/services_snmp.php
@@ -420,15 +420,17 @@ function enable_change(whichone) {
<select name="bindip" class="formselect">
<option value="">All</option>
<?php $listenips = get_possible_listen_ips();
- foreach ($listenips as $lip):
+ foreach ($listenips as $lip => $ldescr):
$selected = "";
- if ($lip['value'] == $pconfig['bindip'])
+ if ($lip == $pconfig['bindip'])
$selected = "selected=\"selected\"";
?>
- <option value="<?=$lip['value'];?>" <?=$selected;?>>
+ <option value="<?=$ldescr;?>" <?=$selected;?>>
<?=htmlspecialchars($lip['name']);?>
</option>
- <?php endforeach; ?>
+ <?php endforeach;
+ unset($listenips);
+ ?>
</select>
</td>
</tr>
diff --git a/usr/local/www/services_unbound.php b/usr/local/www/services_unbound.php
index 2b943dd..4e307b3 100644
--- a/usr/local/www/services_unbound.php
+++ b/usr/local/www/services_unbound.php
@@ -272,22 +272,21 @@ function show_advanced_dns() {
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Network Interfaces"); ?></td>
<td width="78%" class="vtable">
- <?php
- $interface_addresses = get_possible_listen_ips(false);
- $size=count($interface_addresses)+1;
- ?>
+ <?php
+ $interface_addresses = get_possible_listen_ips(true);
+ ?>
<?=gettext("Interface IPs used by the DNS Resolver for responding to queries from clients. If an interface has both IPv4 and IPv6 IPs, both are used. Queries to other interface IPs not selected below are discarded. The default behavior is to respond to queries on every available IPv4 and IPv6 address.");?>
<br /><br />
<select id="active_interface" name="active_interface[]" multiple="multiple" size="<?php echo $size; ?>">
<option value="all" <?php if (empty($pconfig['active_interface']) || empty($pconfig['active_interface'][0]) || in_array("all", $pconfig['active_interface'], true)) echo 'selected="selected"'; ?>>All</option>
<?php
- foreach ($interface_addresses as $laddr):
+ foreach ($interface_addresses as $laddr => ldescr):
$selected = "";
- if (in_array($laddr['value'], $pconfig['active_interface']))
+ if (in_array($laddr, $pconfig['active_interface']))
$selected = 'selected="selected"';
?>
- <option value="<?=$laddr['value'];?>" <?=$selected;?>>
- <?=htmlspecialchars($laddr['name']);?>
+ <option value="<?=$laddr;?>" <?=$selected;?>>
+ <?=htmlspecialchars($ldescr);?>
</option>
<?php endforeach; ?>
</select>
@@ -297,10 +296,6 @@ function show_advanced_dns() {
<tr>
<td width="22%" valign="top" class="vncellreq"><?=gettext("Outgoing Network Interfaces"); ?></td>
<td width="78%" class="vtable">
- <?php
- $interface_addresses = get_possible_listen_ips(false);
- $size=count($interface_addresses)+1;
- ?>
<?=gettext("Utilize different network interface(s) that the DNS Resolver will use to send queries to authoritative servers and receive their replies. By default all interfaces are used.");?>
<br /><br />
<select id="outgoing_interface" name="outgoing_interface[]" multiple="multiple" size="<?php echo $size; ?>">
@@ -308,13 +303,15 @@ function show_advanced_dns() {
<?php
foreach ($interface_addresses as $laddr):
$selected = "";
- if (in_array($laddr['value'], $pconfig['outgoing_interface']))
+ if (in_array($laddr, $pconfig['outgoing_interface']))
$selected = 'selected="selected"';
?>
- <option value="<?=$laddr['value'];?>" <?=$selected;?>>
- <?=htmlspecialchars($laddr['name']);?>
+ <option value="<?=$laddr;?>" <?=$selected;?>>
+ <?=htmlspecialchars($ldescr);?>
</option>
- <?php endforeach; ?>
+ <?php endforeach;
+ unset($interface_addresses);
+ ?>
</select>
<br /><br />
</td>
diff --git a/usr/local/www/system_gateway_groups_edit.php b/usr/local/www/system_gateway_groups_edit.php
index 11b4dd5..01dede2 100644
--- a/usr/local/www/system_gateway_groups_edit.php
+++ b/usr/local/www/system_gateway_groups_edit.php
@@ -51,7 +51,6 @@ if (!is_array($config['gateways']['gateway_group']))
$a_gateway_groups = &$config['gateways']['gateway_group'];
$a_gateways = return_gateways_array();
-$carplist = get_configured_carp_interface_list();
$categories = array('down' => gettext("Member Down"),
'downloss' => gettext("Packet Loss"),
@@ -248,6 +247,7 @@ jQuery(function ($) {
<td class="listhdrr">Description</td>
</tr>
<?php
+ $carplist = get_configured_carp_interface_list($interface);
foreach($a_gateways as $gwname => $gateway) {
if(!empty($pconfig['item'])) {
$af = explode("|", $pconfig['item'][0]);
@@ -296,8 +296,6 @@ jQuery(function ($) {
echo "<option value='address' {$selected['address']} >" . gettext("Interface Address") . "</option>\n";
foreach($carplist as $vip => $address) {
echo "<!-- $vip - $address - $interface -->\n";
- if(!preg_match("/^{$interface}_/i", $vip))
- continue;
if(($gateway['ipprotocol'] == "inet") && (!is_ipaddrv4($address)))
continue;
if(($gateway['ipprotocol'] == "inet6") && (!is_ipaddrv6($address)))
diff --git a/usr/local/www/widgets/widgets/carp_status.widget.php b/usr/local/www/widgets/widgets/carp_status.widget.php
index 159440d..8d2e5ed 100644
--- a/usr/local/www/widgets/widgets/carp_status.widget.php
+++ b/usr/local/www/widgets/widgets/carp_status.widget.php
@@ -52,7 +52,7 @@ $carp_enabled = get_carp_status();
$netmask = $carp['subnet_bits'];
$vhid = $carp['vhid'];
$advskew = $carp['advskew'];
- $status = get_carp_interface_status("{$carp['interface']}_vip{$vhid}");
+ $status = get_carp_interface_status("_vip{$carp['uniqid']}");
?>
<tr>
<td class="vncellt" width="35%">
diff --git a/usr/local/www/xmlrpc.php b/usr/local/www/xmlrpc.php
index 2f2d944..49fad44 100755
--- a/usr/local/www/xmlrpc.php
+++ b/usr/local/www/xmlrpc.php
@@ -213,9 +213,9 @@ function restore_config_section_xmlrpc($raw_params) {
foreach ($config['virtualip']['vip'] as $vipindex => $vip) {
if ($vip['mode'] == "carp")
$oldvips["{$vip['interface']}_vip{$vip['vhid']}"] = "{$vip['password']}{$vip['advskew']}{$vip['subnet']}{$vip['subnet_bits']}{$vip['advbase']}";
- else if ($vip['mode'] == "ipalias" && (strstr($vip['interface'], "_vip") || strstr($vip['interface'], "lo0")))
+ else if ($vip['mode'] == "ipalias" && (substr($vip['interface'], 0, 4) == '_vip') || strpos($vip['interface'], "lo0")))
$oldvips[$vip['subnet']] = "{$vip['interface']}{$vip['subnet']}{$vip['subnet_bits']}";
- else if (($vip['mode'] == "ipalias" || $vip['mode'] == 'proxyarp') && !(strstr($vip['interface'], "_vip") || strstr($vip['interface'], "lo0")))
+ else if (($vip['mode'] == "ipalias" || $vip['mode'] == 'proxyarp') && !(substr($vip['interface'], 0, 4) == '_vip') || strpos($vip['interface'], "lo0")))
$vipbackup[] = $vip;
}
}
OpenPOWER on IntegriCloud