summaryrefslogtreecommitdiffstats
path: root/etc/inc/pfsense-utils.inc
diff options
context:
space:
mode:
Diffstat (limited to 'etc/inc/pfsense-utils.inc')
-rw-r--r--etc/inc/pfsense-utils.inc18
1 files changed, 15 insertions, 3 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 31a9c59..2f3b7f7 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -369,9 +369,21 @@ function filter_translate_type_to_real_interface($interface) {
* get_carp_interface_status($carpinterface): returns the status of a carp ip
*/
function get_carp_interface_status($carpinterface) {
- $result = does_interface_exist($carpinterface);
- if($result <> true) return false;
- $status = exec_command("/sbin/ifconfig {$carpinterface} | /usr/bin/grep \"carp:\" | /usr/bin/cut -d\" \" -f2");
+ /* basically cache the contents of ifconfig statement
+ to speed up this routine */
+ global $carp_query;
+ if($carp_query == "")
+ $carp_query = split("\n", `/sbin/ifconfig | /usr/bin/grep carp`);
+ $found_interface = 0;
+ foreach($carp_query as $int) {
+ if($found_interface == 1) {
+ if(stristr($int, "MASTER") == true) return "MASTER";
+ if(stristr($int, "BACKUP") == true) return "BACKUP";
+ if(stristr($int, "INIT") == true) return "INIT";
+ return false;
+ }
+ if(stristr($int, $carpinterface) == true) $found_interface=1;
+ }
return $status;
}
OpenPOWER on IntegriCloud